[BROWSEUI]
[reactos.git] / reactos / drivers / filesystems / ext2 / inc / ext2fs.h
1 /*
2 * COPYRIGHT: See COPYRIGHT.TXT
3 * PROJECT: Ext2 File System Driver for WinNT/2K/XP
4 * FILE: Ext2fs.h
5 * PURPOSE: Header file: ext2 structures
6 * PROGRAMMER: Matt Wu <mattwu@163.com>
7 * HOMEPAGE: http://www.ext2fsd.com
8 * UPDATE HISTORY:
9 */
10
11 #ifndef _EXT2_HEADER_
12 #define _EXT2_HEADER_
13
14 /* INCLUDES *************************************************************/
15 #include <linux/module.h>
16 #include <ntdddisk.h>
17 #ifdef __REACTOS__
18 #include <ndk/rtlfuncs.h>
19 #include <pseh/pseh2.h>
20 #endif
21 #include <stdio.h>
22 #include <time.h>
23 #include <string.h>
24 #include <linux/ext2_fs.h>
25 #include <linux/ext3_fs.h>
26 #include <linux/ext3_fs_i.h>
27 #include <linux/ext4.h>
28
29 /* DEBUG ****************************************************************/
30 #if DBG
31 # define EXT2_DEBUG 1
32 #else
33 # define EXT2_DEBUG 0
34 #endif
35
36 #define EXT_DEBUG_BREAKPOINT FALSE
37
38 #if EXT2_DEBUG && EXT_DEBUG_BREAKPOINT
39 //#if _X86_
40 //#define DbgBreak() __asm int 3
41 //#else
42 #define DbgBreak() KdBreakPoint()
43 //#endif
44 #else
45 #define DbgBreak()
46 #endif
47
48 /* STRUCTS & CONSTS******************************************************/
49
50 #define EXT2FSD_VERSION "0.68"
51
52
53 /* WDK DEFINITIONS ******************************************************/
54
55
56 /* COMPILER SWITCH / OPTIONS ********************************************/
57
58 //
59 // Ext2Fsd build options
60 //
61
62 // To support driver dynamics unload
63
64 #define EXT2_UNLOAD FALSE
65
66 // To support inode size expansion (fallocate)
67
68 #define EXT2_PRE_ALLOCATION_SUPPORT TRUE
69
70 //
71 // Constants
72 //
73
74 #define EXT2_MAX_NESTED_LINKS (8)
75 #define EXT2_LINKLEN_IN_INODE (60)
76 #define EXT2_BLOCK_TYPES (0x04)
77
78 #define MAXIMUM_RECORD_LENGTH (0x10000)
79
80 #define SECTOR_BITS (Vcb->SectorBits)
81 #define SECTOR_SIZE (Vcb->DiskGeometry.BytesPerSector)
82 #define DEFAULT_SECTOR_SIZE (0x200)
83
84 #define SUPER_BLOCK_OFFSET (0x400)
85 #define SUPER_BLOCK_SIZE (0x400)
86
87 #define READ_AHEAD_GRANULARITY (0x10000)
88
89 #define SUPER_BLOCK (Vcb->SuperBlock)
90
91 #define INODE_SIZE (Vcb->InodeSize)
92 #define BLOCK_SIZE (Vcb->BlockSize)
93 #define BLOCK_BITS (SUPER_BLOCK->s_log_block_size + 10)
94 #define GROUP_DESC_SIZE (Vcb->sbi.s_desc_size)
95
96 #define INODES_COUNT (Vcb->SuperBlock->s_inodes_count)
97
98 #define INODES_PER_GROUP (SUPER_BLOCK->s_inodes_per_group)
99 #define BLOCKS_PER_GROUP (SUPER_BLOCK->s_blocks_per_group)
100 #define TOTAL_BLOCKS (ext3_blocks_count(SUPER_BLOCK))
101
102 #define EXT2_FIRST_DATA_BLOCK (SUPER_BLOCK->s_first_data_block)
103
104 typedef struct ext3_super_block EXT2_SUPER_BLOCK, *PEXT2_SUPER_BLOCK;
105 typedef struct ext3_inode EXT2_INODE, *PEXT2_INODE;
106 typedef struct ext4_group_desc EXT2_GROUP_DESC, *PEXT2_GROUP_DESC;
107 typedef struct ext3_dir_entry EXT2_DIR_ENTRY, *PEXT2_DIR_ENTRY;
108 typedef struct ext3_dir_entry_2 EXT2_DIR_ENTRY2, *PEXT2_DIR_ENTRY2;
109
110 #define CEILING_ALIGNED(T, A, B) (((A) + (B) - 1) & (~((T)(B) - 1)))
111 #define COCKLOFT_ALIGNED(T, A, B) (((A) + (B)) & (~((T)(B) - 1)))
112
113
114
115 /*
116 * Compile-time assertion: (Lustre version)
117 *
118 * Check an invariant described by a constant expression at compile time by
119 * forcing a compiler error if it does not hold. \a cond must be a constant
120 * expression as defined by the ISO C Standard:
121 *
122 * 6.8.4.2 The switch statement
123 * ....
124 * [#3] The expression of each case label shall be an integer
125 * constant expression and no two of the case constant
126 * expressions in the same switch statement shall have the same
127 * value after conversion...
128 *
129 */
130
131 #define CL_ASSERT(cond) do {switch('x') {case (cond): case 0: break;}} while (0)
132
133 /* File System Releated *************************************************/
134
135 #define DRIVER_NAME "Ext2Fsd"
136 #define DEVICE_NAME L"\\Ext2Fsd"
137 #define CDROM_NAME L"\\Ext2CdFsd"
138
139 // Registry
140
141 #define PARAMETERS_KEY L"\\Parameters"
142 #define VOLUMES_KEY L"\\Volumes"
143
144 #define READING_ONLY L"Readonly"
145 #define WRITING_SUPPORT L"WritingSupport"
146 #define CHECKING_BITMAP L"CheckingBitmap"
147 #define EXT3_FORCEWRITING L"Ext3ForceWriting"
148 #define CODEPAGE_NAME L"CodePage"
149 #define HIDING_PREFIX L"HidingPrefix"
150 #define HIDING_SUFFIX L"HidingSuffix"
151 #define AUTO_MOUNT L"AutoMount"
152 #define MOUNT_POINT L"MountPoint"
153 #define UID L"uid"
154 #define GID L"gid"
155 #define EUID L"euid"
156 #define EGID L"egid"
157
158 #define DOS_DEVICE_NAME L"\\DosDevices\\Ext2Fsd"
159
160 // To support ext2fsd unload routine
161 #if EXT2_UNLOAD
162 //
163 // Private IOCTL to make the driver ready to unload
164 //
165 #define IOCTL_PREPARE_TO_UNLOAD \
166 CTL_CODE(FILE_DEVICE_UNKNOWN, 2048, METHOD_NEITHER, FILE_WRITE_ACCESS)
167
168 #endif // EXT2_UNLOAD
169
170 #include "common.h"
171
172 #ifndef _GNU_NTIFS_
173 typedef IO_STACK_LOCATION EXTENDED_IO_STACK_LOCATION, *PEXTENDED_IO_STACK_LOCATION;
174 #endif
175
176 #define IsFlagOn(a,b) ((BOOLEAN)(FlagOn(a,b) == b))
177 #ifndef FlagOn
178 #define FlagOn(_F,_SF) ((_F) & (_SF))
179 #endif
180
181 #ifndef BooleanFlagOn
182 #define BooleanFlagOn(F,SF) ((BOOLEAN)(((F) & (SF)) != 0))
183 #endif
184
185 #ifndef SetFlag
186 #define SetFlag(_F,_SF) ((_F) |= (_SF))
187 #endif
188
189 #ifndef ClearFlag
190 #define ClearFlag(_F,_SF) ((_F) &= ~(_SF))
191 #endif
192
193 #ifndef min
194 #define min(a,b) (((a) < (b)) ? (a) : (b))
195 #endif
196
197 #ifndef max
198 #define max(a,b) (((a) > (b)) ? (a) : (b))
199 #endif
200
201 #ifdef _WIN2K_TARGET_
202 #define InterlockedOr _InterlockedOr
203 LONG
204 _InterlockedAnd (
205 IN OUT LONG volatile *Target,
206 IN LONG Set
207 );
208
209 #pragma intrinsic (_InterlockedAnd)
210 #define InterlockedAnd _InterlockedAnd
211
212 LONG
213 _InterlockedXor (
214 IN OUT LONG volatile *Target,
215 IN LONG Set
216 );
217
218 #pragma intrinsic (_InterlockedXor)
219 #define InterlockedXor _InterlockedXor
220
221 #endif /* only for win2k */
222
223 #if EXT2_DEBUG
224
225 #define SetLongFlag(_F,_SF) Ext2SetFlag((PULONG)&(_F), (ULONG)(_SF))
226 #define ClearLongFlag(_F,_SF) Ext2ClearFlag((PULONG)&(_F), (ULONG)(_SF))
227
228 #ifdef __REACTOS__
229 static
230 #endif
231 __inline
232 VOID
233 Ext2SetFlag(PULONG Flags, ULONG FlagBit)
234 {
235 ULONG _ret = InterlockedOr(Flags, FlagBit);
236 ASSERT(*Flags == (_ret | FlagBit));
237 }
238
239 #ifdef __REACTOS__
240 static
241 #endif
242 __inline
243 VOID
244 Ext2ClearFlag(PULONG Flags, ULONG FlagBit)
245 {
246 ULONG _ret = InterlockedAnd(Flags, ~FlagBit);
247 ASSERT(*Flags == (_ret & (~FlagBit)));
248 }
249
250 #else
251
252 #define SetLongFlag(_F,_SF) InterlockedOr(&(_F), (ULONG)(_SF))
253 #define ClearLongFlag(_F,_SF) InterlockedAnd(&(_F), ~((ULONG)(_SF)))
254
255 #endif /* release */
256
257 #define Ext2RaiseStatus(IRPCONTEXT,STATUS) { \
258 (IRPCONTEXT)->ExceptionCode = (STATUS); \
259 ExRaiseStatus((STATUS)); \
260 }
261
262 #define Ext2NormalizeAndRaiseStatus(IRPCONTEXT,STATUS) { \
263 (IRPCONTEXT)->ExceptionCode = STATUS; \
264 if ((STATUS) == STATUS_VERIFY_REQUIRED) { ExRaiseStatus((STATUS)); } \
265 ExRaiseStatus(FsRtlNormalizeNtstatus((STATUS),STATUS_UNEXPECTED_IO_ERROR)); \
266 }
267
268 //
269 // Define IsWritingToEof for write (append) operations
270 //
271
272 #define FILE_WRITE_TO_END_OF_FILE 0xffffffff
273
274 #define IsWritingToEof(Pos) (((Pos).LowPart == FILE_WRITE_TO_END_OF_FILE) && \
275 ((Pos).HighPart == -1 ))
276
277 #define IsDirectory(Fcb) IsMcbDirectory((Fcb)->Mcb)
278 #define IsSpecialFile(Fcb) IsMcbSpecialFile((Fcb)->Mcb)
279 #define IsSymLink(Fcb) IsMcbSymLink((Fcb)->Mcb)
280 #define IsInodeSymLink(I) S_ISLNK((I)->i_mode)
281 #define IsRoot(Fcb) IsMcbRoot((Fcb)->Mcb)
282
283 //
284 // Pool Tags
285 //
286
287 #define TAG_VPB ' bpV'
288 #define VPB_SIZE sizeof(VPB)
289
290 #define EXT2_DATA_MAGIC 'BD2E'
291 #define EXT2_INAME_MAGIC 'NI2E'
292 #define EXT2_FNAME_MAGIC 'NF2E'
293 #define EXT2_VNAME_MAGIC 'NV2E'
294 #define EXT2_DENTRY_MAGIC 'ED2E'
295 #define EXT2_DIRSP_MAGIC 'SD2E'
296 #define EXT2_SB_MAGIC 'BS2E'
297 #define EXT2_GD_MAGIC 'DG2E'
298 #define EXT2_FLIST_MAGIC 'LF2E'
299 #define EXT2_PARAM_MAGIC 'PP2E'
300 #define EXT2_RWC_MAGIC 'WR2E'
301
302 //
303 // Bug Check Codes Definitions
304 //
305
306 #define EXT2_FILE_SYSTEM (FILE_SYSTEM)
307
308 #define EXT2_BUGCHK_BLOCK (0x00010000)
309 #define EXT2_BUGCHK_CLEANUP (0x00020000)
310 #define EXT2_BUGCHK_CLOSE (0x00030000)
311 #define EXT2_BUGCHK_CMCB (0x00040000)
312 #define EXT2_BUGCHK_CREATE (0x00050000)
313 #define EXT2_BUGCHK_DEBUG (0x00060000)
314 #define EXT2_BUGCHK_DEVCTL (0x00070000)
315 #define EXT2_BUGCHK_DIRCTL (0x00080000)
316 #define EXT2_BUGCHK_DISPATCH (0x00090000)
317 #define EXT2_BUGCHK_EXCEPT (0x000A0000)
318 #define EXT2_BUGCHK_EXT2 (0x000B0000)
319 #define EXT2_BUGCHK_FASTIO (0x000C0000)
320 #define EXT2_BUGCHK_FILEINFO (0x000D0000)
321 #define EXT2_BUGCHK_FLUSH (0x000E0000)
322 #define EXT2_BUGCHK_FSCTL (0x000F0000)
323 #define EXT2_BUGCHK_INIT (0x00100000)
324 #define EXT2_BUGCHK_LOCK (0x0011000)
325 #define EXT2_BUGCHK_MEMORY (0x0012000)
326 #define EXT2_BUGCHK_MISC (0x0013000)
327 #define EXT2_BUGCHK_READ (0x00140000)
328 #define EXT2_BUGCHK_SHUTDOWN (0x00150000)
329 #define EXT2_BUGCHK_VOLINFO (0x00160000)
330 #define EXT2_BUGCHK_WRITE (0x00170000)
331
332 #define EXT2_BUGCHK_LAST (0x00170000)
333
334 #define Ext2BugCheck(A,B,C,D) { KeBugCheckEx(EXT2_FILE_SYSTEM, A | __LINE__, B, C, D ); }
335
336
337 /* Ext2 file system definions *******************************************/
338
339 //
340 // The second extended file system magic number
341 //
342
343 #define EXT2_SUPER_MAGIC 0xEF53
344
345 #define EXT2_MIN_BLOCK 1024
346 #define EXT2_MIN_FRAG 1024
347 #define EXT2_MAX_USER_BLKSIZE 65536
348 //
349 // Inode flags (Linux uses octad number, but why ? strange!!!)
350 //
351
352 #define S_IFMT 0x0F000 /* 017 0000 */
353 #define S_IFSOCK 0x0C000 /* 014 0000 */
354 #define S_IFLNK 0x0A000 /* 012 0000 */
355 #define S_IFREG 0x08000 /* 010 0000 */
356 #define S_IFBLK 0x06000 /* 006 0000 */
357 #define S_IFDIR 0x04000 /* 004 0000 */
358 #define S_IFCHR 0x02000 /* 002 0000 */
359 #define S_IFIFO 0x01000 /* 001 0000 */
360
361 #define S_ISUID 0x00800 /* 000 4000 */
362 #define S_ISGID 0x00400 /* 000 2000 */
363 #define S_ISVTX 0x00200 /* 000 1000 */
364
365 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
366 #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
367 #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
368 #define S_ISFIL(m) (((m) & S_IFMT) == S_IFFIL)
369 #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
370 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
371 #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
372 #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
373
374 #define S_IPERMISSION_MASK 0x1FF /* */
375
376 #define S_IRWXU 0x1C0 /* 0 0700 */
377 #define S_IRWNU 0x180 /* 0 0600 */
378 #define S_IRUSR 0x100 /* 0 0400 */
379 #define S_IWUSR 0x080 /* 0 0200 */
380 #define S_IXUSR 0x040 /* 0 0100 */
381
382 #define S_IRWXG 0x038 /* 0 0070 */
383 #define S_IRWNG 0x030 /* 0 0060 */
384 #define S_IRGRP 0x020 /* 0 0040 */
385 #define S_IWGRP 0x010 /* 0 0020 */
386 #define S_IXGRP 0x008 /* 0 0010 */
387
388 #define S_IRWXO 0x007 /* 0 0007 */
389 #define S_IRWNO 0x006 /* 0 0006 */
390 #define S_IROTH 0x004 /* 0 0004 */
391 #define S_IWOTH 0x002 /* 0 0002 */
392 #define S_IXOTH 0x001 /* 0 0001 */
393
394 #define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO)
395 #define S_IALLUGO (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO)
396 #define S_IRUGO (S_IRUSR|S_IRGRP|S_IROTH)
397 #define S_IWUGO (S_IWUSR|S_IWGRP|S_IWOTH)
398 #define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH)
399 #define S_IFATTR (S_IRWNU|S_IRWNG|S_IRWNO)
400
401 #define S_ISREADABLE(m) (((m) & S_IPERMISSION_MASK) == (S_IRUSR | S_IRGRP | S_IROTH))
402 #define S_ISWRITABLE(m) (((m) & S_IPERMISSION_MASK) == (S_IWUSR | S_IWGRP | S_IWOTH))
403
404 #define Ext2SetReadable(m) do {(m) = (m) | (S_IRUSR | S_IRGRP | S_IROTH);} while(0)
405 #define Ext2SetWritable(m) do {(m) = (m) | (S_IWUSR | S_IWGRP | S_IWOTH);} while(0)
406
407 #define Ext2SetOwnerWritable(m) do {(m) |= S_IWUSR;} while(0)
408 #define Ext2SetOwnerReadOnly(m) do {(m) &= ~S_IWUSR;} while(0)
409
410 #define Ext2IsOwnerWritable(m) (((m) & S_IWUSR) == S_IWUSR)
411 #define Ext2IsOwnerReadable(m) (((m) & S_IRUSR) == S_IRUSR)
412 #define Ext2IsOwnerReadOnly(m) (!(Ext2IsOwnerWritable(m)) && Ext2IsOwnerReadable(m))
413
414 #define Ext2IsGroupWritable(m) (((m) & S_IWGRP) == S_IWGRP)
415 #define Ext2IsGroupReadable(m) (((m) & S_IRGRP) == S_IRGRP)
416 #define Ext2IsGroupReadOnly(m) (!(Ext2IsGroupWritable(m)) && Ext2IsGroupReadable(m))
417
418 #define Ext2IsOtherWritable(m) (((m) & S_IWOTH) == S_IWOTH)
419 #define Ext2IsOtherReadable(m) (((m) & S_IROTH) == S_IROTH)
420 #define Ext2IsOtherReadOnly(m) (!(Ext2IsOtherWritable(m)) && Ext2IsOtherReadable(m))
421
422 #define Ext2SetReadOnly(m) do {(m) &= ~(S_IWUSR | S_IWGRP | S_IWOTH);} while(0)
423
424
425 #define Ext2FileCanRead (0x1)
426 #define Ext2FileCanWrite (0x2)
427 #define Ext2FileCanExecute (0x4)
428
429
430 /*
431 * We need 8-bytes aligned for all the sturctures
432 * It's a must for all ERESOURCE allocations
433 */
434
435 //
436 // Ext2Fsd Driver Definitions
437 //
438
439 //
440 // EXT2_IDENTIFIER_TYPE
441 //
442 // Identifiers used to mark the structures
443 //
444
445 typedef enum _EXT2_IDENTIFIER_TYPE {
446 #ifdef _MSC_VER
447 EXT2FGD = ':DGF',
448 EXT2VCB = ':BCV',
449 EXT2FCB = ':BCF',
450 EXT2CCB = ':BCC',
451 EXT2ICX = ':XCI',
452 EXT2FSD = ':DSF',
453 EXT2MCB = ':BCM'
454 #else
455 EXT2FGD = 0xE2FD0001,
456 EXT2VCB = 0xE2FD0002,
457 EXT2FCB = 0xE2FD0003,
458 EXT2CCB = 0xE2FD0004,
459 EXT2ICX = 0xE2FD0005,
460 EXT2FSD = 0xE2FD0006,
461 EXT2MCB = 0xE2FD0007
462 #endif
463 } EXT2_IDENTIFIER_TYPE;
464
465 //
466 // EXT2_IDENTIFIER
467 //
468 // Header used to mark the structures
469 //
470 typedef struct _EXT2_IDENTIFIER {
471 EXT2_IDENTIFIER_TYPE Type;
472 ULONG Size;
473 } EXT2_IDENTIFIER, *PEXT2_IDENTIFIER;
474
475
476 #define NodeType(Ptr) (*((EXT2_IDENTIFIER_TYPE *)(Ptr)))
477
478 typedef struct _EXT2_MCB EXT2_MCB, *PEXT2_MCB;
479
480
481 typedef PVOID PBCB;
482
483 //
484
485 //
486 // EXT2_GLOBAL_DATA
487 //
488 // Data that is not specific to a mounted volume
489 //
490
491 typedef VOID (NTAPI *EXT2_REAPER_RELEASE)(PVOID);
492
493 typedef struct _EXT2_REAPER {
494 PETHREAD Thread;
495 KEVENT Engine;
496 KEVENT Wait;
497 EXT2_REAPER_RELEASE Free;
498 ULONG Flags;
499 } EXT2_REAPER, *PEXT2_REAPER;
500
501 #define EXT2_REAPER_FLAG_STOP (1 << 0)
502
503 typedef struct _EXT2_GLOBAL {
504
505 /* Identifier for this structure */
506 EXT2_IDENTIFIER Identifier;
507
508 /* Syncronization primitive for this structure */
509 ERESOURCE Resource;
510
511 /* Global flags for the driver: I put it since
512 FastIoDispatch isn't 8bytes aligned. */
513 ULONG Flags;
514
515 /* Table of pointers to the fast I/O entry points */
516 FAST_IO_DISPATCH FastIoDispatch;
517
518 /* Filter callbacks */
519 FS_FILTER_CALLBACKS FilterCallbacks;
520
521 /* Table of pointers to the Cache Manager callbacks */
522 CACHE_MANAGER_CALLBACKS CacheManagerCallbacks;
523 CACHE_MANAGER_CALLBACKS CacheManagerNoOpCallbacks;
524
525 /* Pointer to the driver object */
526 PDRIVER_OBJECT DriverObject;
527
528 /* Pointer to the disk device object */
529 PDEVICE_OBJECT DiskdevObject;
530
531 /* Pointer to the cdrom device object */
532 PDEVICE_OBJECT CdromdevObject;
533
534 /* List of mounted volumes */
535 LIST_ENTRY VcbList;
536
537 /* Cleaning thread related: resource cleaner */
538 EXT2_REAPER FcbReaper;
539 EXT2_REAPER McbReaper;
540 EXT2_REAPER bhReaper;
541
542 /* Look Aside table of IRP_CONTEXT, FCB, MCB, CCB */
543 NPAGED_LOOKASIDE_LIST Ext2IrpContextLookasideList;
544 NPAGED_LOOKASIDE_LIST Ext2FcbLookasideList;
545 NPAGED_LOOKASIDE_LIST Ext2CcbLookasideList;
546 NPAGED_LOOKASIDE_LIST Ext2McbLookasideList;
547 NPAGED_LOOKASIDE_LIST Ext2ExtLookasideList;
548 NPAGED_LOOKASIDE_LIST Ext2DentryLookasideList;
549 USHORT MaxDepth;
550
551 /* User specified global codepage name */
552 struct {
553 WCHAR PageName[CODEPAGE_MAXLEN];
554 UCHAR AnsiName[CODEPAGE_MAXLEN];
555 struct nls_table * PageTable;
556 } Codepage;
557
558 /* global hiding patterns */
559 WCHAR wHidingPrefix[HIDINGPAT_LEN];
560 WCHAR wHidingSuffix[HIDINGPAT_LEN];
561 BOOLEAN bHidingPrefix;
562 CHAR sHidingPrefix[HIDINGPAT_LEN];
563 BOOLEAN bHidingSuffix;
564 CHAR sHidingSuffix[HIDINGPAT_LEN];
565
566 /* Registery path */
567 UNICODE_STRING RegistryPath;
568
569 /* global memory and i/o statistics and memory allocations
570 of various sturctures */
571
572 EXT2_PERF_STATISTICS_V2 PerfStat;
573
574 } EXT2_GLOBAL, *PEXT2_GLOBAL;
575
576 //
577 // Flags for EXT2_GLOBAL_DATA
578 //
579
580 #define EXT2_UNLOAD_PENDING 0x00000001
581 #define EXT2_SUPPORT_WRITING 0x00000002
582 #define EXT3_FORCE_WRITING 0x00000004
583 #define EXT2_CHECKING_BITMAP 0x00000008
584 #define EXT2_AUTO_MOUNT 0x00000010
585
586 //
587 // Glboal Ext2Fsd Memory Block
588 //
589
590 extern PEXT2_GLOBAL Ext2Global;
591
592 //
593 // memory allocation statistics
594 //
595
596
597 #define INC_MEM_COUNT(_i, _p, _s) do { ASSERT(_p); Ext2TraceMemory(TRUE, (int) (_i), (PVOID)(_p), (LONG)(_s)); } while(0)
598 #define DEC_MEM_COUNT(_i, _p, _s) do { ASSERT(_p); Ext2TraceMemory(FALSE, (int) (_i), (PVOID)(_p), (LONG)(_s)); } while(0)
599 #define INC_IRP_COUNT(IrpContext) Ext2TraceIrpContext(TRUE, (IrpContext))
600 #define DEC_IRP_COUNT(IrpContext) Ext2TraceIrpContext(FALSE, (IrpContext))
601
602 //
603 // Driver Extension define
604 //
605
606 #define IsExt2FsDevice(DO) ((DO == Ext2Global->DiskdevObject) || \
607 (DO == Ext2Global->CdromdevObject) )
608
609 #ifdef _WIN2K_TARGET_
610 #define FSRTL_ADVANCED_FCB_HEADER FSRTL_COMMON_FCB_HEADER
611 #endif
612
613 typedef struct _EXT2_FCBVCB {
614
615 // Command header for Vcb and Fcb
616 FSRTL_ADVANCED_FCB_HEADER Header;
617
618 #ifndef _WIN2K_TARGET_
619 FAST_MUTEX Mutex;
620 #endif
621
622 // Ext2Fsd identifier
623 EXT2_IDENTIFIER Identifier;
624
625
626 // Locking resources
627 ERESOURCE MainResource;
628 ERESOURCE PagingIoResource;
629
630 } EXT2_FCBVCB, *PEXT2_FCBVCB;
631
632 //
633 // EXT2_VCB Volume Control Block
634 //
635 // Data that represents a mounted logical volume
636 // It is allocated as the device extension of the volume device object
637 //
638 typedef struct _EXT2_VCB {
639
640 /* Common header */
641 EXT2_FCBVCB;
642
643 // Resource for metadata (inode)
644 ERESOURCE MetaInode;
645
646 // Resource for metadata (block)
647 ERESOURCE MetaBlock;
648
649 // Resource for Mcb (Meta data control block)
650 ERESOURCE McbLock;
651
652 // List of FCBs for open files on this volume
653 ERESOURCE FcbLock;
654 LIST_ENTRY FcbList;
655 ULONG FcbCount;
656
657 // Mcb list
658 ULONG NumOfMcb;
659 LIST_ENTRY McbList;
660
661 // Entry of Mcb Tree (Root Node)
662 PEXT2_MCB McbTree;
663
664 // Link list to Global
665 LIST_ENTRY Next;
666
667 // Section objects
668 SECTION_OBJECT_POINTERS SectionObject;
669
670 // Dirty Mcbs of modifications for volume stream
671 LARGE_MCB Extents;
672
673
674 // Share Access for the file object
675 SHARE_ACCESS ShareAccess;
676
677 // Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLOSE
678 // for both files on this volume and open instances of the
679 // volume itself.
680 ULONG ReferenceCount; /* total ref count */
681 ULONG OpenHandleCount; /* all handles */
682
683 ULONG OpenVolumeCount; /* volume handle */
684
685 // Disk change count
686 ULONG ChangeCount;
687
688 // Pointer to the VPB in the target device object
689 PVPB Vpb;
690 PVPB Vpb2;
691
692 // The FileObject of Volume used to lock the volume
693 PFILE_OBJECT LockFile;
694
695 // List of IRPs pending on directory change notify requests
696 LIST_ENTRY NotifyList;
697
698 // Pointer to syncronization primitive for this list
699 PNOTIFY_SYNC NotifySync;
700
701 // This volumes device object
702 PDEVICE_OBJECT DeviceObject;
703
704 // The physical device object (the disk)
705 PDEVICE_OBJECT TargetDeviceObject;
706
707 // The physical device object (the disk)
708 PDEVICE_OBJECT RealDevice;
709
710 // Information about the physical device object
711 DISK_GEOMETRY DiskGeometry;
712 PARTITION_INFORMATION PartitionInformation;
713
714 BOOLEAN IsExt3fs;
715 PEXT2_SUPER_BLOCK SuperBlock;
716
717 // Block / Cluster size
718 ULONG BlockSize;
719
720 // Sector size in bits
721 ULONG SectorBits;
722
723 // Aligned size (Page or Block)
724 ULONGLONG IoUnitSize;
725
726 // Bits of aligned size
727 ULONG IoUnitBits;
728
729 // Inode size
730 ULONG InodeSize;
731
732 // Inode lookaside list
733 NPAGED_LOOKASIDE_LIST InodeLookasideList;
734
735 // Flags for the volume
736 ULONG Flags;
737
738 // Streaming File Object
739 PFILE_OBJECT Volume;
740
741 // User specified codepage name per volume
742 struct {
743 UCHAR AnsiName[CODEPAGE_MAXLEN];
744 struct nls_table * PageTable;
745 } Codepage;
746
747 /* patterns to hiding files */
748 BOOLEAN bHidingPrefix;
749 CHAR sHidingPrefix[HIDINGPAT_LEN];
750 BOOLEAN bHidingSuffix;
751 CHAR sHidingSuffix[HIDINGPAT_LEN];
752
753 /* User to impersanate */
754 uid_t uid;
755 gid_t gid;
756
757 /* User to act as */
758 uid_t euid;
759 gid_t egid;
760
761 /* mountpoint: symlink to DesDevices */
762 UCHAR DrvLetter;
763
764 struct block_device bd;
765 struct super_block sb;
766 struct ext3_sb_info sbi;
767
768 /* Maximum file size in blocks ... */
769 ULONG max_blocks_per_layer[EXT2_BLOCK_TYPES];
770 ULONG max_data_blocks;
771 loff_t max_bitmap_bytes;
772 loff_t max_bytes;
773 } EXT2_VCB, *PEXT2_VCB;
774
775 //
776 // Flags for EXT2_VCB
777 //
778 #define VCB_INITIALIZED 0x00000001
779 #define VCB_VOLUME_LOCKED 0x00000002
780 #define VCB_MOUNTED 0x00000004
781 #define VCB_DISMOUNT_PENDING 0x00000008
782 #define VCB_NEW_VPB 0x00000010
783 #define VCB_BEING_CLOSED 0x00000020
784 #define VCB_USER_IDS 0x00000040 /* uid/gid specified by user */
785 #define VCB_USER_EIDS 0x00000080 /* euid/egid specified by user */
786
787 #define VCB_BEING_DROPPED 0x00002000
788 #define VCB_FORCE_WRITING 0x00004000
789 #define VCB_DEVICE_REMOVED 0x00008000
790 #define VCB_JOURNAL_RECOVER 0x00080000
791 #define VCB_ARRIVAL_NOTIFIED 0x00800000
792 #define VCB_READ_ONLY 0x08000000
793 #define VCB_WRITE_PROTECTED 0x10000000
794 #define VCB_FLOPPY_DISK 0x20000000
795 #define VCB_REMOVAL_PREVENTED 0x40000000
796 #define VCB_REMOVABLE_MEDIA 0x80000000
797
798
799 #define IsVcbInited(Vcb) (IsFlagOn((Vcb)->Flags, VCB_INITIALIZED))
800 #define IsMounted(Vcb) (IsFlagOn((Vcb)->Flags, VCB_MOUNTED))
801 #define IsDispending(Vcb) (IsFlagOn((Vcb)->Flags, VCB_DISMOUNT_PENDING))
802 #define IsVcbReadOnly(Vcb) (IsFlagOn((Vcb)->Flags, VCB_READ_ONLY) || \
803 IsFlagOn((Vcb)->Flags, VCB_WRITE_PROTECTED))
804
805
806 #define IsExt3ForceWrite() (IsFlagOn(Ext2Global->Flags, EXT3_FORCE_WRITING))
807 #define IsVcbForceWrite(Vcb) (IsFlagOn((Vcb)->Flags, VCB_FORCE_WRITING))
808 #define CanIWrite(Vcb) (IsExt3ForceWrite() || (!IsVcbReadOnly(Vcb) && IsVcbForceWrite(Vcb)))
809 #define IsLazyWriter(Fcb) ((Fcb)->LazyWriterThread == PsGetCurrentThread())
810 //
811 // EXT2_FCB File Control Block
812 //
813 // Data that represents an open file
814 // There is a single instance of the FCB for every open file
815 //
816 typedef struct _EXT2_FCB {
817
818 /* Common header */
819 EXT2_FCBVCB;
820
821 // List of FCBs for this volume
822 LIST_ENTRY Next;
823 LARGE_INTEGER TsDrop; /* drop time */
824
825 SECTION_OBJECT_POINTERS SectionObject;
826
827 // Share Access for the file object
828 SHARE_ACCESS ShareAccess;
829
830 // List of byte-range locks for this file
831 FILE_LOCK FileLockAnchor;
832
833 // oplock information management structure
834 OPLOCK Oplock;
835
836 // Lazy writer thread context
837 PETHREAD LazyWriterThread;
838
839 // Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLEANUP
840 ULONG OpenHandleCount;
841
842 // Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLOSE
843 ULONG ReferenceCount;
844
845 // Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLEANUP
846 // But only for Files with FO_NO_INTERMEDIATE_BUFFERING flag
847 ULONG NonCachedOpenCount;
848
849 // Flags for the FCB
850 ULONG Flags;
851
852 // Pointer to the inode
853 struct inode *Inode;
854
855 // Vcb
856 PEXT2_VCB Vcb;
857
858 // Mcb Node ...
859 PEXT2_MCB Mcb;
860
861 } EXT2_FCB, *PEXT2_FCB;
862
863 //
864 // Flags for EXT2_FCB
865 //
866
867 #define FCB_FROM_POOL 0x00000001
868 #define FCB_PAGE_FILE 0x00000002
869 #define FCB_FILE_MODIFIED 0x00000020
870
871 #define FCB_ALLOC_IN_CREATE 0x00000080
872 #define FCB_ALLOC_IN_WRITE 0x00000100
873 #define FCB_ALLOC_IN_SETINFO 0x00000200
874
875 #define FCB_DELETE_PENDING 0x80000000
876
877 //
878 // Mcb Node
879 //
880
881 struct _EXT2_MCB {
882
883 // Identifier for this structure
884 EXT2_IDENTIFIER Identifier;
885
886 // Flags
887 ULONG Flags;
888
889 // Link List Info
890 PEXT2_MCB Parent; // Parent
891 PEXT2_MCB Next; // Siblings
892
893 union {
894 PEXT2_MCB Child; // Children Mcb nodes
895 PEXT2_MCB Target; // Target Mcb of symlink
896 };
897
898 // Mcb Node Info
899
900 // -> Fcb
901 PEXT2_FCB Fcb;
902
903 // Short name
904 UNICODE_STRING ShortName;
905
906 // Full name with path
907 UNICODE_STRING FullName;
908
909 // File attribute
910 ULONG FileAttr;
911
912 // reference count
913 ULONG Refercount;
914
915 // Extents zone
916 LARGE_MCB Extents;
917
918 // Metablocks
919 LARGE_MCB MetaExts;
920
921 // Time stamps
922 LARGE_INTEGER CreationTime;
923 LARGE_INTEGER LastWriteTime;
924 LARGE_INTEGER ChangeTime;
925 LARGE_INTEGER LastAccessTime;
926
927 // List Link to Vcb->McbList
928 LIST_ENTRY Link;
929
930 struct inode Inode;
931 struct dentry *de;
932 };
933
934 //
935 // Flags for MCB
936 //
937 #define MCB_FROM_POOL 0x00000001
938 #define MCB_VCB_LINK 0x00000002
939 #define MCB_ENTRY_TREE 0x00000004
940 #define MCB_FILE_DELETED 0x00000008
941
942 #define MCB_ZONE_INITED 0x20000000
943 #define MCB_TYPE_SPECIAL 0x40000000 /* unresolved symlink + device node */
944 #define MCB_TYPE_SYMLINK 0x80000000
945
946 #define IsMcbUsed(Mcb) ((Mcb)->Refercount > 0)
947 #define IsMcbSymLink(Mcb) IsFlagOn((Mcb)->Flags, MCB_TYPE_SYMLINK)
948 #define IsZoneInited(Mcb) IsFlagOn((Mcb)->Flags, MCB_ZONE_INITED)
949 #define IsMcbSpecialFile(Mcb) IsFlagOn((Mcb)->Flags, MCB_TYPE_SPECIAL)
950 #define IsMcbRoot(Mcb) ((Mcb)->Inode.i_ino == EXT2_ROOT_INO)
951 #define IsMcbReadonly(Mcb) IsFlagOn((Mcb)->FileAttr, FILE_ATTRIBUTE_READONLY)
952 #define IsMcbDirectory(Mcb) IsFlagOn((Mcb)->FileAttr, FILE_ATTRIBUTE_DIRECTORY)
953 #define IsFileDeleted(Mcb) IsFlagOn((Mcb)->Flags, MCB_FILE_DELETED)
954
955 #define IsLinkInvalid(Mcb) (IsMcbSymLink(Mcb) && IsFileDeleted(Mcb->Target))
956
957 /*
958 * routines for reference count management
959 */
960
961 #define Ext2ReferXcb(_C) InterlockedIncrement(_C)
962 #define Ext2DerefXcb(_C) DEC_OBJ_CNT(_C)
963
964 #ifdef __REACTOS__
965 static
966 #endif
967 __inline ULONG DEC_OBJ_CNT(PULONG _C) {
968 if (*_C <= 0) {
969 DbgBreak();
970 }
971 return InterlockedDecrement(_C);
972 }
973
974 #if EXT2_DEBUG
975 VOID
976 Ext2TraceMcb(PCHAR fn, USHORT lc, USHORT add, PEXT2_MCB Mcb);
977 #define Ext2ReferMcb(Mcb) Ext2TraceMcb(__FUNCTION__, __LINE__, TRUE, Mcb)
978 #define Ext2DerefMcb(Mcb) Ext2TraceMcb(__FUNCTION__, __LINE__, FALSE, Mcb)
979 #else
980 #define Ext2ReferMcb(Mcb) Ext2ReferXcb(&Mcb->Refercount)
981 #define Ext2DerefMcb(Mcb) Ext2DerefXcb(&Mcb->Refercount)
982 #endif
983
984 //
985 // EXT2_CCB Context Control Block
986 //
987 // Data that represents one instance of an open file
988 // There is one instance of the CCB for every instance of an open file
989 //
990 typedef struct _EXT2_CCB {
991
992 // Identifier for this structure
993 EXT2_IDENTIFIER Identifier;
994
995 // Flags
996 ULONG Flags;
997
998 // Mcb of it's symbol link
999 PEXT2_MCB SymLink;
1000
1001 // State that may need to be maintained
1002 UNICODE_STRING DirectorySearchPattern;
1003
1004 /* Open handle control block */
1005 struct file filp;
1006
1007 } EXT2_CCB, *PEXT2_CCB;
1008
1009 //
1010 // Flags for CCB
1011 //
1012
1013 #define CCB_FROM_POOL 0x00000001
1014 #define CCB_VOLUME_DASD_PURGE 0x00000002
1015 #define CCB_LAST_WRITE_UPDATED 0x00000004
1016 #define CCB_OPEN_REPARSE_POINT 0x00000008
1017 #define CCB_DELETE_ON_CLOSE 0x00000010
1018
1019 #define CCB_ALLOW_EXTENDED_DASD_IO 0x80000000
1020
1021 //
1022 // EXT2_IRP_CONTEXT
1023 //
1024 // Used to pass information about a request between the drivers functions
1025 //
1026 typedef struct ext2_icb {
1027
1028 // Identifier for this structure
1029 EXT2_IDENTIFIER Identifier;
1030
1031 // Pointer to the IRP this request describes
1032 PIRP Irp;
1033
1034 // Flags
1035 ULONG Flags;
1036
1037 // The major and minor function code for the request
1038 UCHAR MajorFunction;
1039 UCHAR MinorFunction;
1040
1041 // The device object
1042 PDEVICE_OBJECT DeviceObject;
1043
1044 // The real device object
1045 PDEVICE_OBJECT RealDevice;
1046
1047 // The file object
1048 PFILE_OBJECT FileObject;
1049
1050 PEXT2_FCB Fcb;
1051 PEXT2_CCB Ccb;
1052
1053 // If the request is top level
1054 BOOLEAN IsTopLevel;
1055
1056 // Used if the request needs to be queued for later processing
1057 WORK_QUEUE_ITEM WorkQueueItem;
1058
1059 // If an exception is currently in progress
1060 BOOLEAN ExceptionInProgress;
1061
1062 // The exception code when an exception is in progress
1063 NTSTATUS ExceptionCode;
1064
1065 } EXT2_IRP_CONTEXT, *PEXT2_IRP_CONTEXT;
1066
1067
1068 #define IRP_CONTEXT_FLAG_FROM_POOL (0x00000001)
1069 #define IRP_CONTEXT_FLAG_WAIT (0x00000002)
1070 #define IRP_CONTEXT_FLAG_WRITE_THROUGH (0x00000004)
1071 #define IRP_CONTEXT_FLAG_FLOPPY (0x00000008)
1072 #define IRP_CONTEXT_FLAG_DISABLE_POPUPS (0x00000020)
1073 #define IRP_CONTEXT_FLAG_DEFERRED (0x00000040)
1074 #define IRP_CONTEXT_FLAG_VERIFY_READ (0x00000080)
1075 #define IRP_CONTEXT_STACK_IO_CONTEXT (0x00000100)
1076 #define IRP_CONTEXT_FLAG_REQUEUED (0x00000200)
1077 #define IRP_CONTEXT_FLAG_USER_IO (0x00000400)
1078 #define IRP_CONTEXT_FLAG_DELAY_CLOSE (0x00000800)
1079 #define IRP_CONTEXT_FLAG_FILE_BUSY (0x00001000)
1080
1081
1082 #define Ext2CanIWait() (!IrpContext || IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT))
1083
1084 //
1085 // EXT2_ALLOC_HEADER
1086 //
1087 // In the checked version of the driver this header is put in the beginning of
1088 // every memory allocation
1089 //
1090 typedef struct _EXT2_ALLOC_HEADER {
1091 EXT2_IDENTIFIER Identifier;
1092 } EXT2_ALLOC_HEADER, *PEXT2_ALLOC_HEADER;
1093
1094 typedef struct _FCB_LIST_ENTRY {
1095 PEXT2_FCB Fcb;
1096 LIST_ENTRY Next;
1097 } FCB_LIST_ENTRY, *PFCB_LIST_ENTRY;
1098
1099
1100 // Block Description List
1101 typedef struct _EXT2_EXTENT {
1102 LONGLONG Lba;
1103 ULONG Offset;
1104 ULONG Length;
1105 PIRP Irp;
1106 struct _EXT2_EXTENT * Next;
1107 } EXT2_EXTENT, *PEXT2_EXTENT;
1108
1109
1110 /* FUNCTIONS DECLARATION *****************************************************/
1111
1112 // Include this so we don't need the latest WDK to build the driver.
1113 #ifndef FSCTL_GET_RETRIEVAL_POINTER_BASE
1114 #define FSCTL_GET_RETRIEVAL_POINTER_BASE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 141, METHOD_BUFFERED, FILE_ANY_ACCESS) // RETRIEVAL_POINTER_BASE
1115 #endif
1116
1117 //
1118 // The following macro is used to determine if an FSD thread can block
1119 // for I/O or wait for a resource. It returns TRUE if the thread can
1120 // block and FALSE otherwise. This attribute can then be used to call
1121 // the FSD & FSP common work routine with the proper wait value.
1122 //
1123
1124 #define CanExt2Wait(IRP) IoIsOperationSynchronous(Irp)
1125
1126 //
1127 // memory allocation statistics
1128 //
1129
1130 #ifdef __REACTOS__
1131 static
1132 #endif
1133 __inline
1134 VOID
1135 Ext2TraceMemory(BOOLEAN _n, int _i, PVOID _p, LONG _s)
1136 {
1137 if (_n) {
1138 InterlockedIncrement(&Ext2Global->PerfStat.Current.Slot[_i]);
1139 InterlockedIncrement(&Ext2Global->PerfStat.Total.Slot[_i]);
1140 InterlockedExchangeAdd(&Ext2Global->PerfStat.Size.Slot[_i], _s);
1141 } else {
1142 InterlockedDecrement(&Ext2Global->PerfStat.Current.Slot[_i]);
1143 InterlockedExchangeAdd(&Ext2Global->PerfStat.Size.Slot[_i], -1 * _s);
1144 }
1145 }
1146
1147 #ifdef __REACTOS__
1148 static
1149 #endif
1150 __inline
1151 VOID
1152 Ext2TraceIrpContext(BOOLEAN _n, PEXT2_IRP_CONTEXT IrpContext)
1153 {
1154 if (_n) {
1155 INC_MEM_COUNT(PS_IRP_CONTEXT, IrpContext, sizeof(EXT2_IRP_CONTEXT));
1156 InterlockedIncrement(&(Ext2Global->PerfStat.Irps[IrpContext->MajorFunction].Current));
1157 } else {
1158 DEC_MEM_COUNT(PS_IRP_CONTEXT, IrpContext, sizeof(EXT2_IRP_CONTEXT));
1159 InterlockedIncrement(&Ext2Global->PerfStat.Irps[IrpContext->MajorFunction].Processed);
1160 InterlockedDecrement(&Ext2Global->PerfStat.Irps[IrpContext->MajorFunction].Current);
1161 }
1162 }
1163
1164 typedef struct _EXT2_FILLDIR_CONTEXT {
1165 PEXT2_IRP_CONTEXT efc_irp;
1166 PUCHAR efc_buf;
1167 ULONG efc_size;
1168 ULONG efc_start;
1169 ULONG efc_prev;
1170 NTSTATUS efc_status;
1171 FILE_INFORMATION_CLASS efc_fi;
1172 BOOLEAN efc_single;
1173 } EXT2_FILLDIR_CONTEXT, *PEXT2_FILLDIR_CONTEXT;
1174
1175 //
1176 // Access.c
1177 //
1178
1179
1180 int Ext2CheckInodeAccess(PEXT2_VCB Vcb, struct inode *in, int attempt);
1181 int Ext2CheckFileAccess (PEXT2_VCB Vcb, PEXT2_MCB Mcb, int attempt);
1182
1183 //
1184 // Block.c
1185 //
1186
1187 PMDL
1188 Ext2CreateMdl (
1189 IN PVOID Buffer,
1190 IN ULONG Length,
1191 IN LOCK_OPERATION Operation
1192 );
1193
1194 VOID
1195 Ext2DestroyMdl (IN PMDL Mdl);
1196
1197 NTSTATUS
1198 Ext2LockUserBuffer (
1199 IN PIRP Irp,
1200 IN ULONG Length,
1201 IN LOCK_OPERATION Operation);
1202 PVOID
1203 Ext2GetUserBuffer (IN PIRP Irp);
1204
1205
1206 NTSTATUS
1207 Ext2ReadWriteBlocks(
1208 IN PEXT2_IRP_CONTEXT IrpContext,
1209 IN PEXT2_VCB Vcb,
1210 IN PEXT2_EXTENT Extent,
1211 IN ULONG Length
1212 );
1213
1214 NTSTATUS
1215 Ext2ReadSync(
1216 IN PEXT2_VCB Vcb,
1217 IN ULONGLONG Offset,
1218 IN ULONG Length,
1219 OUT PVOID Buffer,
1220 IN BOOLEAN bVerify );
1221
1222 NTSTATUS
1223 Ext2ReadDisk(
1224 IN PEXT2_VCB Vcb,
1225 IN ULONGLONG Offset,
1226 IN ULONG Size,
1227 IN PVOID Buffer,
1228 IN BOOLEAN bVerify );
1229
1230 NTSTATUS
1231 Ext2DiskIoControl (
1232 IN PDEVICE_OBJECT DeviceOjbect,
1233 IN ULONG IoctlCode,
1234 IN PVOID InputBuffer,
1235 IN ULONG InputBufferSize,
1236 IN OUT PVOID OutputBuffer,
1237 IN OUT PULONG OutputBufferSize );
1238
1239 VOID
1240 Ext2MediaEjectControl (
1241 IN PEXT2_IRP_CONTEXT IrpContext,
1242 IN PEXT2_VCB Vcb,
1243 IN BOOLEAN bPrevent );
1244
1245 NTSTATUS
1246 Ext2DiskShutDown(PEXT2_VCB Vcb);
1247
1248
1249 //
1250 // Cleanup.c
1251 //
1252
1253 NTSTATUS
1254 Ext2Cleanup (IN PEXT2_IRP_CONTEXT IrpContext);
1255
1256 //
1257 // Close.c
1258 //
1259
1260 NTSTATUS
1261 Ext2Close (IN PEXT2_IRP_CONTEXT IrpContext);
1262
1263 VOID
1264 Ext2QueueCloseRequest (IN PEXT2_IRP_CONTEXT IrpContext);
1265
1266 VOID NTAPI
1267 Ext2DeQueueCloseRequest (IN PVOID Context);
1268
1269 //
1270 // Cmcb.c
1271 //
1272
1273 BOOLEAN NTAPI
1274 Ext2AcquireForLazyWrite (
1275 IN PVOID Context,
1276 IN BOOLEAN Wait );
1277 VOID NTAPI
1278 Ext2ReleaseFromLazyWrite (IN PVOID Context);
1279
1280 BOOLEAN NTAPI
1281 Ext2AcquireForReadAhead (
1282 IN PVOID Context,
1283 IN BOOLEAN Wait );
1284
1285 VOID NTAPI
1286 Ext2ReleaseFromReadAhead (IN PVOID Context);
1287
1288 BOOLEAN NTAPI
1289 Ext2NoOpAcquire (
1290 IN PVOID Fcb,
1291 IN BOOLEAN Wait );
1292
1293 VOID NTAPI
1294 Ext2NoOpRelease (IN PVOID Fcb);
1295
1296 //
1297 // Create.c
1298 //
1299
1300
1301 BOOLEAN
1302 Ext2IsNameValid(PUNICODE_STRING FileName);
1303
1304 NTSTATUS
1305 Ext2FollowLink (
1306 IN PEXT2_IRP_CONTEXT IrpContext,
1307 IN PEXT2_VCB Vcb,
1308 IN PEXT2_MCB Parent,
1309 IN PEXT2_MCB Mcb,
1310 IN ULONG Linkdep
1311 );
1312
1313 NTSTATUS
1314 Ext2ScanDir (
1315 IN PEXT2_IRP_CONTEXT IrpContext,
1316 IN PEXT2_VCB Vcb,
1317 IN PEXT2_MCB Parent,
1318 IN PUNICODE_STRING FileName,
1319 OUT PULONG Inode,
1320 struct dentry **dentry
1321 );
1322
1323 BOOLEAN
1324 Ext2IsSpecialSystemFile(
1325 IN PUNICODE_STRING FileName,
1326 IN BOOLEAN bDirectory
1327 );
1328
1329 #define EXT2_LOOKUP_FLAG_MASK (0xFF00000)
1330 #define EXT2_LOOKUP_NOT_FOLLOW (0x8000000)
1331
1332 NTSTATUS
1333 Ext2LookupFile (
1334 IN PEXT2_IRP_CONTEXT IrpContext,
1335 IN PEXT2_VCB Vcb,
1336 IN PUNICODE_STRING FullName,
1337 IN PEXT2_MCB Parent,
1338 OUT PEXT2_MCB * Ext2Mcb,
1339 IN ULONG Linkdep
1340 );
1341
1342 NTSTATUS
1343 Ext2CreateFile(
1344 IN PEXT2_IRP_CONTEXT IrpContext,
1345 IN PEXT2_VCB Vcb,
1346 OUT PBOOLEAN OpPostIrp
1347 );
1348
1349 NTSTATUS
1350 Ext2CreateVolume(
1351 IN PEXT2_IRP_CONTEXT IrpContext,
1352 IN PEXT2_VCB Vcb );
1353
1354 NTSTATUS
1355 Ext2Create (IN PEXT2_IRP_CONTEXT IrpContext);
1356
1357 NTSTATUS
1358 Ext2CreateInode(
1359 IN PEXT2_IRP_CONTEXT IrpContext,
1360 IN PEXT2_VCB Vcb,
1361 IN PEXT2_FCB pParentFcb,
1362 IN ULONG Type,
1363 IN ULONG FileAttr,
1364 IN PUNICODE_STRING FileName);
1365
1366
1367 NTSTATUS
1368 Ext2SupersedeOrOverWriteFile(
1369 IN PEXT2_IRP_CONTEXT IrpContext,
1370 IN PFILE_OBJECT FileObject,
1371 IN PEXT2_VCB Vcb,
1372 IN PEXT2_FCB Fcb,
1373 IN PLARGE_INTEGER AllocationSize,
1374 IN ULONG Disposition
1375 );
1376
1377 //
1378 // Debug.c
1379 //
1380
1381 /* debug levels */
1382 #define DL_NVR 0
1383 #define DL_VIT 0x00000001
1384 #define DL_ERR 0x00000002
1385 #define DL_DBG 0x00000004
1386 #define DL_INF 0x00000008
1387 #define DL_FUN 0x00000010
1388 #define DL_LOW 0x00000020
1389 #define DL_REN 0x00000040 /* renaming operation */
1390 #define DL_RES 0x00000080 /* entry reference managment */
1391 #define DL_BLK 0x00000100 /* data block allocation / free */
1392 #define DL_CP 0x00000200 /* code pages (create, querydir) */
1393 #define DL_EXT 0x00000400 /* mcb extents */
1394 #define DL_MAP 0x00000800 /* retrieval points */
1395 #define DL_JNL 0x00001000 /* dump journal operations */
1396 #define DL_HTI 0x00002000 /* htree index */
1397 #define DL_WRN 0x00004000 /* warning */
1398 #define DL_BH 0x00008000 /* buffer head */
1399 #define DL_PNP 0x00010000 /* pnp */
1400 #define DL_IO 0x00020000 /* file i/o */
1401
1402 #define DL_ALL (DL_ERR|DL_VIT|DL_DBG|DL_INF|DL_FUN|DL_LOW|DL_REN|DL_RES|DL_BLK|DL_CP|DL_EXT|DL_MAP|DL_JNL|DL_HTI|DL_WRN|DL_BH|DL_PNP|DL_IO)
1403
1404 #if EXT2_DEBUG && defined(__REACTOS__)
1405 #define DL_DEFAULT (DL_ERR|DL_VIT|DL_DBG|DL_INF|DL_FUN|DL_LOW|DL_WRN)
1406 #else
1407 #define DL_DEFAULT (DL_ERR|DL_VIT)
1408 #endif
1409
1410 #if EXT2_DEBUG
1411 extern ULONG DebugFilter;
1412
1413 VOID
1414 __cdecl
1415 Ext2NiPrintf(
1416 PCHAR DebugMessage,
1417 ...
1418 );
1419
1420 #define DEBUG(_DL, arg) do {if ((_DL) & DebugFilter) Ext2Printf arg;} while(0)
1421 #define DEBUGNI(_DL, arg) do {if ((_DL) & DebugFilter) Ext2NiPrintf arg;} while(0)
1422
1423 #define Ext2CompleteRequest(Irp, bPrint, PriorityBoost) \
1424 Ext2DbgPrintComplete(Irp, bPrint); \
1425 IoCompleteRequest(Irp, PriorityBoost)
1426
1427 #else
1428
1429 #define DEBUG(_DL, arg) do {if ((_DL) & DL_ERR) DbgPrint arg;} while(0)
1430
1431 #define Ext2CompleteRequest(Irp, bPrint, PriorityBoost) \
1432 IoCompleteRequest(Irp, PriorityBoost)
1433
1434 #endif // EXT2_DEBUG
1435
1436 VOID
1437 __cdecl
1438 Ext2Printf(
1439 PCHAR DebugMessage,
1440 ...
1441 );
1442
1443 extern ULONG ProcessNameOffset;
1444
1445 #define Ext2GetCurrentProcessName() ( \
1446 (PUCHAR) PsGetCurrentProcess() + ProcessNameOffset \
1447 )
1448
1449 ULONG
1450 Ext2GetProcessNameOffset (VOID);
1451
1452 VOID
1453 Ext2DbgPrintCall (
1454 IN PDEVICE_OBJECT DeviceObject,
1455 IN PIRP Irp );
1456
1457 VOID
1458 Ext2DbgPrintComplete (
1459 IN PIRP Irp,
1460 IN BOOLEAN bPrint
1461 );
1462
1463 PUCHAR
1464 Ext2NtStatusToString (IN NTSTATUS Status );
1465
1466 PVOID Ext2AllocatePool(
1467 IN POOL_TYPE PoolType,
1468 IN SIZE_T NumberOfBytes,
1469 IN ULONG Tag
1470 );
1471
1472 VOID
1473 Ext2FreePool(
1474 IN PVOID P,
1475 IN ULONG Tag
1476 );
1477
1478 //
1479 // Devctl.c
1480 //
1481
1482 NTSTATUS
1483 Ext2ProcessGlobalProperty(
1484 IN PDEVICE_OBJECT DeviceObject,
1485 IN PEXT2_VOLUME_PROPERTY3 Property,
1486 IN ULONG Length
1487 );
1488
1489 NTSTATUS
1490 Ext2ProcessVolumeProperty(
1491 IN PEXT2_VCB Vcb,
1492 IN PEXT2_VOLUME_PROPERTY3 Property,
1493 IN ULONG Length
1494 );
1495
1496 NTSTATUS
1497 Ext2ProcessUserProperty(
1498 IN PEXT2_IRP_CONTEXT IrpContext,
1499 IN PEXT2_VOLUME_PROPERTY3 Property,
1500 IN ULONG Length
1501 );
1502
1503 NTSTATUS
1504 Ex2ProcessUserPerfStat(
1505 IN PEXT2_IRP_CONTEXT IrpContext,
1506 IN PEXT2_QUERY_PERFSTAT QueryPerf,
1507 IN ULONG Length
1508 );
1509
1510 NTSTATUS
1511 Ex2ProcessMountPoint(
1512 IN PEXT2_IRP_CONTEXT IrpContext,
1513 IN PEXT2_MOUNT_POINT MountPoint,
1514 IN ULONG Length
1515 );
1516
1517 NTSTATUS
1518 Ext2DeviceControlNormal (IN PEXT2_IRP_CONTEXT IrpContext);
1519
1520 NTSTATUS
1521 Ext2PrepareToUnload (IN PEXT2_IRP_CONTEXT IrpContext);
1522
1523 NTSTATUS
1524 Ext2DeviceControl (IN PEXT2_IRP_CONTEXT IrpContext);
1525
1526 //
1527 // Dirctl.c
1528 //
1529
1530 ULONG
1531 Ext2GetInfoLength(IN FILE_INFORMATION_CLASS FileInformationClass);
1532
1533 NTSTATUS
1534 Ext2ProcessEntry(
1535 IN PEXT2_IRP_CONTEXT IrpContext,
1536 IN PEXT2_VCB Vcb,
1537 IN PEXT2_FCB Dcb,
1538 IN FILE_INFORMATION_CLASS FileInformationClass,
1539 IN ULONG in,
1540 IN PVOID Buffer,
1541 IN ULONG UsedLength,
1542 IN ULONG Length,
1543 IN ULONG FileIndex,
1544 IN PUNICODE_STRING pName,
1545 OUT PULONG EntrySize,
1546 IN BOOLEAN Single
1547 );
1548
1549 BOOLEAN
1550 Ext2IsWearingCloak(
1551 IN PEXT2_VCB Vcb,
1552 IN POEM_STRING OeName
1553 );
1554
1555 NTSTATUS Ext2QueryDirectory (IN PEXT2_IRP_CONTEXT IrpContext);
1556
1557 NTSTATUS
1558 Ext2NotifyChangeDirectory (
1559 IN PEXT2_IRP_CONTEXT IrpContext
1560 );
1561
1562 VOID
1563 Ext2NotifyReportChange (
1564 IN PEXT2_IRP_CONTEXT IrpContext,
1565 IN PEXT2_VCB Vcb,
1566 IN PEXT2_MCB Mcb,
1567 IN ULONG Filter,
1568 IN ULONG Action
1569 );
1570
1571 NTSTATUS
1572 Ext2DirectoryControl (IN PEXT2_IRP_CONTEXT IrpContext);
1573
1574 BOOLEAN
1575 Ext2IsDirectoryEmpty (
1576 IN PEXT2_IRP_CONTEXT IrpContext,
1577 IN PEXT2_VCB Vcb,
1578 IN PEXT2_MCB Mcb
1579 );
1580
1581 //
1582 // Dispatch.c
1583 //
1584
1585 VOID NTAPI
1586 Ext2OplockComplete (
1587 IN PVOID Context,
1588 IN PIRP Irp
1589 );
1590
1591 VOID NTAPI
1592 Ext2LockIrp (
1593 IN PVOID Context,
1594 IN PIRP Irp
1595 );
1596
1597 NTSTATUS
1598 Ext2QueueRequest (IN PEXT2_IRP_CONTEXT IrpContext);
1599
1600 VOID NTAPI
1601 Ext2DeQueueRequest (IN PVOID Context);
1602
1603 NTSTATUS
1604 Ext2DispatchRequest (IN PEXT2_IRP_CONTEXT IrpContext);
1605
1606 NTSTATUS NTAPI
1607 Ext2BuildRequest (
1608 IN PDEVICE_OBJECT DeviceObject,
1609 IN PIRP Irp
1610 );
1611
1612 //
1613 // Except.c
1614 //
1615
1616 NTSTATUS
1617 Ext2ExceptionFilter (
1618 IN PEXT2_IRP_CONTEXT IrpContext,
1619 IN PEXCEPTION_POINTERS ExceptionPointer
1620 );
1621
1622 NTSTATUS
1623 Ext2ExceptionHandler (IN PEXT2_IRP_CONTEXT IrpContext);
1624
1625
1626 //
1627 // Extents.c
1628 //
1629
1630
1631 NTSTATUS
1632 Ext2MapExtent(
1633 IN PEXT2_IRP_CONTEXT IrpContext,
1634 IN PEXT2_VCB Vcb,
1635 IN PEXT2_MCB Mcb,
1636 IN ULONG Index,
1637 IN BOOLEAN Alloc,
1638 OUT PULONG Block,
1639 OUT PULONG Number
1640 );
1641
1642 NTSTATUS
1643 Ext2ExpandExtent(
1644 PEXT2_IRP_CONTEXT IrpContext,
1645 PEXT2_VCB Vcb,
1646 PEXT2_MCB Mcb,
1647 ULONG Start,
1648 ULONG End,
1649 PLARGE_INTEGER Size
1650 );
1651
1652 NTSTATUS
1653 Ext2TruncateExtent(
1654 PEXT2_IRP_CONTEXT IrpContext,
1655 PEXT2_VCB Vcb,
1656 PEXT2_MCB Mcb,
1657 PLARGE_INTEGER Size
1658 );
1659
1660
1661 //
1662 // generic.c
1663 //
1664
1665 static inline ext3_fsblk_t ext3_blocks_count(struct ext3_super_block *es)
1666 {
1667 return ((ext3_fsblk_t)le32_to_cpu(es->s_blocks_count_hi) << 32) |
1668 le32_to_cpu(es->s_blocks_count);
1669 }
1670
1671 static inline ext3_fsblk_t ext3_r_blocks_count(struct ext3_super_block *es)
1672 {
1673 return ((ext3_fsblk_t)le32_to_cpu(es->s_r_blocks_count_hi) << 32) |
1674 le32_to_cpu(es->s_r_blocks_count);
1675 }
1676
1677 static inline ext3_fsblk_t ext3_free_blocks_count(struct ext3_super_block *es)
1678 {
1679 return ((ext3_fsblk_t)le32_to_cpu(es->s_free_blocks_count_hi) << 32) |
1680 le32_to_cpu(es->s_free_blocks_count);
1681 }
1682
1683 static inline void ext3_blocks_count_set(struct ext3_super_block *es,
1684 ext3_fsblk_t blk)
1685 {
1686 es->s_blocks_count = cpu_to_le32((u32)blk);
1687 es->s_blocks_count_hi = cpu_to_le32(blk >> 32);
1688 }
1689
1690 static inline void ext3_free_blocks_count_set(struct ext3_super_block *es,
1691 ext3_fsblk_t blk)
1692 {
1693 es->s_free_blocks_count = cpu_to_le32((u32)blk);
1694 es->s_free_blocks_count_hi = cpu_to_le32(blk >> 32);
1695 }
1696
1697 static inline void ext3_r_blocks_count_set(struct ext3_super_block *es,
1698 ext3_fsblk_t blk)
1699 {
1700 es->s_r_blocks_count = cpu_to_le32((u32)blk);
1701 es->s_r_blocks_count_hi = cpu_to_le32(blk >> 32);
1702 }
1703
1704 blkcnt_t ext3_inode_blocks(struct ext3_inode *raw_inode,
1705 struct inode *inode);
1706
1707 int ext3_inode_blocks_set(struct ext3_inode *raw_inode,
1708 struct inode * inode);
1709 ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
1710 struct ext4_group_desc *bg);
1711
1712 ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb,
1713 struct ext4_group_desc *bg);
1714 ext4_fsblk_t ext4_inode_table(struct super_block *sb,
1715 struct ext4_group_desc *bg);
1716 __u32 ext4_free_blks_count(struct super_block *sb,
1717 struct ext4_group_desc *bg);
1718 __u32 ext4_free_inodes_count(struct super_block *sb,
1719 struct ext4_group_desc *bg);
1720 __u32 ext4_used_dirs_count(struct super_block *sb,
1721 struct ext4_group_desc *bg);
1722 __u32 ext4_itable_unused_count(struct super_block *sb,
1723 struct ext4_group_desc *bg);
1724 void ext4_block_bitmap_set(struct super_block *sb,
1725 struct ext4_group_desc *bg, ext4_fsblk_t blk);
1726 void ext4_inode_bitmap_set(struct super_block *sb,
1727 struct ext4_group_desc *bg, ext4_fsblk_t blk);
1728 void ext4_inode_table_set(struct super_block *sb,
1729 struct ext4_group_desc *bg, ext4_fsblk_t blk);
1730 void ext4_free_blks_set(struct super_block *sb,
1731 struct ext4_group_desc *bg, __u32 count);
1732 void ext4_free_inodes_set(struct super_block *sb,
1733 struct ext4_group_desc *bg, __u32 count);
1734 void ext4_used_dirs_set(struct super_block *sb,
1735 struct ext4_group_desc *bg, __u32 count);
1736 void ext4_itable_unused_set(struct super_block *sb,
1737 struct ext4_group_desc *bg, __u32 count);
1738
1739 int ext3_bg_has_super(struct super_block *sb, ext3_group_t group);
1740 unsigned long ext4_bg_num_gdb(struct super_block *sb, ext4_group_t group);
1741 unsigned ext4_init_inode_bitmap(struct super_block *sb, struct buffer_head *bh,
1742 ext4_group_t block_group,
1743 struct ext4_group_desc *gdp);
1744 unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
1745 ext4_group_t block_group, struct ext4_group_desc *gdp);
1746 struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb,
1747 ext4_group_t block_group, struct buffer_head **bh);
1748 ext4_fsblk_t ext4_count_free_blocks(struct super_block *sb);
1749 unsigned long ext4_count_free_inodes(struct super_block *sb);
1750 int ext4_check_descriptors(struct super_block *sb);
1751
1752 NTSTATUS
1753 Ext2LoadSuper(
1754 IN PEXT2_VCB Vcb,
1755 IN BOOLEAN bVerify,
1756 OUT PEXT2_SUPER_BLOCK * Sb
1757 );
1758
1759
1760 BOOLEAN
1761 Ext2SaveSuper(
1762 IN PEXT2_IRP_CONTEXT IrpContext,
1763 IN PEXT2_VCB Vcb
1764 );
1765
1766 BOOLEAN
1767 Ext2RefreshSuper(
1768 IN PEXT2_IRP_CONTEXT IrpContext,
1769 IN PEXT2_VCB Vcb
1770 );
1771
1772 BOOLEAN
1773 Ext2LoadGroup(IN PEXT2_VCB Vcb);
1774
1775 VOID
1776 Ext2PutGroup(IN PEXT2_VCB Vcb);
1777
1778 VOID
1779 Ext2DropBH(IN PEXT2_VCB Vcb);
1780
1781 BOOLEAN
1782 Ext2SaveGroup(
1783 IN PEXT2_IRP_CONTEXT IrpContext,
1784 IN PEXT2_VCB Vcb,
1785 IN ULONG Group
1786 );
1787
1788 BOOLEAN
1789 Ext2RefreshGroup(
1790 IN PEXT2_IRP_CONTEXT IrpContext,
1791 IN PEXT2_VCB Vcb
1792 );
1793
1794 BOOLEAN
1795 Ext2GetInodeLba (
1796 IN PEXT2_VCB Vcb,
1797 IN ULONG inode,
1798 OUT PLONGLONG offset
1799 );
1800
1801 BOOLEAN
1802 Ext2LoadInode (
1803 IN PEXT2_VCB Vcb,
1804 IN struct inode *Inode
1805 );
1806
1807 BOOLEAN
1808 Ext2ClearInode (
1809 IN PEXT2_IRP_CONTEXT IrpContext,
1810 IN PEXT2_VCB Vcb,
1811 IN ULONG inode
1812 );
1813
1814 BOOLEAN
1815 Ext2SaveInode (
1816 IN PEXT2_IRP_CONTEXT IrpContext,
1817 IN PEXT2_VCB Vcb,
1818 IN struct inode *Inode
1819 );
1820
1821 BOOLEAN
1822 Ext2LoadBlock (
1823 IN PEXT2_VCB Vcb,
1824 IN ULONG dwBlk,
1825 IN PVOID Buffer
1826 );
1827
1828 BOOLEAN
1829 Ext2SaveBlock (
1830 IN PEXT2_IRP_CONTEXT IrpContext,
1831 IN PEXT2_VCB Vcb,
1832 IN ULONG dwBlk,
1833 IN PVOID Buf
1834 );
1835
1836 BOOLEAN
1837 Ext2ZeroBuffer(
1838 IN PEXT2_IRP_CONTEXT IrpContext,
1839 IN PEXT2_VCB Vcb,
1840 IN LONGLONG Offset,
1841 IN ULONG Size
1842 );
1843
1844 BOOLEAN
1845 Ext2SaveBuffer(
1846 IN PEXT2_IRP_CONTEXT IrpContext,
1847 IN PEXT2_VCB Vcb,
1848 IN LONGLONG Offset,
1849 IN ULONG Size,
1850 IN PVOID Buf
1851 );
1852
1853 NTSTATUS
1854 Ext2GetBlock(
1855 IN PEXT2_IRP_CONTEXT IrpContext,
1856 IN PEXT2_VCB Vcb,
1857 IN PEXT2_MCB Mcb,
1858 IN ULONG Base,
1859 IN ULONG Layer,
1860 IN ULONG Start,
1861 IN ULONG SizeArray,
1862 IN PULONG BlockArray,
1863 IN BOOLEAN bAlloc,
1864 IN OUT PULONG Hint,
1865 OUT PULONG Block,
1866 OUT PULONG Number
1867 );
1868
1869 NTSTATUS
1870 Ext2BlockMap(
1871 IN PEXT2_IRP_CONTEXT IrpContext,
1872 IN PEXT2_VCB Vcb,
1873 IN PEXT2_MCB Mcb,
1874 IN ULONG Index,
1875 IN BOOLEAN bAlloc,
1876 OUT PULONG pBlock,
1877 OUT PULONG Number
1878 );
1879
1880 VOID
1881 Ext2UpdateVcbStat(
1882 IN PEXT2_IRP_CONTEXT IrpContext,
1883 IN PEXT2_VCB Vcb
1884 );
1885
1886 NTSTATUS
1887 Ext2NewBlock(
1888 IN PEXT2_IRP_CONTEXT IrpContext,
1889 IN PEXT2_VCB Vcb,
1890 IN ULONG GroupHint,
1891 IN ULONG BlockHint,
1892 OUT PULONG Block,
1893 IN OUT PULONG Number
1894 );
1895
1896 NTSTATUS
1897 Ext2FreeBlock(
1898 IN PEXT2_IRP_CONTEXT IrpContext,
1899 IN PEXT2_VCB Vcb,
1900 IN ULONG Block,
1901 IN ULONG Number
1902 );
1903
1904
1905 NTSTATUS
1906 Ext2NewInode(
1907 IN PEXT2_IRP_CONTEXT IrpContext,
1908 IN PEXT2_VCB Vcb,
1909 IN ULONG GroupHint,
1910 IN ULONG Type,
1911 OUT PULONG Inode
1912 );
1913
1914 NTSTATUS
1915 Ext2UpdateGroupDirStat(
1916 IN PEXT2_IRP_CONTEXT IrpContext,
1917 IN PEXT2_VCB Vcb,
1918 IN ULONG Group
1919 );
1920
1921 NTSTATUS
1922 Ext2FreeInode(
1923 IN PEXT2_IRP_CONTEXT IrpContext,
1924 IN PEXT2_VCB Vcb,
1925 IN ULONG Inode,
1926 IN ULONG Type
1927 );
1928
1929 NTSTATUS
1930 Ext2AddEntry (
1931 IN PEXT2_IRP_CONTEXT IrpContext,
1932 IN PEXT2_VCB Vcb,
1933 IN PEXT2_FCB Dcb,
1934 IN struct inode *Inode,
1935 IN PUNICODE_STRING FileName,
1936 OUT struct dentry **dentry
1937 );
1938
1939 NTSTATUS
1940 Ext2SetFileType (
1941 IN PEXT2_IRP_CONTEXT IrpContext,
1942 IN PEXT2_VCB Vcb,
1943 IN PEXT2_FCB Dcb,
1944 IN PEXT2_MCB Mcb,
1945 IN umode_t mode
1946 );
1947
1948 NTSTATUS
1949 Ext2RemoveEntry (
1950 IN PEXT2_IRP_CONTEXT IrpContext,
1951 IN PEXT2_VCB Vcb,
1952 IN PEXT2_FCB Dcb,
1953 IN PEXT2_MCB Mcb
1954 );
1955
1956 NTSTATUS
1957 Ext2SetParentEntry (
1958 IN PEXT2_IRP_CONTEXT IrpContext,
1959 IN PEXT2_VCB Vcb,
1960 IN PEXT2_FCB Dcb,
1961 IN ULONG OldParent,
1962 IN ULONG NewParent );
1963
1964
1965 NTSTATUS
1966 Ext2TruncateBlock(
1967 IN PEXT2_IRP_CONTEXT IrpContext,
1968 IN PEXT2_VCB Vcb,
1969 IN PEXT2_MCB Mcb,
1970 IN ULONG Base,
1971 IN ULONG Start,
1972 IN ULONG Layer,
1973 IN ULONG SizeArray,
1974 IN PULONG BlockArray,
1975 IN PULONG Extra
1976 );
1977
1978 struct ext3_dir_entry_2 *ext3_next_entry(struct ext3_dir_entry_2 *p);
1979
1980 int ext3_check_dir_entry (const char * function, struct inode * dir,
1981 struct ext3_dir_entry_2 * de,
1982 struct buffer_head * bh,
1983 unsigned long offset);
1984
1985 loff_t ext3_max_size(int blkbits, int has_huge_files);
1986 loff_t ext3_max_bitmap_size(int bits, int has_huge_files);
1987
1988
1989 __le16 ext4_group_desc_csum(struct ext3_sb_info *sbi, __u32 block_group,
1990 struct ext4_group_desc *gdp);
1991 int ext4_group_desc_csum_verify(struct ext3_sb_info *sbi, __u32 block_group,
1992 struct ext4_group_desc *gdp);
1993
1994 ext3_fsblk_t descriptor_loc(struct super_block *sb,
1995 ext3_fsblk_t logical_sb_block, unsigned int nr);
1996 struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb,
1997 ext4_group_t block_group, struct buffer_head **bh);
1998 int ext4_check_descriptors(struct super_block *sb);
1999
2000 //
2001 // Fastio.c
2002 //
2003
2004 FAST_IO_POSSIBLE
2005 Ext2IsFastIoPossible(
2006 IN PEXT2_FCB Fcb
2007 );
2008
2009 BOOLEAN NTAPI
2010 Ext2FastIoCheckIfPossible (
2011 IN PFILE_OBJECT FileObject,
2012 IN PLARGE_INTEGER FileOffset,
2013 IN ULONG Length,
2014 IN BOOLEAN Wait,
2015 IN ULONG LockKey,
2016 IN BOOLEAN CheckForReadOperation,
2017 OUT PIO_STATUS_BLOCK IoStatus,
2018 IN PDEVICE_OBJECT DeviceObject
2019 );
2020
2021
2022 BOOLEAN NTAPI
2023 Ext2FastIoRead (IN PFILE_OBJECT FileObject,
2024 IN PLARGE_INTEGER FileOffset,
2025 IN ULONG Length,
2026 IN BOOLEAN Wait,
2027 IN ULONG LockKey,
2028 OUT PVOID Buffer,
2029 OUT PIO_STATUS_BLOCK IoStatus,
2030 IN PDEVICE_OBJECT DeviceObject);
2031
2032 BOOLEAN NTAPI
2033 Ext2FastIoWrite (
2034 IN PFILE_OBJECT FileObject,
2035 IN PLARGE_INTEGER FileOffset,
2036 IN ULONG Length,
2037 IN BOOLEAN Wait,
2038 IN ULONG LockKey,
2039 OUT PVOID Buffer,
2040 OUT PIO_STATUS_BLOCK IoStatus,
2041 IN PDEVICE_OBJECT DeviceObject);
2042
2043 BOOLEAN NTAPI
2044 Ext2FastIoQueryBasicInfo (
2045 IN PFILE_OBJECT FileObject,
2046 IN BOOLEAN Wait,
2047 OUT PFILE_BASIC_INFORMATION Buffer,
2048 OUT PIO_STATUS_BLOCK IoStatus,
2049 IN PDEVICE_OBJECT DeviceObject);
2050
2051 BOOLEAN NTAPI
2052 Ext2FastIoQueryStandardInfo (
2053 IN PFILE_OBJECT FileObject,
2054 IN BOOLEAN Wait,
2055 OUT PFILE_STANDARD_INFORMATION Buffer,
2056 OUT PIO_STATUS_BLOCK IoStatus,
2057 IN PDEVICE_OBJECT DeviceObject);
2058
2059 BOOLEAN NTAPI
2060 Ext2FastIoLock (
2061 IN PFILE_OBJECT FileObject,
2062 IN PLARGE_INTEGER FileOffset,
2063 IN PLARGE_INTEGER Length,
2064 IN PEPROCESS Process,
2065 IN ULONG Key,
2066 IN BOOLEAN FailImmediately,
2067 IN BOOLEAN ExclusiveLock,
2068 OUT PIO_STATUS_BLOCK IoStatus,
2069 IN PDEVICE_OBJECT DeviceObject
2070 );
2071
2072 BOOLEAN NTAPI
2073 Ext2FastIoUnlockSingle (
2074 IN PFILE_OBJECT FileObject,
2075 IN PLARGE_INTEGER FileOffset,
2076 IN PLARGE_INTEGER Length,
2077 IN PEPROCESS Process,
2078 IN ULONG Key,
2079 OUT PIO_STATUS_BLOCK IoStatus,
2080 IN PDEVICE_OBJECT DeviceObject
2081 );
2082
2083 BOOLEAN NTAPI
2084 Ext2FastIoUnlockAll (
2085 IN PFILE_OBJECT FileObject,
2086 IN PEPROCESS Process,
2087 OUT PIO_STATUS_BLOCK IoStatus,
2088 IN PDEVICE_OBJECT DeviceObject
2089 );
2090
2091 BOOLEAN NTAPI
2092 Ext2FastIoUnlockAllByKey (
2093 IN PFILE_OBJECT FileObject,
2094 #ifdef __REACTOS__
2095 IN PVOID Process,
2096 #else
2097 IN PEPROCESS Process,
2098 #endif
2099 IN ULONG Key,
2100 OUT PIO_STATUS_BLOCK IoStatus,
2101 IN PDEVICE_OBJECT DeviceObject
2102 );
2103
2104
2105 BOOLEAN NTAPI
2106 Ext2FastIoQueryNetworkOpenInfo (
2107 IN PFILE_OBJECT FileObject,
2108 IN BOOLEAN Wait,
2109 OUT PFILE_NETWORK_OPEN_INFORMATION Buffer,
2110 OUT PIO_STATUS_BLOCK IoStatus,
2111 IN PDEVICE_OBJECT DeviceObject );
2112
2113 BOOLEAN NTAPI
2114 Ext2FastIoQueryNetworkOpenInfo (
2115 IN PFILE_OBJECT FileObject,
2116 IN BOOLEAN Wait,
2117 OUT PFILE_NETWORK_OPEN_INFORMATION Buffer,
2118 OUT PIO_STATUS_BLOCK IoStatus,
2119 IN PDEVICE_OBJECT DeviceObject);
2120
2121 VOID
2122 NTAPI
2123 Ext2AcquireForCreateSection (
2124 IN PFILE_OBJECT FileObject
2125 );
2126
2127 VOID
2128 NTAPI
2129 Ext2ReleaseForCreateSection (
2130 IN PFILE_OBJECT FileObject
2131 );
2132
2133 NTSTATUS
2134 NTAPI
2135 Ext2AcquireFileForModWrite (
2136 IN PFILE_OBJECT FileObject,
2137 IN PLARGE_INTEGER EndingOffset,
2138 OUT PERESOURCE *ResourceToRelease,
2139 IN PDEVICE_OBJECT DeviceObject
2140 );
2141
2142 NTSTATUS
2143 NTAPI
2144 Ext2ReleaseFileForModWrite (
2145 IN PFILE_OBJECT FileObject,
2146 IN PERESOURCE ResourceToRelease,
2147 IN PDEVICE_OBJECT DeviceObject
2148 );
2149
2150 NTSTATUS
2151 NTAPI
2152 Ext2AcquireFileForCcFlush (
2153 IN PFILE_OBJECT FileObject,
2154 IN PDEVICE_OBJECT DeviceObject
2155 );
2156
2157 NTSTATUS
2158 NTAPI
2159 Ext2ReleaseFileForCcFlush (
2160 IN PFILE_OBJECT FileObject,
2161 IN PDEVICE_OBJECT DeviceObject
2162 );
2163
2164
2165 NTSTATUS
2166 NTAPI
2167 Ext2PreAcquireForCreateSection(
2168 IN PFS_FILTER_CALLBACK_DATA cd,
2169 OUT PVOID *cc
2170 );
2171
2172 //
2173 // FileInfo.c
2174 //
2175
2176
2177 NTSTATUS
2178 Ext2QueryFileInformation (IN PEXT2_IRP_CONTEXT IrpContext);
2179
2180 NTSTATUS
2181 Ext2SetFileInformation (IN PEXT2_IRP_CONTEXT IrpContext);
2182
2183 ULONG
2184 Ext2TotalBlocks(
2185 PEXT2_VCB Vcb,
2186 PLARGE_INTEGER Size,
2187 PULONG pMeta
2188 );
2189
2190 NTSTATUS
2191 Ext2ExpandFile(
2192 PEXT2_IRP_CONTEXT IrpContext,
2193 PEXT2_VCB Vcb,
2194 PEXT2_MCB Mcb,
2195 PLARGE_INTEGER Size
2196 );
2197
2198 NTSTATUS
2199 Ext2TruncateFile (
2200 PEXT2_IRP_CONTEXT IrpContext,
2201 PEXT2_VCB Vcb,
2202 PEXT2_MCB Mcb,
2203 PLARGE_INTEGER AllocationSize );
2204
2205 NTSTATUS
2206 Ext2IsFileRemovable(
2207 IN PEXT2_IRP_CONTEXT IrpContext,
2208 IN PEXT2_VCB Vcb,
2209 IN PEXT2_FCB Fcb,
2210 IN PEXT2_CCB Ccb
2211 );
2212
2213 NTSTATUS
2214 Ext2SetDispositionInfo(
2215 PEXT2_IRP_CONTEXT IrpContext,
2216 PEXT2_VCB Vcb,
2217 PEXT2_FCB Fcb,
2218 PEXT2_CCB Ccb,
2219 BOOLEAN bDelete
2220 );
2221
2222 NTSTATUS
2223 Ext2SetRenameInfo(
2224 PEXT2_IRP_CONTEXT IrpContext,
2225 PEXT2_VCB Vcb,
2226 PEXT2_FCB Fcb,
2227 PEXT2_CCB Ccb
2228 );
2229
2230 NTSTATUS
2231 Ext2SetLinkInfo(
2232 PEXT2_IRP_CONTEXT IrpContext,
2233 PEXT2_VCB Vcb,
2234 PEXT2_FCB Fcb,
2235 PEXT2_CCB Ccb
2236 );
2237
2238 ULONG
2239 Ext2InodeType(PEXT2_MCB Mcb);
2240
2241 NTSTATUS
2242 Ext2DeleteFile(
2243 PEXT2_IRP_CONTEXT IrpContext,
2244 PEXT2_VCB Vcb,
2245 PEXT2_FCB Fcb,
2246 PEXT2_MCB Mcb
2247 );
2248
2249
2250 //
2251 // Flush.c
2252 //
2253
2254 NTSTATUS
2255 Ext2FlushFiles(
2256 IN PEXT2_IRP_CONTEXT IrpContext,
2257 IN PEXT2_VCB Vcb,
2258 IN BOOLEAN bShutDown
2259 );
2260
2261 NTSTATUS
2262 Ext2FlushVolume (
2263 IN PEXT2_IRP_CONTEXT IrpContext,
2264 IN PEXT2_VCB Vcb,
2265 IN BOOLEAN bShutDown
2266 );
2267
2268 NTSTATUS
2269 Ext2FlushFile (
2270 IN PEXT2_IRP_CONTEXT IrpContext,
2271 IN PEXT2_FCB Fcb,
2272 IN PEXT2_CCB Ccb
2273 );
2274
2275 NTSTATUS
2276 Ext2Flush (IN PEXT2_IRP_CONTEXT IrpContext);
2277
2278
2279 //
2280 // Fsctl.c
2281 //
2282
2283 NTSTATUS
2284 Ext2ReadSymlink (
2285 IN PEXT2_IRP_CONTEXT IrpContext,
2286 IN PEXT2_VCB Vcb,
2287 IN PEXT2_MCB Mcb,
2288 IN PVOID Buffer,
2289 IN ULONG Size,
2290 OUT PULONG BytesRead
2291 );
2292
2293 NTSTATUS
2294 Ext2WriteSymlink (
2295 IN PEXT2_IRP_CONTEXT IrpContext,
2296 IN PEXT2_VCB Vcb,
2297 IN PEXT2_MCB Mcb,
2298 IN PVOID Buffer,
2299 IN ULONG Size,
2300 OUT PULONG BytesWritten
2301 );
2302
2303 NTSTATUS
2304 Ext2TruncateSymlink(
2305 PEXT2_IRP_CONTEXT IrpContext,
2306 PEXT2_VCB Vcb,
2307 PEXT2_MCB Mcb,
2308 ULONG Size
2309 );
2310
2311 //
2312 // MountPoint process workitem
2313 //
2314
2315 VOID
2316 Ext2SetVpbFlag (IN PVPB Vpb,
2317 IN USHORT Flag );
2318
2319 VOID
2320 Ext2ClearVpbFlag (IN PVPB Vpb,
2321 IN USHORT Flag );
2322
2323 BOOLEAN
2324 Ext2CheckDismount (
2325 IN PEXT2_IRP_CONTEXT IrpContext,
2326 IN PEXT2_VCB Vcb,
2327 IN BOOLEAN bForce );
2328
2329 NTSTATUS
2330 Ext2PurgeVolume (IN PEXT2_VCB Vcb,
2331 IN BOOLEAN FlushBeforePurge);
2332
2333 NTSTATUS
2334 Ext2PurgeFile (IN PEXT2_FCB Fcb,
2335 IN BOOLEAN FlushBeforePurge);
2336
2337 BOOLEAN
2338 Ext2IsHandleCountZero(IN PEXT2_VCB Vcb);
2339
2340 NTSTATUS
2341 Ext2LockVcb (IN PEXT2_VCB Vcb,
2342 IN PFILE_OBJECT FileObject);
2343
2344 NTSTATUS
2345 Ext2LockVolume (IN PEXT2_IRP_CONTEXT IrpContext);
2346
2347 NTSTATUS
2348 Ext2UnlockVcb (IN PEXT2_VCB Vcb,
2349 IN PFILE_OBJECT FileObject);
2350
2351 NTSTATUS
2352 Ext2UnlockVolume (IN PEXT2_IRP_CONTEXT IrpContext);
2353
2354 NTSTATUS
2355 Ext2AllowExtendedDasdIo(IN PEXT2_IRP_CONTEXT IrpContext);
2356
2357 NTSTATUS
2358 Ext2OplockRequest (IN PEXT2_IRP_CONTEXT IrpContext);
2359
2360 NTSTATUS
2361 Ext2QueryExtentMappings(
2362 IN PEXT2_IRP_CONTEXT IrpContext,
2363 IN PEXT2_VCB Vcb,
2364 IN PEXT2_FCB Fcb,
2365 IN PLARGE_INTEGER RequestVbn,
2366 OUT PLARGE_INTEGER * pMappedRuns
2367 );
2368
2369 NTSTATUS
2370 Ext2QueryRetrievalPointers(IN PEXT2_IRP_CONTEXT IrpContext);
2371
2372 NTSTATUS
2373 Ext2GetRetrievalPointers(IN PEXT2_IRP_CONTEXT IrpContext);
2374
2375 NTSTATUS
2376 Ext2GetRetrievalPointerBase(IN PEXT2_IRP_CONTEXT IrpContext);
2377
2378 NTSTATUS
2379 Ext2UserFsRequest (IN PEXT2_IRP_CONTEXT IrpContext);
2380
2381 BOOLEAN
2382 Ext2IsMediaWriteProtected (
2383 IN PEXT2_IRP_CONTEXT IrpContext,
2384 IN PDEVICE_OBJECT TargetDevice
2385 );
2386
2387 NTSTATUS
2388 Ext2MountVolume (IN PEXT2_IRP_CONTEXT IrpContext);
2389
2390 VOID
2391 Ext2VerifyVcb (IN PEXT2_IRP_CONTEXT IrpContext,
2392 IN PEXT2_VCB Vcb );
2393 NTSTATUS
2394 Ext2VerifyVolume (IN PEXT2_IRP_CONTEXT IrpContext);
2395
2396 NTSTATUS
2397 Ext2IsVolumeMounted (IN PEXT2_IRP_CONTEXT IrpContext);
2398
2399 NTSTATUS
2400 Ext2DismountVolume (IN PEXT2_IRP_CONTEXT IrpContext);
2401
2402 NTSTATUS
2403 Ext2FileSystemControl (IN PEXT2_IRP_CONTEXT IrpContext);
2404
2405 //
2406 // HTree.c
2407 //
2408
2409 struct buffer_head *ext3_append(struct ext2_icb *icb, struct inode *inode,
2410 ext3_lblk_t *block, int *err);
2411
2412 void ext3_set_de_type(struct super_block *sb,
2413 struct ext3_dir_entry_2 *de,
2414 umode_t mode);
2415
2416 __u32 ext3_current_time(struct inode *in);
2417 void ext3_warning (struct super_block * sb, const char * function,
2418 char * fmt, ...);
2419 #define ext3_error ext3_warning
2420 #define ext4_error ext3_error
2421
2422 void ext3_update_dx_flag(struct inode *inode);
2423 int ext3_mark_inode_dirty(struct ext2_icb *icb, struct inode *in);
2424
2425 void ext3_inc_count(struct inode *inode);
2426 void ext3_dec_count(struct inode *inode);
2427
2428 struct buffer_head *
2429 ext3_find_entry (struct ext2_icb *icb, struct dentry *dentry,
2430 struct ext3_dir_entry_2 ** res_dir);
2431 struct buffer_head *
2432 ext3_dx_find_entry(struct ext2_icb *, struct dentry *dentry,
2433 struct ext3_dir_entry_2 **res_dir, int *err);
2434
2435 typedef int (*filldir_t)(void *, const char *, int, unsigned long, __u32, unsigned);
2436 int ext3_dx_readdir(struct file *filp, filldir_t filldir, void * context);
2437
2438 struct buffer_head *ext3_bread(struct ext2_icb *icb, struct inode *inode,
2439 unsigned long block, int *err);
2440 int add_dirent_to_buf(struct ext2_icb *icb, struct dentry *dentry,
2441 struct inode *inode, struct ext3_dir_entry_2 *de,
2442 struct buffer_head *bh);
2443 #if !defined(__REACTOS__) || defined(_MSC_VER)
2444 struct ext3_dir_entry_2 *
2445 do_split(struct ext2_icb *icb, struct inode *dir,
2446 struct buffer_head **bh,struct dx_frame *frame,
2447 struct dx_hash_info *hinfo, int *error);
2448 #endif
2449
2450 int ext3_add_entry(struct ext2_icb *icb, struct dentry *dentry, struct inode *inode);
2451
2452 int ext3_delete_entry(struct ext2_icb *icb, struct inode *dir,
2453 struct ext3_dir_entry_2 *de_del,
2454 struct buffer_head *bh);
2455
2456 int ext3_is_dir_empty(struct ext2_icb *icb, struct inode *inode);
2457
2458 //
2459 // Init.c
2460 //
2461
2462 NTSTATUS
2463 Ext2QueryGlobalParameters(IN PUNICODE_STRING RegistryPath);
2464 BOOLEAN
2465 Ext2QueryRegistrySettings(IN PUNICODE_STRING RegistryPath);
2466
2467 VOID NTAPI
2468 DriverUnload (IN PDRIVER_OBJECT DriverObject);
2469
2470 //
2471 // Indirect.c
2472 //
2473
2474 NTSTATUS
2475 Ext2MapIndirect(
2476 IN PEXT2_IRP_CONTEXT IrpContext,
2477 IN PEXT2_VCB Vcb,
2478 IN PEXT2_MCB Mcb,
2479 IN ULONG Index,
2480 IN BOOLEAN bAlloc,
2481 OUT PULONG pBlock,
2482 OUT PULONG Number
2483 );
2484
2485 NTSTATUS
2486 Ext2ExpandIndirect(
2487 PEXT2_IRP_CONTEXT IrpContext,
2488 PEXT2_VCB Vcb,
2489 PEXT2_MCB Mcb,
2490 ULONG Start,
2491 ULONG End,
2492 PLARGE_INTEGER Size
2493 );
2494
2495 NTSTATUS
2496 Ext2TruncateIndirect(
2497 PEXT2_IRP_CONTEXT IrpContext,
2498 PEXT2_VCB Vcb,
2499 PEXT2_MCB Mcb,
2500 PLARGE_INTEGER Size
2501 );
2502
2503
2504 //
2505 // linux.c: linux lib implemenation
2506 //
2507
2508 int
2509 ext2_init_linux();
2510
2511 void
2512 ext2_destroy_linux();
2513
2514
2515 //
2516 // Lock.c
2517 //
2518
2519 NTSTATUS
2520 Ext2LockControl (IN PEXT2_IRP_CONTEXT IrpContext);
2521
2522
2523 //
2524 // Memory.c
2525 //
2526
2527 VOID
2528 NTAPI
2529 Ext2FcbReaperThread(
2530 PVOID Context
2531 );
2532
2533 VOID
2534 NTAPI
2535 Ext2McbReaperThread(
2536 PVOID Context
2537 );
2538
2539 VOID
2540 NTAPI
2541 Ext2bhReaperThread(
2542 PVOID Context
2543 );
2544
2545
2546 PEXT2_IRP_CONTEXT
2547 Ext2AllocateIrpContext (IN PDEVICE_OBJECT DeviceObject,
2548 IN PIRP Irp );
2549
2550 VOID
2551 Ext2FreeIrpContext (IN PEXT2_IRP_CONTEXT IrpContext);
2552
2553
2554 PEXT2_FCB
2555 Ext2AllocateFcb (
2556 IN PEXT2_VCB Vcb,
2557 IN PEXT2_MCB Mcb
2558 );
2559
2560 VOID
2561 Ext2UnlinkFcb(IN PEXT2_FCB Fcb);
2562
2563 VOID
2564 Ext2FreeFcb (IN PEXT2_FCB Fcb);
2565 VOID
2566 Ext2ReleaseFcb (IN PEXT2_FCB Fcb);
2567
2568 VOID
2569 Ext2InsertFcb(PEXT2_VCB Vcb, PEXT2_FCB Fcb);
2570
2571 PEXT2_CCB
2572 Ext2AllocateCcb (ULONG Flags, PEXT2_MCB SymLink);
2573
2574 VOID
2575 Ext2FreeMcb (
2576 IN PEXT2_VCB Vcb,
2577 IN PEXT2_MCB Mcb
2578 );
2579
2580 VOID
2581 Ext2FreeCcb (IN PEXT2_VCB Vcb, IN PEXT2_CCB Ccb);
2582
2583 PEXT2_INODE
2584 Ext2AllocateInode (PEXT2_VCB Vcb);
2585
2586 VOID
2587 Ext2DestroyInode (IN PEXT2_VCB Vcb, IN PEXT2_INODE inode);
2588
2589 struct dentry * Ext2AllocateEntry();
2590 VOID Ext2FreeEntry (IN struct dentry *de);
2591 struct dentry *Ext2BuildEntry(PEXT2_VCB Vcb, PEXT2_MCB Dcb, PUNICODE_STRING FileName);
2592
2593 PEXT2_EXTENT
2594 Ext2AllocateExtent();
2595
2596 VOID
2597 Ext2FreeExtent (IN PEXT2_EXTENT Extent);
2598
2599 ULONG
2600 Ext2CountExtents(IN PEXT2_EXTENT Chain);
2601
2602 VOID
2603 Ext2JointExtents(
2604 IN PEXT2_EXTENT Chain,
2605 IN PEXT2_EXTENT Extent
2606 );
2607
2608 VOID
2609 Ext2DestroyExtentChain(IN PEXT2_EXTENT Chain);
2610
2611 NTSTATUS
2612 Ext2BuildExtents(
2613 IN PEXT2_IRP_CONTEXT IrpContext,
2614 IN PEXT2_VCB Vcb,
2615 IN PEXT2_MCB Mcb,
2616 IN ULONGLONG Offset,
2617 IN ULONG Size,
2618 IN BOOLEAN bAlloc,
2619 OUT PEXT2_EXTENT * Chain
2620 );
2621
2622 BOOLEAN
2623 Ext2ListExtents(PLARGE_MCB Extents);
2624
2625 VOID
2626 Ext2CheckExtent(
2627 PLARGE_MCB Zone,
2628 LONGLONG Vbn,
2629 LONGLONG Lbn,
2630 LONGLONG Length,
2631 BOOLEAN bAdded
2632 );
2633
2634 VOID
2635 Ext2ClearAllExtents(PLARGE_MCB Zone);
2636
2637 BOOLEAN
2638 Ext2AddVcbExtent (
2639 IN PEXT2_VCB Vcb,
2640 IN LONGLONG Vbn,
2641 IN LONGLONG Length
2642 );
2643
2644 BOOLEAN
2645 Ext2RemoveVcbExtent (
2646 IN PEXT2_VCB Vcb,
2647 IN LONGLONG Vbn,
2648 IN LONGLONG Length
2649 );
2650
2651 BOOLEAN
2652 Ext2LookupVcbExtent (
2653 IN PEXT2_VCB Vcb,
2654 IN LONGLONG Vbn,
2655 OUT PLONGLONG Lbn,
2656 OUT PLONGLONG Length
2657 );
2658
2659 BOOLEAN
2660 Ext2AddMcbExtent (
2661 IN PEXT2_VCB Vcb,
2662 IN PEXT2_MCB Mcb,
2663 IN LONGLONG Vbn,
2664 IN LONGLONG Lbn,
2665 IN LONGLONG Length
2666 );
2667
2668 BOOLEAN
2669 Ext2RemoveMcbExtent (
2670 IN PEXT2_VCB Vcb,
2671 IN PEXT2_MCB Mcb,
2672 IN LONGLONG Vbn,
2673 IN LONGLONG Length
2674 );
2675
2676 BOOLEAN
2677 Ext2LookupMcbExtent (
2678 IN PEXT2_VCB Vcb,
2679 IN PEXT2_MCB Mcb,
2680 IN LONGLONG Vbn,
2681 OUT PLONGLONG Lbn,
2682 OUT PLONGLONG Length
2683 );
2684
2685 BOOLEAN
2686 Ext2AddMcbMetaExts (
2687 IN PEXT2_VCB Vcb,
2688 IN PEXT2_MCB Mcb,
2689 IN ULONG Block,
2690 IN ULONG Length
2691 );
2692
2693 BOOLEAN
2694 Ext2RemoveMcbMetaExts (
2695 IN PEXT2_VCB Vcb,
2696 IN PEXT2_MCB Mcb,
2697 IN ULONG Block,
2698 IN ULONG Length
2699 );
2700
2701 BOOLEAN
2702 Ext2AddBlockExtent(
2703 IN PEXT2_VCB Vcb,
2704 IN PEXT2_MCB Mcb,
2705 IN ULONG Start,
2706 IN ULONG Block,
2707 IN ULONG Number
2708 );
2709
2710 BOOLEAN
2711 Ext2LookupBlockExtent(
2712 IN PEXT2_VCB Vcb,
2713 IN PEXT2_MCB Mcb,
2714 IN ULONG Start,
2715 IN PULONG Block,
2716 IN PULONG Mapped
2717 );
2718
2719 BOOLEAN
2720 Ext2RemoveBlockExtent(
2721 IN PEXT2_VCB Vcb,
2722 IN PEXT2_MCB Mcb,
2723 IN ULONG Start,
2724 IN ULONG Number
2725 );
2726
2727 NTSTATUS
2728 Ext2InitializeZone(
2729 IN PEXT2_IRP_CONTEXT IrpContext,
2730 IN PEXT2_VCB Vcb,
2731 IN PEXT2_MCB Mcb
2732 );
2733
2734 BOOLEAN
2735 Ext2BuildName(
2736 IN OUT PUNICODE_STRING Target,
2737 IN PUNICODE_STRING File,
2738 IN PUNICODE_STRING Parent
2739 );
2740
2741
2742 PEXT2_MCB
2743 Ext2AllocateMcb (
2744 IN PEXT2_VCB Vcb,
2745 IN PUNICODE_STRING FileName,
2746 IN PUNICODE_STRING Parent,
2747 IN ULONG FileAttr
2748 );
2749
2750 PEXT2_MCB
2751 Ext2SearchMcb(
2752 PEXT2_VCB Vcb,
2753 PEXT2_MCB Parent,
2754 PUNICODE_STRING FileName
2755 );
2756
2757 PEXT2_MCB
2758 Ext2SearchMcbWithoutLock(
2759 PEXT2_MCB Parent,
2760 PUNICODE_STRING FileName
2761 );
2762
2763 VOID
2764 Ext2InsertMcb(
2765 PEXT2_VCB Vcb,
2766 PEXT2_MCB Parent,
2767 PEXT2_MCB Child
2768 );
2769
2770 BOOLEAN
2771 Ext2RemoveMcb(
2772 PEXT2_VCB Vcb,
2773 PEXT2_MCB Mcb
2774 );
2775
2776 VOID
2777 Ext2CleanupAllMcbs(
2778 PEXT2_VCB Vcb
2779 );
2780
2781 BOOLEAN
2782 Ext2CheckSetBlock(
2783 PEXT2_IRP_CONTEXT IrpContext,
2784 PEXT2_VCB Vcb, LONGLONG Block
2785 );
2786
2787 BOOLEAN
2788 Ext2CheckBitmapConsistency(
2789 PEXT2_IRP_CONTEXT IrpContext,
2790 PEXT2_VCB Vcb
2791 );
2792
2793 VOID
2794 Ext2InsertVcb(PEXT2_VCB Vcb);
2795
2796 VOID
2797 Ext2RemoveVcb(PEXT2_VCB Vcb);
2798
2799 NTSTATUS
2800 Ext2InitializeLabel(
2801 IN PEXT2_VCB Vcb,
2802 IN PEXT2_SUPER_BLOCK Sb
2803 );
2804
2805 NTSTATUS
2806 Ext2InitializeVcb(
2807 PEXT2_IRP_CONTEXT IrpContext,
2808 PEXT2_VCB Vcb,
2809 PEXT2_SUPER_BLOCK Ext2Sb,
2810 PDEVICE_OBJECT TargetDevice,
2811 PDEVICE_OBJECT VolumeDevice,
2812 PVPB Vpb );
2813
2814 VOID
2815 Ext2TearDownStream (IN PEXT2_VCB Vcb);
2816
2817 VOID
2818 Ext2DestroyVcb (IN PEXT2_VCB Vcb);
2819
2820 NTSTATUS
2821 Ext2CompleteIrpContext (
2822 IN PEXT2_IRP_CONTEXT IrpContext,
2823 IN NTSTATUS Status );
2824
2825 VOID
2826 Ext2SyncUninitializeCacheMap (
2827 IN PFILE_OBJECT FileObject );
2828
2829 VOID
2830 Ext2LinkTailMcb(PEXT2_VCB Vcb, PEXT2_MCB Mcb);
2831
2832
2833 VOID
2834 Ext2LinkHeadMcb(PEXT2_VCB Vcb, PEXT2_MCB Mcb);
2835
2836 VOID
2837 Ext2UnlinkMcb(PEXT2_VCB Vcb, PEXT2_MCB Mcb);
2838
2839 PEXT2_MCB
2840 Ext2FirstUnusedMcb(
2841 PEXT2_VCB Vcb,
2842 BOOLEAN Wait,
2843 ULONG Number
2844 );
2845
2846 VOID NTAPI
2847 Ext2ReaperThread(
2848 PVOID Context
2849 );
2850
2851 NTSTATUS
2852 Ext2StartReaper(PEXT2_REAPER, EXT2_REAPER_RELEASE);
2853 VOID
2854 NTAPI
2855 Ext2StopReaper(PEXT2_REAPER Reaper);
2856
2857 //
2858 // Misc.c
2859 //
2860
2861 ULONG
2862 Ext2Log2(ULONG Value);
2863
2864 LARGE_INTEGER
2865 Ext2NtTime (IN ULONG i_time);
2866
2867 ULONG
2868 Ext2LinuxTime (IN LARGE_INTEGER SysTime);
2869
2870 ULONG
2871 Ext2OEMToUnicodeSize(
2872 IN PEXT2_VCB Vcb,
2873 IN PANSI_STRING Oem
2874 );
2875
2876 NTSTATUS
2877 Ext2OEMToUnicode(
2878 IN PEXT2_VCB Vcb,
2879 IN OUT PUNICODE_STRING Oem,
2880 IN POEM_STRING Unicode
2881 );
2882
2883 ULONG
2884 Ext2UnicodeToOEMSize(
2885 IN PEXT2_VCB Vcb,
2886 IN PUNICODE_STRING Unicode
2887 );
2888
2889 NTSTATUS
2890 Ext2UnicodeToOEM (
2891 IN PEXT2_VCB Vcb,
2892 IN OUT POEM_STRING Oem,
2893 IN PUNICODE_STRING Unicode
2894 );
2895
2896 VOID
2897 Ext2Sleep(ULONG ms);
2898
2899 int Ext2LinuxError (NTSTATUS Status);
2900 NTSTATUS Ext2WinntError(int rc);
2901
2902 BOOLEAN Ext2IsDot(PUNICODE_STRING name);
2903 BOOLEAN Ext2IsDotDot(PUNICODE_STRING name);
2904 //
2905 // nls/nls_rtl.c
2906 //
2907
2908 int
2909 Ext2LoadAllNls();
2910
2911 VOID
2912 Ext2UnloadAllNls();
2913
2914 //
2915 // Pnp.c
2916 //
2917
2918 NTSTATUS
2919 Ext2Pnp(IN PEXT2_IRP_CONTEXT IrpContext);
2920
2921 NTSTATUS
2922 Ext2PnpQueryRemove(
2923 PEXT2_IRP_CONTEXT IrpContext,
2924 PEXT2_VCB Vcb );
2925
2926 NTSTATUS
2927 Ext2PnpRemove(
2928 PEXT2_IRP_CONTEXT IrpContext,
2929 PEXT2_VCB Vcb );
2930
2931 NTSTATUS
2932 Ext2PnpCancelRemove(
2933 PEXT2_IRP_CONTEXT IrpContext,
2934 PEXT2_VCB Vcb );
2935
2936 NTSTATUS
2937 Ext2PnpSurpriseRemove(
2938 PEXT2_IRP_CONTEXT IrpContext,
2939 PEXT2_VCB Vcb );
2940
2941
2942 //
2943 // Read.c
2944 //
2945
2946 NTSTATUS
2947 Ext2ReadInode (
2948 IN PEXT2_IRP_CONTEXT IrpContext,
2949 IN PEXT2_VCB Vcb,
2950 IN PEXT2_MCB Mcb,
2951 IN ULONGLONG Offset,
2952 IN PVOID Buffer,
2953 IN ULONG Size,
2954 IN BOOLEAN bDirectIo,
2955 OUT PULONG dwReturn
2956 );
2957
2958 NTSTATUS
2959 Ext2Read (IN PEXT2_IRP_CONTEXT IrpContext);
2960
2961
2962 //
2963 // ext3\recover.c
2964 //
2965
2966 PEXT2_MCB
2967 Ext2LoadInternalJournal(
2968 PEXT2_VCB Vcb,
2969 ULONG jNo
2970 );
2971
2972 INT
2973 Ext2CheckJournal(
2974 PEXT2_VCB Vcb,
2975 PULONG jNo
2976 );
2977
2978 INT
2979 Ext2RecoverJournal(
2980 PEXT2_IRP_CONTEXT IrpContext,
2981 PEXT2_VCB Vcb
2982 );
2983
2984 //
2985 // Shutdown.c
2986 //
2987
2988
2989 NTSTATUS
2990 Ext2ShutDown (IN PEXT2_IRP_CONTEXT IrpContext);
2991
2992
2993 //
2994 // Volinfo.c
2995 //
2996
2997 NTSTATUS
2998 Ext2QueryVolumeInformation (IN PEXT2_IRP_CONTEXT IrpContext);
2999
3000 NTSTATUS
3001 Ext2SetVolumeInformation (IN PEXT2_IRP_CONTEXT IrpContext);
3002
3003 //
3004 // Write.c
3005 //
3006
3007 typedef struct _EXT2_RW_CONTEXT {
3008 PIRP MasterIrp;
3009 KEVENT Event;
3010 ULONG Blocks;
3011 ULONG Length;
3012 PERESOURCE Resource;
3013 ERESOURCE_THREAD ThreadId;
3014 PFILE_OBJECT FileObject;
3015 ULONG Flags;
3016 BOOLEAN Wait;
3017
3018 } EXT2_RW_CONTEXT, *PEXT2_RW_CONTEXT;
3019
3020 #define EXT2_RW_CONTEXT_WRITE 1
3021
3022 NTSTATUS
3023 Ext2WriteInode (
3024 IN PEXT2_IRP_CONTEXT IrpContext,
3025 IN PEXT2_VCB Vcb,
3026 IN PEXT2_MCB Mcb,
3027 IN ULONGLONG Offset,
3028 IN PVOID Buffer,
3029 IN ULONG Size,
3030 IN BOOLEAN bDirectIo,
3031 OUT PULONG dwReturn
3032 );
3033
3034
3035 VOID
3036 Ext2StartFloppyFlushDpc (
3037 PEXT2_VCB Vcb,
3038 PEXT2_FCB Fcb,
3039 PFILE_OBJECT FileObject );
3040
3041 BOOLEAN
3042 Ext2ZeroData (
3043 IN PEXT2_IRP_CONTEXT IrpContext,
3044 IN PEXT2_VCB Vcb,
3045 IN PFILE_OBJECT FileObject,
3046 IN PLARGE_INTEGER Start,
3047 IN PLARGE_INTEGER End );
3048
3049 NTSTATUS
3050 Ext2Write (IN PEXT2_IRP_CONTEXT IrpContext);
3051
3052 #endif /* _EXT2_HEADER_ */