[EXT2]
[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_DEFAULT (DL_ERR|DL_VIT)
1403
1404 #if EXT2_DEBUG
1405 extern ULONG DebugFilter;
1406
1407 VOID
1408 __cdecl
1409 Ext2NiPrintf(
1410 PCHAR DebugMessage,
1411 ...
1412 );
1413
1414 #define DEBUG(_DL, arg) do {if ((_DL) & DebugFilter) Ext2Printf arg;} while(0)
1415 #define DEBUGNI(_DL, arg) do {if ((_DL) & DebugFilter) Ext2NiPrintf arg;} while(0)
1416
1417 #define Ext2CompleteRequest(Irp, bPrint, PriorityBoost) \
1418 Ext2DbgPrintComplete(Irp, bPrint); \
1419 IoCompleteRequest(Irp, PriorityBoost)
1420
1421 #else
1422
1423 #define DEBUG(_DL, arg) do {if ((_DL) & DL_ERR) DbgPrint arg;} while(0)
1424
1425 #define Ext2CompleteRequest(Irp, bPrint, PriorityBoost) \
1426 IoCompleteRequest(Irp, PriorityBoost)
1427
1428 #endif // EXT2_DEBUG
1429
1430 VOID
1431 __cdecl
1432 Ext2Printf(
1433 PCHAR DebugMessage,
1434 ...
1435 );
1436
1437 extern ULONG ProcessNameOffset;
1438
1439 #define Ext2GetCurrentProcessName() ( \
1440 (PUCHAR) PsGetCurrentProcess() + ProcessNameOffset \
1441 )
1442
1443 ULONG
1444 Ext2GetProcessNameOffset (VOID);
1445
1446 VOID
1447 Ext2DbgPrintCall (
1448 IN PDEVICE_OBJECT DeviceObject,
1449 IN PIRP Irp );
1450
1451 VOID
1452 Ext2DbgPrintComplete (
1453 IN PIRP Irp,
1454 IN BOOLEAN bPrint
1455 );
1456
1457 PUCHAR
1458 Ext2NtStatusToString (IN NTSTATUS Status );
1459
1460 PVOID Ext2AllocatePool(
1461 IN POOL_TYPE PoolType,
1462 IN SIZE_T NumberOfBytes,
1463 IN ULONG Tag
1464 );
1465
1466 VOID
1467 Ext2FreePool(
1468 IN PVOID P,
1469 IN ULONG Tag
1470 );
1471
1472 //
1473 // Devctl.c
1474 //
1475
1476 NTSTATUS
1477 Ext2ProcessGlobalProperty(
1478 IN PDEVICE_OBJECT DeviceObject,
1479 IN PEXT2_VOLUME_PROPERTY3 Property,
1480 IN ULONG Length
1481 );
1482
1483 NTSTATUS
1484 Ext2ProcessVolumeProperty(
1485 IN PEXT2_VCB Vcb,
1486 IN PEXT2_VOLUME_PROPERTY3 Property,
1487 IN ULONG Length
1488 );
1489
1490 NTSTATUS
1491 Ext2ProcessUserProperty(
1492 IN PEXT2_IRP_CONTEXT IrpContext,
1493 IN PEXT2_VOLUME_PROPERTY3 Property,
1494 IN ULONG Length
1495 );
1496
1497 NTSTATUS
1498 Ex2ProcessUserPerfStat(
1499 IN PEXT2_IRP_CONTEXT IrpContext,
1500 IN PEXT2_QUERY_PERFSTAT QueryPerf,
1501 IN ULONG Length
1502 );
1503
1504 NTSTATUS
1505 Ex2ProcessMountPoint(
1506 IN PEXT2_IRP_CONTEXT IrpContext,
1507 IN PEXT2_MOUNT_POINT MountPoint,
1508 IN ULONG Length
1509 );
1510
1511 NTSTATUS
1512 Ext2DeviceControlNormal (IN PEXT2_IRP_CONTEXT IrpContext);
1513
1514 NTSTATUS
1515 Ext2PrepareToUnload (IN PEXT2_IRP_CONTEXT IrpContext);
1516
1517 NTSTATUS
1518 Ext2DeviceControl (IN PEXT2_IRP_CONTEXT IrpContext);
1519
1520 //
1521 // Dirctl.c
1522 //
1523
1524 ULONG
1525 Ext2GetInfoLength(IN FILE_INFORMATION_CLASS FileInformationClass);
1526
1527 NTSTATUS
1528 Ext2ProcessEntry(
1529 IN PEXT2_IRP_CONTEXT IrpContext,
1530 IN PEXT2_VCB Vcb,
1531 IN PEXT2_FCB Dcb,
1532 IN FILE_INFORMATION_CLASS FileInformationClass,
1533 IN ULONG in,
1534 IN PVOID Buffer,
1535 IN ULONG UsedLength,
1536 IN ULONG Length,
1537 IN ULONG FileIndex,
1538 IN PUNICODE_STRING pName,
1539 OUT PULONG EntrySize,
1540 IN BOOLEAN Single
1541 );
1542
1543 BOOLEAN
1544 Ext2IsWearingCloak(
1545 IN PEXT2_VCB Vcb,
1546 IN POEM_STRING OeName
1547 );
1548
1549 NTSTATUS Ext2QueryDirectory (IN PEXT2_IRP_CONTEXT IrpContext);
1550
1551 NTSTATUS
1552 Ext2NotifyChangeDirectory (
1553 IN PEXT2_IRP_CONTEXT IrpContext
1554 );
1555
1556 VOID
1557 Ext2NotifyReportChange (
1558 IN PEXT2_IRP_CONTEXT IrpContext,
1559 IN PEXT2_VCB Vcb,
1560 IN PEXT2_MCB Mcb,
1561 IN ULONG Filter,
1562 IN ULONG Action
1563 );
1564
1565 NTSTATUS
1566 Ext2DirectoryControl (IN PEXT2_IRP_CONTEXT IrpContext);
1567
1568 BOOLEAN
1569 Ext2IsDirectoryEmpty (
1570 IN PEXT2_IRP_CONTEXT IrpContext,
1571 IN PEXT2_VCB Vcb,
1572 IN PEXT2_MCB Mcb
1573 );
1574
1575 //
1576 // Dispatch.c
1577 //
1578
1579 VOID NTAPI
1580 Ext2OplockComplete (
1581 IN PVOID Context,
1582 IN PIRP Irp
1583 );
1584
1585 VOID NTAPI
1586 Ext2LockIrp (
1587 IN PVOID Context,
1588 IN PIRP Irp
1589 );
1590
1591 NTSTATUS
1592 Ext2QueueRequest (IN PEXT2_IRP_CONTEXT IrpContext);
1593
1594 VOID NTAPI
1595 Ext2DeQueueRequest (IN PVOID Context);
1596
1597 NTSTATUS
1598 Ext2DispatchRequest (IN PEXT2_IRP_CONTEXT IrpContext);
1599
1600 NTSTATUS NTAPI
1601 Ext2BuildRequest (
1602 IN PDEVICE_OBJECT DeviceObject,
1603 IN PIRP Irp
1604 );
1605
1606 //
1607 // Except.c
1608 //
1609
1610 NTSTATUS
1611 Ext2ExceptionFilter (
1612 IN PEXT2_IRP_CONTEXT IrpContext,
1613 IN PEXCEPTION_POINTERS ExceptionPointer
1614 );
1615
1616 NTSTATUS
1617 Ext2ExceptionHandler (IN PEXT2_IRP_CONTEXT IrpContext);
1618
1619
1620 //
1621 // Extents.c
1622 //
1623
1624
1625 NTSTATUS
1626 Ext2MapExtent(
1627 IN PEXT2_IRP_CONTEXT IrpContext,
1628 IN PEXT2_VCB Vcb,
1629 IN PEXT2_MCB Mcb,
1630 IN ULONG Index,
1631 IN BOOLEAN Alloc,
1632 OUT PULONG Block,
1633 OUT PULONG Number
1634 );
1635
1636 NTSTATUS
1637 Ext2ExpandExtent(
1638 PEXT2_IRP_CONTEXT IrpContext,
1639 PEXT2_VCB Vcb,
1640 PEXT2_MCB Mcb,
1641 ULONG Start,
1642 ULONG End,
1643 PLARGE_INTEGER Size
1644 );
1645
1646 NTSTATUS
1647 Ext2TruncateExtent(
1648 PEXT2_IRP_CONTEXT IrpContext,
1649 PEXT2_VCB Vcb,
1650 PEXT2_MCB Mcb,
1651 PLARGE_INTEGER Size
1652 );
1653
1654
1655 //
1656 // generic.c
1657 //
1658
1659 static inline ext3_fsblk_t ext3_blocks_count(struct ext3_super_block *es)
1660 {
1661 return ((ext3_fsblk_t)le32_to_cpu(es->s_blocks_count_hi) << 32) |
1662 le32_to_cpu(es->s_blocks_count);
1663 }
1664
1665 static inline ext3_fsblk_t ext3_r_blocks_count(struct ext3_super_block *es)
1666 {
1667 return ((ext3_fsblk_t)le32_to_cpu(es->s_r_blocks_count_hi) << 32) |
1668 le32_to_cpu(es->s_r_blocks_count);
1669 }
1670
1671 static inline ext3_fsblk_t ext3_free_blocks_count(struct ext3_super_block *es)
1672 {
1673 return ((ext3_fsblk_t)le32_to_cpu(es->s_free_blocks_count_hi) << 32) |
1674 le32_to_cpu(es->s_free_blocks_count);
1675 }
1676
1677 static inline void ext3_blocks_count_set(struct ext3_super_block *es,
1678 ext3_fsblk_t blk)
1679 {
1680 es->s_blocks_count = cpu_to_le32((u32)blk);
1681 es->s_blocks_count_hi = cpu_to_le32(blk >> 32);
1682 }
1683
1684 static inline void ext3_free_blocks_count_set(struct ext3_super_block *es,
1685 ext3_fsblk_t blk)
1686 {
1687 es->s_free_blocks_count = cpu_to_le32((u32)blk);
1688 es->s_free_blocks_count_hi = cpu_to_le32(blk >> 32);
1689 }
1690
1691 static inline void ext3_r_blocks_count_set(struct ext3_super_block *es,
1692 ext3_fsblk_t blk)
1693 {
1694 es->s_r_blocks_count = cpu_to_le32((u32)blk);
1695 es->s_r_blocks_count_hi = cpu_to_le32(blk >> 32);
1696 }
1697
1698 blkcnt_t ext3_inode_blocks(struct ext3_inode *raw_inode,
1699 struct inode *inode);
1700
1701 int ext3_inode_blocks_set(struct ext3_inode *raw_inode,
1702 struct inode * inode);
1703 ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
1704 struct ext4_group_desc *bg);
1705
1706 ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb,
1707 struct ext4_group_desc *bg);
1708 ext4_fsblk_t ext4_inode_table(struct super_block *sb,
1709 struct ext4_group_desc *bg);
1710 __u32 ext4_free_blks_count(struct super_block *sb,
1711 struct ext4_group_desc *bg);
1712 __u32 ext4_free_inodes_count(struct super_block *sb,
1713 struct ext4_group_desc *bg);
1714 __u32 ext4_used_dirs_count(struct super_block *sb,
1715 struct ext4_group_desc *bg);
1716 __u32 ext4_itable_unused_count(struct super_block *sb,
1717 struct ext4_group_desc *bg);
1718 void ext4_block_bitmap_set(struct super_block *sb,
1719 struct ext4_group_desc *bg, ext4_fsblk_t blk);
1720 void ext4_inode_bitmap_set(struct super_block *sb,
1721 struct ext4_group_desc *bg, ext4_fsblk_t blk);
1722 void ext4_inode_table_set(struct super_block *sb,
1723 struct ext4_group_desc *bg, ext4_fsblk_t blk);
1724 void ext4_free_blks_set(struct super_block *sb,
1725 struct ext4_group_desc *bg, __u32 count);
1726 void ext4_free_inodes_set(struct super_block *sb,
1727 struct ext4_group_desc *bg, __u32 count);
1728 void ext4_used_dirs_set(struct super_block *sb,
1729 struct ext4_group_desc *bg, __u32 count);
1730 void ext4_itable_unused_set(struct super_block *sb,
1731 struct ext4_group_desc *bg, __u32 count);
1732
1733 int ext3_bg_has_super(struct super_block *sb, ext3_group_t group);
1734 unsigned long ext4_bg_num_gdb(struct super_block *sb, ext4_group_t group);
1735 unsigned ext4_init_inode_bitmap(struct super_block *sb, struct buffer_head *bh,
1736 ext4_group_t block_group,
1737 struct ext4_group_desc *gdp);
1738 unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
1739 ext4_group_t block_group, struct ext4_group_desc *gdp);
1740 struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb,
1741 ext4_group_t block_group, struct buffer_head **bh);
1742 ext4_fsblk_t ext4_count_free_blocks(struct super_block *sb);
1743 unsigned long ext4_count_free_inodes(struct super_block *sb);
1744 int ext4_check_descriptors(struct super_block *sb);
1745
1746 NTSTATUS
1747 Ext2LoadSuper(
1748 IN PEXT2_VCB Vcb,
1749 IN BOOLEAN bVerify,
1750 OUT PEXT2_SUPER_BLOCK * Sb
1751 );
1752
1753
1754 BOOLEAN
1755 Ext2SaveSuper(
1756 IN PEXT2_IRP_CONTEXT IrpContext,
1757 IN PEXT2_VCB Vcb
1758 );
1759
1760 BOOLEAN
1761 Ext2RefreshSuper(
1762 IN PEXT2_IRP_CONTEXT IrpContext,
1763 IN PEXT2_VCB Vcb
1764 );
1765
1766 BOOLEAN
1767 Ext2LoadGroup(IN PEXT2_VCB Vcb);
1768
1769 VOID
1770 Ext2PutGroup(IN PEXT2_VCB Vcb);
1771
1772 VOID
1773 Ext2DropBH(IN PEXT2_VCB Vcb);
1774
1775 BOOLEAN
1776 Ext2SaveGroup(
1777 IN PEXT2_IRP_CONTEXT IrpContext,
1778 IN PEXT2_VCB Vcb,
1779 IN ULONG Group
1780 );
1781
1782 BOOLEAN
1783 Ext2RefreshGroup(
1784 IN PEXT2_IRP_CONTEXT IrpContext,
1785 IN PEXT2_VCB Vcb
1786 );
1787
1788 BOOLEAN
1789 Ext2GetInodeLba (
1790 IN PEXT2_VCB Vcb,
1791 IN ULONG inode,
1792 OUT PLONGLONG offset
1793 );
1794
1795 BOOLEAN
1796 Ext2LoadInode (
1797 IN PEXT2_VCB Vcb,
1798 IN struct inode *Inode
1799 );
1800
1801 BOOLEAN
1802 Ext2ClearInode (
1803 IN PEXT2_IRP_CONTEXT IrpContext,
1804 IN PEXT2_VCB Vcb,
1805 IN ULONG inode
1806 );
1807
1808 BOOLEAN
1809 Ext2SaveInode (
1810 IN PEXT2_IRP_CONTEXT IrpContext,
1811 IN PEXT2_VCB Vcb,
1812 IN struct inode *Inode
1813 );
1814
1815 BOOLEAN
1816 Ext2LoadBlock (
1817 IN PEXT2_VCB Vcb,
1818 IN ULONG dwBlk,
1819 IN PVOID Buffer
1820 );
1821
1822 BOOLEAN
1823 Ext2SaveBlock (
1824 IN PEXT2_IRP_CONTEXT IrpContext,
1825 IN PEXT2_VCB Vcb,
1826 IN ULONG dwBlk,
1827 IN PVOID Buf
1828 );
1829
1830 BOOLEAN
1831 Ext2ZeroBuffer(
1832 IN PEXT2_IRP_CONTEXT IrpContext,
1833 IN PEXT2_VCB Vcb,
1834 IN LONGLONG Offset,
1835 IN ULONG Size
1836 );
1837
1838 BOOLEAN
1839 Ext2SaveBuffer(
1840 IN PEXT2_IRP_CONTEXT IrpContext,
1841 IN PEXT2_VCB Vcb,
1842 IN LONGLONG Offset,
1843 IN ULONG Size,
1844 IN PVOID Buf
1845 );
1846
1847 NTSTATUS
1848 Ext2GetBlock(
1849 IN PEXT2_IRP_CONTEXT IrpContext,
1850 IN PEXT2_VCB Vcb,
1851 IN PEXT2_MCB Mcb,
1852 IN ULONG Base,
1853 IN ULONG Layer,
1854 IN ULONG Start,
1855 IN ULONG SizeArray,
1856 IN PULONG BlockArray,
1857 IN BOOLEAN bAlloc,
1858 IN OUT PULONG Hint,
1859 OUT PULONG Block,
1860 OUT PULONG Number
1861 );
1862
1863 NTSTATUS
1864 Ext2BlockMap(
1865 IN PEXT2_IRP_CONTEXT IrpContext,
1866 IN PEXT2_VCB Vcb,
1867 IN PEXT2_MCB Mcb,
1868 IN ULONG Index,
1869 IN BOOLEAN bAlloc,
1870 OUT PULONG pBlock,
1871 OUT PULONG Number
1872 );
1873
1874 VOID
1875 Ext2UpdateVcbStat(
1876 IN PEXT2_IRP_CONTEXT IrpContext,
1877 IN PEXT2_VCB Vcb
1878 );
1879
1880 NTSTATUS
1881 Ext2NewBlock(
1882 IN PEXT2_IRP_CONTEXT IrpContext,
1883 IN PEXT2_VCB Vcb,
1884 IN ULONG GroupHint,
1885 IN ULONG BlockHint,
1886 OUT PULONG Block,
1887 IN OUT PULONG Number
1888 );
1889
1890 NTSTATUS
1891 Ext2FreeBlock(
1892 IN PEXT2_IRP_CONTEXT IrpContext,
1893 IN PEXT2_VCB Vcb,
1894 IN ULONG Block,
1895 IN ULONG Number
1896 );
1897
1898
1899 NTSTATUS
1900 Ext2NewInode(
1901 IN PEXT2_IRP_CONTEXT IrpContext,
1902 IN PEXT2_VCB Vcb,
1903 IN ULONG GroupHint,
1904 IN ULONG Type,
1905 OUT PULONG Inode
1906 );
1907
1908 NTSTATUS
1909 Ext2UpdateGroupDirStat(
1910 IN PEXT2_IRP_CONTEXT IrpContext,
1911 IN PEXT2_VCB Vcb,
1912 IN ULONG Group
1913 );
1914
1915 NTSTATUS
1916 Ext2FreeInode(
1917 IN PEXT2_IRP_CONTEXT IrpContext,
1918 IN PEXT2_VCB Vcb,
1919 IN ULONG Inode,
1920 IN ULONG Type
1921 );
1922
1923 NTSTATUS
1924 Ext2AddEntry (
1925 IN PEXT2_IRP_CONTEXT IrpContext,
1926 IN PEXT2_VCB Vcb,
1927 IN PEXT2_FCB Dcb,
1928 IN struct inode *Inode,
1929 IN PUNICODE_STRING FileName,
1930 OUT struct dentry **dentry
1931 );
1932
1933 NTSTATUS
1934 Ext2SetFileType (
1935 IN PEXT2_IRP_CONTEXT IrpContext,
1936 IN PEXT2_VCB Vcb,
1937 IN PEXT2_FCB Dcb,
1938 IN PEXT2_MCB Mcb,
1939 IN umode_t mode
1940 );
1941
1942 NTSTATUS
1943 Ext2RemoveEntry (
1944 IN PEXT2_IRP_CONTEXT IrpContext,
1945 IN PEXT2_VCB Vcb,
1946 IN PEXT2_FCB Dcb,
1947 IN PEXT2_MCB Mcb
1948 );
1949
1950 NTSTATUS
1951 Ext2SetParentEntry (
1952 IN PEXT2_IRP_CONTEXT IrpContext,
1953 IN PEXT2_VCB Vcb,
1954 IN PEXT2_FCB Dcb,
1955 IN ULONG OldParent,
1956 IN ULONG NewParent );
1957
1958
1959 NTSTATUS
1960 Ext2TruncateBlock(
1961 IN PEXT2_IRP_CONTEXT IrpContext,
1962 IN PEXT2_VCB Vcb,
1963 IN PEXT2_MCB Mcb,
1964 IN ULONG Base,
1965 IN ULONG Start,
1966 IN ULONG Layer,
1967 IN ULONG SizeArray,
1968 IN PULONG BlockArray,
1969 IN PULONG Extra
1970 );
1971
1972 struct ext3_dir_entry_2 *ext3_next_entry(struct ext3_dir_entry_2 *p);
1973
1974 int ext3_check_dir_entry (const char * function, struct inode * dir,
1975 struct ext3_dir_entry_2 * de,
1976 struct buffer_head * bh,
1977 unsigned long offset);
1978
1979 loff_t ext3_max_size(int blkbits, int has_huge_files);
1980 loff_t ext3_max_bitmap_size(int bits, int has_huge_files);
1981
1982
1983 __le16 ext4_group_desc_csum(struct ext3_sb_info *sbi, __u32 block_group,
1984 struct ext4_group_desc *gdp);
1985 int ext4_group_desc_csum_verify(struct ext3_sb_info *sbi, __u32 block_group,
1986 struct ext4_group_desc *gdp);
1987
1988 ext3_fsblk_t descriptor_loc(struct super_block *sb,
1989 ext3_fsblk_t logical_sb_block, unsigned int nr);
1990 struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb,
1991 ext4_group_t block_group, struct buffer_head **bh);
1992 int ext4_check_descriptors(struct super_block *sb);
1993
1994 //
1995 // Fastio.c
1996 //
1997
1998 FAST_IO_POSSIBLE
1999 Ext2IsFastIoPossible(
2000 IN PEXT2_FCB Fcb
2001 );
2002
2003 BOOLEAN NTAPI
2004 Ext2FastIoCheckIfPossible (
2005 IN PFILE_OBJECT FileObject,
2006 IN PLARGE_INTEGER FileOffset,
2007 IN ULONG Length,
2008 IN BOOLEAN Wait,
2009 IN ULONG LockKey,
2010 IN BOOLEAN CheckForReadOperation,
2011 OUT PIO_STATUS_BLOCK IoStatus,
2012 IN PDEVICE_OBJECT DeviceObject
2013 );
2014
2015
2016 BOOLEAN NTAPI
2017 Ext2FastIoRead (IN PFILE_OBJECT FileObject,
2018 IN PLARGE_INTEGER FileOffset,
2019 IN ULONG Length,
2020 IN BOOLEAN Wait,
2021 IN ULONG LockKey,
2022 OUT PVOID Buffer,
2023 OUT PIO_STATUS_BLOCK IoStatus,
2024 IN PDEVICE_OBJECT DeviceObject);
2025
2026 BOOLEAN NTAPI
2027 Ext2FastIoWrite (
2028 IN PFILE_OBJECT FileObject,
2029 IN PLARGE_INTEGER FileOffset,
2030 IN ULONG Length,
2031 IN BOOLEAN Wait,
2032 IN ULONG LockKey,
2033 OUT PVOID Buffer,
2034 OUT PIO_STATUS_BLOCK IoStatus,
2035 IN PDEVICE_OBJECT DeviceObject);
2036
2037 BOOLEAN NTAPI
2038 Ext2FastIoQueryBasicInfo (
2039 IN PFILE_OBJECT FileObject,
2040 IN BOOLEAN Wait,
2041 OUT PFILE_BASIC_INFORMATION Buffer,
2042 OUT PIO_STATUS_BLOCK IoStatus,
2043 IN PDEVICE_OBJECT DeviceObject);
2044
2045 BOOLEAN NTAPI
2046 Ext2FastIoQueryStandardInfo (
2047 IN PFILE_OBJECT FileObject,
2048 IN BOOLEAN Wait,
2049 OUT PFILE_STANDARD_INFORMATION Buffer,
2050 OUT PIO_STATUS_BLOCK IoStatus,
2051 IN PDEVICE_OBJECT DeviceObject);
2052
2053 BOOLEAN NTAPI
2054 Ext2FastIoLock (
2055 IN PFILE_OBJECT FileObject,
2056 IN PLARGE_INTEGER FileOffset,
2057 IN PLARGE_INTEGER Length,
2058 IN PEPROCESS Process,
2059 IN ULONG Key,
2060 IN BOOLEAN FailImmediately,
2061 IN BOOLEAN ExclusiveLock,
2062 OUT PIO_STATUS_BLOCK IoStatus,
2063 IN PDEVICE_OBJECT DeviceObject
2064 );
2065
2066 BOOLEAN NTAPI
2067 Ext2FastIoUnlockSingle (
2068 IN PFILE_OBJECT FileObject,
2069 IN PLARGE_INTEGER FileOffset,
2070 IN PLARGE_INTEGER Length,
2071 IN PEPROCESS Process,
2072 IN ULONG Key,
2073 OUT PIO_STATUS_BLOCK IoStatus,
2074 IN PDEVICE_OBJECT DeviceObject
2075 );
2076
2077 BOOLEAN NTAPI
2078 Ext2FastIoUnlockAll (
2079 IN PFILE_OBJECT FileObject,
2080 IN PEPROCESS Process,
2081 OUT PIO_STATUS_BLOCK IoStatus,
2082 IN PDEVICE_OBJECT DeviceObject
2083 );
2084
2085 BOOLEAN NTAPI
2086 Ext2FastIoUnlockAllByKey (
2087 IN PFILE_OBJECT FileObject,
2088 #ifdef __REACTOS__
2089 IN PVOID Process,
2090 #else
2091 IN PEPROCESS Process,
2092 #endif
2093 IN ULONG Key,
2094 OUT PIO_STATUS_BLOCK IoStatus,
2095 IN PDEVICE_OBJECT DeviceObject
2096 );
2097
2098
2099 BOOLEAN NTAPI
2100 Ext2FastIoQueryNetworkOpenInfo (
2101 IN PFILE_OBJECT FileObject,
2102 IN BOOLEAN Wait,
2103 OUT PFILE_NETWORK_OPEN_INFORMATION Buffer,
2104 OUT PIO_STATUS_BLOCK IoStatus,
2105 IN PDEVICE_OBJECT DeviceObject );
2106
2107 BOOLEAN NTAPI
2108 Ext2FastIoQueryNetworkOpenInfo (
2109 IN PFILE_OBJECT FileObject,
2110 IN BOOLEAN Wait,
2111 OUT PFILE_NETWORK_OPEN_INFORMATION Buffer,
2112 OUT PIO_STATUS_BLOCK IoStatus,
2113 IN PDEVICE_OBJECT DeviceObject);
2114
2115 VOID
2116 NTAPI
2117 Ext2AcquireForCreateSection (
2118 IN PFILE_OBJECT FileObject
2119 );
2120
2121 VOID
2122 NTAPI
2123 Ext2ReleaseForCreateSection (
2124 IN PFILE_OBJECT FileObject
2125 );
2126
2127 NTSTATUS
2128 NTAPI
2129 Ext2AcquireFileForModWrite (
2130 IN PFILE_OBJECT FileObject,
2131 IN PLARGE_INTEGER EndingOffset,
2132 OUT PERESOURCE *ResourceToRelease,
2133 IN PDEVICE_OBJECT DeviceObject
2134 );
2135
2136 NTSTATUS
2137 NTAPI
2138 Ext2ReleaseFileForModWrite (
2139 IN PFILE_OBJECT FileObject,
2140 IN PERESOURCE ResourceToRelease,
2141 IN PDEVICE_OBJECT DeviceObject
2142 );
2143
2144 NTSTATUS
2145 NTAPI
2146 Ext2AcquireFileForCcFlush (
2147 IN PFILE_OBJECT FileObject,
2148 IN PDEVICE_OBJECT DeviceObject
2149 );
2150
2151 NTSTATUS
2152 NTAPI
2153 Ext2ReleaseFileForCcFlush (
2154 IN PFILE_OBJECT FileObject,
2155 IN PDEVICE_OBJECT DeviceObject
2156 );
2157
2158
2159 NTSTATUS
2160 NTAPI
2161 Ext2PreAcquireForCreateSection(
2162 IN PFS_FILTER_CALLBACK_DATA cd,
2163 OUT PVOID *cc
2164 );
2165
2166 //
2167 // FileInfo.c
2168 //
2169
2170
2171 NTSTATUS
2172 Ext2QueryFileInformation (IN PEXT2_IRP_CONTEXT IrpContext);
2173
2174 NTSTATUS
2175 Ext2SetFileInformation (IN PEXT2_IRP_CONTEXT IrpContext);
2176
2177 ULONG
2178 Ext2TotalBlocks(
2179 PEXT2_VCB Vcb,
2180 PLARGE_INTEGER Size,
2181 PULONG pMeta
2182 );
2183
2184 NTSTATUS
2185 Ext2ExpandFile(
2186 PEXT2_IRP_CONTEXT IrpContext,
2187 PEXT2_VCB Vcb,
2188 PEXT2_MCB Mcb,
2189 PLARGE_INTEGER Size
2190 );
2191
2192 NTSTATUS
2193 Ext2TruncateFile (
2194 PEXT2_IRP_CONTEXT IrpContext,
2195 PEXT2_VCB Vcb,
2196 PEXT2_MCB Mcb,
2197 PLARGE_INTEGER AllocationSize );
2198
2199 NTSTATUS
2200 Ext2IsFileRemovable(
2201 IN PEXT2_IRP_CONTEXT IrpContext,
2202 IN PEXT2_VCB Vcb,
2203 IN PEXT2_FCB Fcb,
2204 IN PEXT2_CCB Ccb
2205 );
2206
2207 NTSTATUS
2208 Ext2SetDispositionInfo(
2209 PEXT2_IRP_CONTEXT IrpContext,
2210 PEXT2_VCB Vcb,
2211 PEXT2_FCB Fcb,
2212 PEXT2_CCB Ccb,
2213 BOOLEAN bDelete
2214 );
2215
2216 NTSTATUS
2217 Ext2SetRenameInfo(
2218 PEXT2_IRP_CONTEXT IrpContext,
2219 PEXT2_VCB Vcb,
2220 PEXT2_FCB Fcb,
2221 PEXT2_CCB Ccb
2222 );
2223
2224 NTSTATUS
2225 Ext2SetLinkInfo(
2226 PEXT2_IRP_CONTEXT IrpContext,
2227 PEXT2_VCB Vcb,
2228 PEXT2_FCB Fcb,
2229 PEXT2_CCB Ccb
2230 );
2231
2232 ULONG
2233 Ext2InodeType(PEXT2_MCB Mcb);
2234
2235 NTSTATUS
2236 Ext2DeleteFile(
2237 PEXT2_IRP_CONTEXT IrpContext,
2238 PEXT2_VCB Vcb,
2239 PEXT2_FCB Fcb,
2240 PEXT2_MCB Mcb
2241 );
2242
2243
2244 //
2245 // Flush.c
2246 //
2247
2248 NTSTATUS
2249 Ext2FlushFiles(
2250 IN PEXT2_IRP_CONTEXT IrpContext,
2251 IN PEXT2_VCB Vcb,
2252 IN BOOLEAN bShutDown
2253 );
2254
2255 NTSTATUS
2256 Ext2FlushVolume (
2257 IN PEXT2_IRP_CONTEXT IrpContext,
2258 IN PEXT2_VCB Vcb,
2259 IN BOOLEAN bShutDown
2260 );
2261
2262 NTSTATUS
2263 Ext2FlushFile (
2264 IN PEXT2_IRP_CONTEXT IrpContext,
2265 IN PEXT2_FCB Fcb,
2266 IN PEXT2_CCB Ccb
2267 );
2268
2269 NTSTATUS
2270 Ext2Flush (IN PEXT2_IRP_CONTEXT IrpContext);
2271
2272
2273 //
2274 // Fsctl.c
2275 //
2276
2277 NTSTATUS
2278 Ext2ReadSymlink (
2279 IN PEXT2_IRP_CONTEXT IrpContext,
2280 IN PEXT2_VCB Vcb,
2281 IN PEXT2_MCB Mcb,
2282 IN PVOID Buffer,
2283 IN ULONG Size,
2284 OUT PULONG BytesRead
2285 );
2286
2287 NTSTATUS
2288 Ext2WriteSymlink (
2289 IN PEXT2_IRP_CONTEXT IrpContext,
2290 IN PEXT2_VCB Vcb,
2291 IN PEXT2_MCB Mcb,
2292 IN PVOID Buffer,
2293 IN ULONG Size,
2294 OUT PULONG BytesWritten
2295 );
2296
2297 NTSTATUS
2298 Ext2TruncateSymlink(
2299 PEXT2_IRP_CONTEXT IrpContext,
2300 PEXT2_VCB Vcb,
2301 PEXT2_MCB Mcb,
2302 ULONG Size
2303 );
2304
2305 //
2306 // MountPoint process workitem
2307 //
2308
2309 VOID
2310 Ext2SetVpbFlag (IN PVPB Vpb,
2311 IN USHORT Flag );
2312
2313 VOID
2314 Ext2ClearVpbFlag (IN PVPB Vpb,
2315 IN USHORT Flag );
2316
2317 BOOLEAN
2318 Ext2CheckDismount (
2319 IN PEXT2_IRP_CONTEXT IrpContext,
2320 IN PEXT2_VCB Vcb,
2321 IN BOOLEAN bForce );
2322
2323 NTSTATUS
2324 Ext2PurgeVolume (IN PEXT2_VCB Vcb,
2325 IN BOOLEAN FlushBeforePurge);
2326
2327 NTSTATUS
2328 Ext2PurgeFile (IN PEXT2_FCB Fcb,
2329 IN BOOLEAN FlushBeforePurge);
2330
2331 BOOLEAN
2332 Ext2IsHandleCountZero(IN PEXT2_VCB Vcb);
2333
2334 NTSTATUS
2335 Ext2LockVcb (IN PEXT2_VCB Vcb,
2336 IN PFILE_OBJECT FileObject);
2337
2338 NTSTATUS
2339 Ext2LockVolume (IN PEXT2_IRP_CONTEXT IrpContext);
2340
2341 NTSTATUS
2342 Ext2UnlockVcb (IN PEXT2_VCB Vcb,
2343 IN PFILE_OBJECT FileObject);
2344
2345 NTSTATUS
2346 Ext2UnlockVolume (IN PEXT2_IRP_CONTEXT IrpContext);
2347
2348 NTSTATUS
2349 Ext2AllowExtendedDasdIo(IN PEXT2_IRP_CONTEXT IrpContext);
2350
2351 NTSTATUS
2352 Ext2OplockRequest (IN PEXT2_IRP_CONTEXT IrpContext);
2353
2354 NTSTATUS
2355 Ext2QueryExtentMappings(
2356 IN PEXT2_IRP_CONTEXT IrpContext,
2357 IN PEXT2_VCB Vcb,
2358 IN PEXT2_FCB Fcb,
2359 IN PLARGE_INTEGER RequestVbn,
2360 OUT PLARGE_INTEGER * pMappedRuns
2361 );
2362
2363 NTSTATUS
2364 Ext2QueryRetrievalPointers(IN PEXT2_IRP_CONTEXT IrpContext);
2365
2366 NTSTATUS
2367 Ext2GetRetrievalPointers(IN PEXT2_IRP_CONTEXT IrpContext);
2368
2369 NTSTATUS
2370 Ext2GetRetrievalPointerBase(IN PEXT2_IRP_CONTEXT IrpContext);
2371
2372 NTSTATUS
2373 Ext2UserFsRequest (IN PEXT2_IRP_CONTEXT IrpContext);
2374
2375 BOOLEAN
2376 Ext2IsMediaWriteProtected (
2377 IN PEXT2_IRP_CONTEXT IrpContext,
2378 IN PDEVICE_OBJECT TargetDevice
2379 );
2380
2381 NTSTATUS
2382 Ext2MountVolume (IN PEXT2_IRP_CONTEXT IrpContext);
2383
2384 VOID
2385 Ext2VerifyVcb (IN PEXT2_IRP_CONTEXT IrpContext,
2386 IN PEXT2_VCB Vcb );
2387 NTSTATUS
2388 Ext2VerifyVolume (IN PEXT2_IRP_CONTEXT IrpContext);
2389
2390 NTSTATUS
2391 Ext2IsVolumeMounted (IN PEXT2_IRP_CONTEXT IrpContext);
2392
2393 NTSTATUS
2394 Ext2DismountVolume (IN PEXT2_IRP_CONTEXT IrpContext);
2395
2396 NTSTATUS
2397 Ext2FileSystemControl (IN PEXT2_IRP_CONTEXT IrpContext);
2398
2399 //
2400 // HTree.c
2401 //
2402
2403 struct buffer_head *ext3_append(struct ext2_icb *icb, struct inode *inode,
2404 ext3_lblk_t *block, int *err);
2405
2406 void ext3_set_de_type(struct super_block *sb,
2407 struct ext3_dir_entry_2 *de,
2408 umode_t mode);
2409
2410 __u32 ext3_current_time(struct inode *in);
2411 void ext3_warning (struct super_block * sb, const char * function,
2412 char * fmt, ...);
2413 #define ext3_error ext3_warning
2414 #define ext4_error ext3_error
2415
2416 void ext3_update_dx_flag(struct inode *inode);
2417 int ext3_mark_inode_dirty(struct ext2_icb *icb, struct inode *in);
2418
2419 void ext3_inc_count(struct inode *inode);
2420 void ext3_dec_count(struct inode *inode);
2421
2422 struct buffer_head *
2423 ext3_find_entry (struct ext2_icb *icb, struct dentry *dentry,
2424 struct ext3_dir_entry_2 ** res_dir);
2425 struct buffer_head *
2426 ext3_dx_find_entry(struct ext2_icb *, struct dentry *dentry,
2427 struct ext3_dir_entry_2 **res_dir, int *err);
2428
2429 typedef int (*filldir_t)(void *, const char *, int, unsigned long, __u32, unsigned);
2430 int ext3_dx_readdir(struct file *filp, filldir_t filldir, void * context);
2431
2432 struct buffer_head *ext3_bread(struct ext2_icb *icb, struct inode *inode,
2433 unsigned long block, int *err);
2434 int add_dirent_to_buf(struct ext2_icb *icb, struct dentry *dentry,
2435 struct inode *inode, struct ext3_dir_entry_2 *de,
2436 struct buffer_head *bh);
2437 #if !defined(__REACTOS__) || defined(_MSC_VER)
2438 struct ext3_dir_entry_2 *
2439 do_split(struct ext2_icb *icb, struct inode *dir,
2440 struct buffer_head **bh,struct dx_frame *frame,
2441 struct dx_hash_info *hinfo, int *error);
2442 #endif
2443
2444 int ext3_add_entry(struct ext2_icb *icb, struct dentry *dentry, struct inode *inode);
2445
2446 int ext3_delete_entry(struct ext2_icb *icb, struct inode *dir,
2447 struct ext3_dir_entry_2 *de_del,
2448 struct buffer_head *bh);
2449
2450 int ext3_is_dir_empty(struct ext2_icb *icb, struct inode *inode);
2451
2452 //
2453 // Init.c
2454 //
2455
2456 NTSTATUS
2457 Ext2QueryGlobalParameters(IN PUNICODE_STRING RegistryPath);
2458 BOOLEAN
2459 Ext2QueryRegistrySettings(IN PUNICODE_STRING RegistryPath);
2460
2461 VOID NTAPI
2462 DriverUnload (IN PDRIVER_OBJECT DriverObject);
2463
2464 //
2465 // Indirect.c
2466 //
2467
2468 NTSTATUS
2469 Ext2MapIndirect(
2470 IN PEXT2_IRP_CONTEXT IrpContext,
2471 IN PEXT2_VCB Vcb,
2472 IN PEXT2_MCB Mcb,
2473 IN ULONG Index,
2474 IN BOOLEAN bAlloc,
2475 OUT PULONG pBlock,
2476 OUT PULONG Number
2477 );
2478
2479 NTSTATUS
2480 Ext2ExpandIndirect(
2481 PEXT2_IRP_CONTEXT IrpContext,
2482 PEXT2_VCB Vcb,
2483 PEXT2_MCB Mcb,
2484 ULONG Start,
2485 ULONG End,
2486 PLARGE_INTEGER Size
2487 );
2488
2489 NTSTATUS
2490 Ext2TruncateIndirect(
2491 PEXT2_IRP_CONTEXT IrpContext,
2492 PEXT2_VCB Vcb,
2493 PEXT2_MCB Mcb,
2494 PLARGE_INTEGER Size
2495 );
2496
2497
2498 //
2499 // linux.c: linux lib implemenation
2500 //
2501
2502 int
2503 ext2_init_linux();
2504
2505 void
2506 ext2_destroy_linux();
2507
2508
2509 //
2510 // Lock.c
2511 //
2512
2513 NTSTATUS
2514 Ext2LockControl (IN PEXT2_IRP_CONTEXT IrpContext);
2515
2516
2517 //
2518 // Memory.c
2519 //
2520
2521 VOID
2522 NTAPI
2523 Ext2FcbReaperThread(
2524 PVOID Context
2525 );
2526
2527 VOID
2528 NTAPI
2529 Ext2McbReaperThread(
2530 PVOID Context
2531 );
2532
2533 VOID
2534 NTAPI
2535 Ext2bhReaperThread(
2536 PVOID Context
2537 );
2538
2539
2540 PEXT2_IRP_CONTEXT
2541 Ext2AllocateIrpContext (IN PDEVICE_OBJECT DeviceObject,
2542 IN PIRP Irp );
2543
2544 VOID
2545 Ext2FreeIrpContext (IN PEXT2_IRP_CONTEXT IrpContext);
2546
2547
2548 PEXT2_FCB
2549 Ext2AllocateFcb (
2550 IN PEXT2_VCB Vcb,
2551 IN PEXT2_MCB Mcb
2552 );
2553
2554 VOID
2555 Ext2UnlinkFcb(IN PEXT2_FCB Fcb);
2556
2557 VOID
2558 Ext2FreeFcb (IN PEXT2_FCB Fcb);
2559 VOID
2560 Ext2ReleaseFcb (IN PEXT2_FCB Fcb);
2561
2562 VOID
2563 Ext2InsertFcb(PEXT2_VCB Vcb, PEXT2_FCB Fcb);
2564
2565 PEXT2_CCB
2566 Ext2AllocateCcb (ULONG Flags, PEXT2_MCB SymLink);
2567
2568 VOID
2569 Ext2FreeMcb (
2570 IN PEXT2_VCB Vcb,
2571 IN PEXT2_MCB Mcb
2572 );
2573
2574 VOID
2575 Ext2FreeCcb (IN PEXT2_VCB Vcb, IN PEXT2_CCB Ccb);
2576
2577 PEXT2_INODE
2578 Ext2AllocateInode (PEXT2_VCB Vcb);
2579
2580 VOID
2581 Ext2DestroyInode (IN PEXT2_VCB Vcb, IN PEXT2_INODE inode);
2582
2583 struct dentry * Ext2AllocateEntry();
2584 VOID Ext2FreeEntry (IN struct dentry *de);
2585 struct dentry *Ext2BuildEntry(PEXT2_VCB Vcb, PEXT2_MCB Dcb, PUNICODE_STRING FileName);
2586
2587 PEXT2_EXTENT
2588 Ext2AllocateExtent();
2589
2590 VOID
2591 Ext2FreeExtent (IN PEXT2_EXTENT Extent);
2592
2593 ULONG
2594 Ext2CountExtents(IN PEXT2_EXTENT Chain);
2595
2596 VOID
2597 Ext2JointExtents(
2598 IN PEXT2_EXTENT Chain,
2599 IN PEXT2_EXTENT Extent
2600 );
2601
2602 VOID
2603 Ext2DestroyExtentChain(IN PEXT2_EXTENT Chain);
2604
2605 NTSTATUS
2606 Ext2BuildExtents(
2607 IN PEXT2_IRP_CONTEXT IrpContext,
2608 IN PEXT2_VCB Vcb,
2609 IN PEXT2_MCB Mcb,
2610 IN ULONGLONG Offset,
2611 IN ULONG Size,
2612 IN BOOLEAN bAlloc,
2613 OUT PEXT2_EXTENT * Chain
2614 );
2615
2616 BOOLEAN
2617 Ext2ListExtents(PLARGE_MCB Extents);
2618
2619 VOID
2620 Ext2CheckExtent(
2621 PLARGE_MCB Zone,
2622 LONGLONG Vbn,
2623 LONGLONG Lbn,
2624 LONGLONG Length,
2625 BOOLEAN bAdded
2626 );
2627
2628 VOID
2629 Ext2ClearAllExtents(PLARGE_MCB Zone);
2630
2631 BOOLEAN
2632 Ext2AddVcbExtent (
2633 IN PEXT2_VCB Vcb,
2634 IN LONGLONG Vbn,
2635 IN LONGLONG Length
2636 );
2637
2638 BOOLEAN
2639 Ext2RemoveVcbExtent (
2640 IN PEXT2_VCB Vcb,
2641 IN LONGLONG Vbn,
2642 IN LONGLONG Length
2643 );
2644
2645 BOOLEAN
2646 Ext2LookupVcbExtent (
2647 IN PEXT2_VCB Vcb,
2648 IN LONGLONG Vbn,
2649 OUT PLONGLONG Lbn,
2650 OUT PLONGLONG Length
2651 );
2652
2653 BOOLEAN
2654 Ext2AddMcbExtent (
2655 IN PEXT2_VCB Vcb,
2656 IN PEXT2_MCB Mcb,
2657 IN LONGLONG Vbn,
2658 IN LONGLONG Lbn,
2659 IN LONGLONG Length
2660 );
2661
2662 BOOLEAN
2663 Ext2RemoveMcbExtent (
2664 IN PEXT2_VCB Vcb,
2665 IN PEXT2_MCB Mcb,
2666 IN LONGLONG Vbn,
2667 IN LONGLONG Length
2668 );
2669
2670 BOOLEAN
2671 Ext2LookupMcbExtent (
2672 IN PEXT2_VCB Vcb,
2673 IN PEXT2_MCB Mcb,
2674 IN LONGLONG Vbn,
2675 OUT PLONGLONG Lbn,
2676 OUT PLONGLONG Length
2677 );
2678
2679 BOOLEAN
2680 Ext2AddMcbMetaExts (
2681 IN PEXT2_VCB Vcb,
2682 IN PEXT2_MCB Mcb,
2683 IN ULONG Block,
2684 IN ULONG Length
2685 );
2686
2687 BOOLEAN
2688 Ext2RemoveMcbMetaExts (
2689 IN PEXT2_VCB Vcb,
2690 IN PEXT2_MCB Mcb,
2691 IN ULONG Block,
2692 IN ULONG Length
2693 );
2694
2695 BOOLEAN
2696 Ext2AddBlockExtent(
2697 IN PEXT2_VCB Vcb,
2698 IN PEXT2_MCB Mcb,
2699 IN ULONG Start,
2700 IN ULONG Block,
2701 IN ULONG Number
2702 );
2703
2704 BOOLEAN
2705 Ext2LookupBlockExtent(
2706 IN PEXT2_VCB Vcb,
2707 IN PEXT2_MCB Mcb,
2708 IN ULONG Start,
2709 IN PULONG Block,
2710 IN PULONG Mapped
2711 );
2712
2713 BOOLEAN
2714 Ext2RemoveBlockExtent(
2715 IN PEXT2_VCB Vcb,
2716 IN PEXT2_MCB Mcb,
2717 IN ULONG Start,
2718 IN ULONG Number
2719 );
2720
2721 NTSTATUS
2722 Ext2InitializeZone(
2723 IN PEXT2_IRP_CONTEXT IrpContext,
2724 IN PEXT2_VCB Vcb,
2725 IN PEXT2_MCB Mcb
2726 );
2727
2728 BOOLEAN
2729 Ext2BuildName(
2730 IN OUT PUNICODE_STRING Target,
2731 IN PUNICODE_STRING File,
2732 IN PUNICODE_STRING Parent
2733 );
2734
2735
2736 PEXT2_MCB
2737 Ext2AllocateMcb (
2738 IN PEXT2_VCB Vcb,
2739 IN PUNICODE_STRING FileName,
2740 IN PUNICODE_STRING Parent,
2741 IN ULONG FileAttr
2742 );
2743
2744 PEXT2_MCB
2745 Ext2SearchMcb(
2746 PEXT2_VCB Vcb,
2747 PEXT2_MCB Parent,
2748 PUNICODE_STRING FileName
2749 );
2750
2751 PEXT2_MCB
2752 Ext2SearchMcbWithoutLock(
2753 PEXT2_MCB Parent,
2754 PUNICODE_STRING FileName
2755 );
2756
2757 VOID
2758 Ext2InsertMcb(
2759 PEXT2_VCB Vcb,
2760 PEXT2_MCB Parent,
2761 PEXT2_MCB Child
2762 );
2763
2764 BOOLEAN
2765 Ext2RemoveMcb(
2766 PEXT2_VCB Vcb,
2767 PEXT2_MCB Mcb
2768 );
2769
2770 VOID
2771 Ext2CleanupAllMcbs(
2772 PEXT2_VCB Vcb
2773 );
2774
2775 BOOLEAN
2776 Ext2CheckSetBlock(
2777 PEXT2_IRP_CONTEXT IrpContext,
2778 PEXT2_VCB Vcb, LONGLONG Block
2779 );
2780
2781 BOOLEAN
2782 Ext2CheckBitmapConsistency(
2783 PEXT2_IRP_CONTEXT IrpContext,
2784 PEXT2_VCB Vcb
2785 );
2786
2787 VOID
2788 Ext2InsertVcb(PEXT2_VCB Vcb);
2789
2790 VOID
2791 Ext2RemoveVcb(PEXT2_VCB Vcb);
2792
2793 NTSTATUS
2794 Ext2InitializeLabel(
2795 IN PEXT2_VCB Vcb,
2796 IN PEXT2_SUPER_BLOCK Sb
2797 );
2798
2799 NTSTATUS
2800 Ext2InitializeVcb(
2801 PEXT2_IRP_CONTEXT IrpContext,
2802 PEXT2_VCB Vcb,
2803 PEXT2_SUPER_BLOCK Ext2Sb,
2804 PDEVICE_OBJECT TargetDevice,
2805 PDEVICE_OBJECT VolumeDevice,
2806 PVPB Vpb );
2807
2808 VOID
2809 Ext2TearDownStream (IN PEXT2_VCB Vcb);
2810
2811 VOID
2812 Ext2DestroyVcb (IN PEXT2_VCB Vcb);
2813
2814 NTSTATUS
2815 Ext2CompleteIrpContext (
2816 IN PEXT2_IRP_CONTEXT IrpContext,
2817 IN NTSTATUS Status );
2818
2819 VOID
2820 Ext2SyncUninitializeCacheMap (
2821 IN PFILE_OBJECT FileObject );
2822
2823 VOID
2824 Ext2LinkTailMcb(PEXT2_VCB Vcb, PEXT2_MCB Mcb);
2825
2826
2827 VOID
2828 Ext2LinkHeadMcb(PEXT2_VCB Vcb, PEXT2_MCB Mcb);
2829
2830 VOID
2831 Ext2UnlinkMcb(PEXT2_VCB Vcb, PEXT2_MCB Mcb);
2832
2833 PEXT2_MCB
2834 Ext2FirstUnusedMcb(
2835 PEXT2_VCB Vcb,
2836 BOOLEAN Wait,
2837 ULONG Number
2838 );
2839
2840 VOID NTAPI
2841 Ext2ReaperThread(
2842 PVOID Context
2843 );
2844
2845 NTSTATUS
2846 Ext2StartReaper(PEXT2_REAPER, EXT2_REAPER_RELEASE);
2847 VOID
2848 NTAPI
2849 Ext2StopReaper(PEXT2_REAPER Reaper);
2850
2851 //
2852 // Misc.c
2853 //
2854
2855 ULONG
2856 Ext2Log2(ULONG Value);
2857
2858 LARGE_INTEGER
2859 Ext2NtTime (IN ULONG i_time);
2860
2861 ULONG
2862 Ext2LinuxTime (IN LARGE_INTEGER SysTime);
2863
2864 ULONG
2865 Ext2OEMToUnicodeSize(
2866 IN PEXT2_VCB Vcb,
2867 IN PANSI_STRING Oem
2868 );
2869
2870 NTSTATUS
2871 Ext2OEMToUnicode(
2872 IN PEXT2_VCB Vcb,
2873 IN OUT PUNICODE_STRING Oem,
2874 IN POEM_STRING Unicode
2875 );
2876
2877 ULONG
2878 Ext2UnicodeToOEMSize(
2879 IN PEXT2_VCB Vcb,
2880 IN PUNICODE_STRING Unicode
2881 );
2882
2883 NTSTATUS
2884 Ext2UnicodeToOEM (
2885 IN PEXT2_VCB Vcb,
2886 IN OUT POEM_STRING Oem,
2887 IN PUNICODE_STRING Unicode
2888 );
2889
2890 VOID
2891 Ext2Sleep(ULONG ms);
2892
2893 int Ext2LinuxError (NTSTATUS Status);
2894 NTSTATUS Ext2WinntError(int rc);
2895
2896 BOOLEAN Ext2IsDot(PUNICODE_STRING name);
2897 BOOLEAN Ext2IsDotDot(PUNICODE_STRING name);
2898 //
2899 // nls/nls_rtl.c
2900 //
2901
2902 int
2903 Ext2LoadAllNls();
2904
2905 VOID
2906 Ext2UnloadAllNls();
2907
2908 //
2909 // Pnp.c
2910 //
2911
2912 NTSTATUS
2913 Ext2Pnp(IN PEXT2_IRP_CONTEXT IrpContext);
2914
2915 NTSTATUS
2916 Ext2PnpQueryRemove(
2917 PEXT2_IRP_CONTEXT IrpContext,
2918 PEXT2_VCB Vcb );
2919
2920 NTSTATUS
2921 Ext2PnpRemove(
2922 PEXT2_IRP_CONTEXT IrpContext,
2923 PEXT2_VCB Vcb );
2924
2925 NTSTATUS
2926 Ext2PnpCancelRemove(
2927 PEXT2_IRP_CONTEXT IrpContext,
2928 PEXT2_VCB Vcb );
2929
2930 NTSTATUS
2931 Ext2PnpSurpriseRemove(
2932 PEXT2_IRP_CONTEXT IrpContext,
2933 PEXT2_VCB Vcb );
2934
2935
2936 //
2937 // Read.c
2938 //
2939
2940 NTSTATUS
2941 Ext2ReadInode (
2942 IN PEXT2_IRP_CONTEXT IrpContext,
2943 IN PEXT2_VCB Vcb,
2944 IN PEXT2_MCB Mcb,
2945 IN ULONGLONG Offset,
2946 IN PVOID Buffer,
2947 IN ULONG Size,
2948 IN BOOLEAN bDirectIo,
2949 OUT PULONG dwReturn
2950 );
2951
2952 NTSTATUS
2953 Ext2Read (IN PEXT2_IRP_CONTEXT IrpContext);
2954
2955
2956 //
2957 // ext3\recover.c
2958 //
2959
2960 PEXT2_MCB
2961 Ext2LoadInternalJournal(
2962 PEXT2_VCB Vcb,
2963 ULONG jNo
2964 );
2965
2966 INT
2967 Ext2CheckJournal(
2968 PEXT2_VCB Vcb,
2969 PULONG jNo
2970 );
2971
2972 INT
2973 Ext2RecoverJournal(
2974 PEXT2_IRP_CONTEXT IrpContext,
2975 PEXT2_VCB Vcb
2976 );
2977
2978 //
2979 // Shutdown.c
2980 //
2981
2982
2983 NTSTATUS
2984 Ext2ShutDown (IN PEXT2_IRP_CONTEXT IrpContext);
2985
2986
2987 //
2988 // Volinfo.c
2989 //
2990
2991 NTSTATUS
2992 Ext2QueryVolumeInformation (IN PEXT2_IRP_CONTEXT IrpContext);
2993
2994 NTSTATUS
2995 Ext2SetVolumeInformation (IN PEXT2_IRP_CONTEXT IrpContext);
2996
2997 //
2998 // Write.c
2999 //
3000
3001 typedef struct _EXT2_RW_CONTEXT {
3002 PIRP MasterIrp;
3003 KEVENT Event;
3004 ULONG Blocks;
3005 ULONG Length;
3006 PERESOURCE Resource;
3007 ERESOURCE_THREAD ThreadId;
3008 PFILE_OBJECT FileObject;
3009 ULONG Flags;
3010 BOOLEAN Wait;
3011
3012 } EXT2_RW_CONTEXT, *PEXT2_RW_CONTEXT;
3013
3014 #define EXT2_RW_CONTEXT_WRITE 1
3015
3016 NTSTATUS
3017 Ext2WriteInode (
3018 IN PEXT2_IRP_CONTEXT IrpContext,
3019 IN PEXT2_VCB Vcb,
3020 IN PEXT2_MCB Mcb,
3021 IN ULONGLONG Offset,
3022 IN PVOID Buffer,
3023 IN ULONG Size,
3024 IN BOOLEAN bDirectIo,
3025 OUT PULONG dwReturn
3026 );
3027
3028
3029 VOID
3030 Ext2StartFloppyFlushDpc (
3031 PEXT2_VCB Vcb,
3032 PEXT2_FCB Fcb,
3033 PFILE_OBJECT FileObject );
3034
3035 BOOLEAN
3036 Ext2ZeroData (
3037 IN PEXT2_IRP_CONTEXT IrpContext,
3038 IN PEXT2_VCB Vcb,
3039 IN PFILE_OBJECT FileObject,
3040 IN PLARGE_INTEGER Start,
3041 IN PLARGE_INTEGER End );
3042
3043 NTSTATUS
3044 Ext2Write (IN PEXT2_IRP_CONTEXT IrpContext);
3045
3046 #endif /* _EXT2_HEADER_ */