[NTFS]
[reactos.git] / 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_RO_COMPAT_READ_ONLY 0x01000000
793 #define VCB_READ_ONLY 0x08000000
794 #define VCB_WRITE_PROTECTED 0x10000000
795 #define VCB_FLOPPY_DISK 0x20000000
796 #define VCB_REMOVAL_PREVENTED 0x40000000
797 #define VCB_REMOVABLE_MEDIA 0x80000000
798
799
800 #define IsVcbInited(Vcb) (IsFlagOn((Vcb)->Flags, VCB_INITIALIZED))
801 #define IsMounted(Vcb) (IsFlagOn((Vcb)->Flags, VCB_MOUNTED))
802 #define IsDispending(Vcb) (IsFlagOn((Vcb)->Flags, VCB_DISMOUNT_PENDING))
803 #define IsVcbReadOnly(Vcb) (IsFlagOn((Vcb)->Flags, VCB_READ_ONLY) || \
804 IsFlagOn((Vcb)->Flags, VCB_RO_COMPAT_READ_ONLY) || \
805 IsFlagOn((Vcb)->Flags, VCB_WRITE_PROTECTED))
806
807
808 #define IsExt3ForceWrite() (IsFlagOn(Ext2Global->Flags, EXT3_FORCE_WRITING))
809 #define IsVcbForceWrite(Vcb) (IsFlagOn((Vcb)->Flags, VCB_FORCE_WRITING))
810 #define CanIWrite(Vcb) (IsExt3ForceWrite() || (!IsVcbReadOnly(Vcb) && IsVcbForceWrite(Vcb)))
811 #define IsLazyWriter(Fcb) ((Fcb)->LazyWriterThread == PsGetCurrentThread())
812 //
813 // EXT2_FCB File Control Block
814 //
815 // Data that represents an open file
816 // There is a single instance of the FCB for every open file
817 //
818 typedef struct _EXT2_FCB {
819
820 /* Common header */
821 EXT2_FCBVCB;
822
823 // List of FCBs for this volume
824 LIST_ENTRY Next;
825 LARGE_INTEGER TsDrop; /* drop time */
826
827 SECTION_OBJECT_POINTERS SectionObject;
828
829 // Share Access for the file object
830 SHARE_ACCESS ShareAccess;
831
832 // List of byte-range locks for this file
833 FILE_LOCK FileLockAnchor;
834
835 // oplock information management structure
836 OPLOCK Oplock;
837
838 // Lazy writer thread context
839 PETHREAD LazyWriterThread;
840
841 // Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLEANUP
842 ULONG OpenHandleCount;
843
844 // Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLOSE
845 ULONG ReferenceCount;
846
847 // Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLEANUP
848 // But only for Files with FO_NO_INTERMEDIATE_BUFFERING flag
849 ULONG NonCachedOpenCount;
850
851 // Flags for the FCB
852 ULONG Flags;
853
854 // Pointer to the inode
855 struct inode *Inode;
856
857 // Vcb
858 PEXT2_VCB Vcb;
859
860 // Mcb Node ...
861 PEXT2_MCB Mcb;
862
863 } EXT2_FCB, *PEXT2_FCB;
864
865 //
866 // Flags for EXT2_FCB
867 //
868
869 #define FCB_FROM_POOL 0x00000001
870 #define FCB_PAGE_FILE 0x00000002
871 #define FCB_FILE_MODIFIED 0x00000020
872
873 #define FCB_ALLOC_IN_CREATE 0x00000080
874 #define FCB_ALLOC_IN_WRITE 0x00000100
875 #define FCB_ALLOC_IN_SETINFO 0x00000200
876
877 #define FCB_DELETE_PENDING 0x80000000
878
879 //
880 // Mcb Node
881 //
882
883 struct _EXT2_MCB {
884
885 // Identifier for this structure
886 EXT2_IDENTIFIER Identifier;
887
888 // Flags
889 ULONG Flags;
890
891 // Link List Info
892 PEXT2_MCB Parent; // Parent
893 PEXT2_MCB Next; // Siblings
894
895 union {
896 PEXT2_MCB Child; // Children Mcb nodes
897 PEXT2_MCB Target; // Target Mcb of symlink
898 };
899
900 // Mcb Node Info
901
902 // -> Fcb
903 PEXT2_FCB Fcb;
904
905 // Short name
906 UNICODE_STRING ShortName;
907
908 // Full name with path
909 UNICODE_STRING FullName;
910
911 // File attribute
912 ULONG FileAttr;
913
914 // reference count
915 ULONG Refercount;
916
917 // Extents zone
918 LARGE_MCB Extents;
919
920 // Metablocks
921 LARGE_MCB MetaExts;
922
923 // Time stamps
924 LARGE_INTEGER CreationTime;
925 LARGE_INTEGER LastWriteTime;
926 LARGE_INTEGER ChangeTime;
927 LARGE_INTEGER LastAccessTime;
928
929 // List Link to Vcb->McbList
930 LIST_ENTRY Link;
931
932 struct inode Inode;
933 struct dentry *de;
934 };
935
936 //
937 // Flags for MCB
938 //
939 #define MCB_FROM_POOL 0x00000001
940 #define MCB_VCB_LINK 0x00000002
941 #define MCB_ENTRY_TREE 0x00000004
942 #define MCB_FILE_DELETED 0x00000008
943
944 #define MCB_ZONE_INITED 0x20000000
945 #define MCB_TYPE_SPECIAL 0x40000000 /* unresolved symlink + device node */
946 #define MCB_TYPE_SYMLINK 0x80000000
947
948 #define IsMcbUsed(Mcb) ((Mcb)->Refercount > 0)
949 #define IsMcbSymLink(Mcb) IsFlagOn((Mcb)->Flags, MCB_TYPE_SYMLINK)
950 #define IsZoneInited(Mcb) IsFlagOn((Mcb)->Flags, MCB_ZONE_INITED)
951 #define IsMcbSpecialFile(Mcb) IsFlagOn((Mcb)->Flags, MCB_TYPE_SPECIAL)
952 #define IsMcbRoot(Mcb) ((Mcb)->Inode.i_ino == EXT2_ROOT_INO)
953 #define IsMcbReadonly(Mcb) IsFlagOn((Mcb)->FileAttr, FILE_ATTRIBUTE_READONLY)
954 #define IsMcbDirectory(Mcb) IsFlagOn((Mcb)->FileAttr, FILE_ATTRIBUTE_DIRECTORY)
955 #define IsFileDeleted(Mcb) IsFlagOn((Mcb)->Flags, MCB_FILE_DELETED)
956
957 #define IsLinkInvalid(Mcb) (IsMcbSymLink(Mcb) && IsFileDeleted(Mcb->Target))
958
959 /*
960 * routines for reference count management
961 */
962
963 #define Ext2ReferXcb(_C) InterlockedIncrement(_C)
964 #define Ext2DerefXcb(_C) DEC_OBJ_CNT(_C)
965
966 #ifdef __REACTOS__
967 static
968 #endif
969 __inline ULONG DEC_OBJ_CNT(PULONG _C) {
970 if (*_C <= 0) {
971 DbgBreak();
972 }
973 return InterlockedDecrement(_C);
974 }
975
976 #if EXT2_DEBUG
977 VOID
978 Ext2TraceMcb(PCHAR fn, USHORT lc, USHORT add, PEXT2_MCB Mcb);
979 #define Ext2ReferMcb(Mcb) Ext2TraceMcb(__FUNCTION__, __LINE__, TRUE, Mcb)
980 #define Ext2DerefMcb(Mcb) Ext2TraceMcb(__FUNCTION__, __LINE__, FALSE, Mcb)
981 #else
982 #define Ext2ReferMcb(Mcb) Ext2ReferXcb(&Mcb->Refercount)
983 #define Ext2DerefMcb(Mcb) Ext2DerefXcb(&Mcb->Refercount)
984 #endif
985
986 //
987 // EXT2_CCB Context Control Block
988 //
989 // Data that represents one instance of an open file
990 // There is one instance of the CCB for every instance of an open file
991 //
992 typedef struct _EXT2_CCB {
993
994 // Identifier for this structure
995 EXT2_IDENTIFIER Identifier;
996
997 // Flags
998 ULONG Flags;
999
1000 // Mcb of it's symbol link
1001 PEXT2_MCB SymLink;
1002
1003 // State that may need to be maintained
1004 UNICODE_STRING DirectorySearchPattern;
1005
1006 /* Open handle control block */
1007 struct file filp;
1008
1009 } EXT2_CCB, *PEXT2_CCB;
1010
1011 //
1012 // Flags for CCB
1013 //
1014
1015 #define CCB_FROM_POOL 0x00000001
1016 #define CCB_VOLUME_DASD_PURGE 0x00000002
1017 #define CCB_LAST_WRITE_UPDATED 0x00000004
1018 #define CCB_OPEN_REPARSE_POINT 0x00000008
1019 #define CCB_DELETE_ON_CLOSE 0x00000010
1020
1021 #define CCB_ALLOW_EXTENDED_DASD_IO 0x80000000
1022
1023 //
1024 // EXT2_IRP_CONTEXT
1025 //
1026 // Used to pass information about a request between the drivers functions
1027 //
1028 typedef struct ext2_icb {
1029
1030 // Identifier for this structure
1031 EXT2_IDENTIFIER Identifier;
1032
1033 // Pointer to the IRP this request describes
1034 PIRP Irp;
1035
1036 // Flags
1037 ULONG Flags;
1038
1039 // The major and minor function code for the request
1040 UCHAR MajorFunction;
1041 UCHAR MinorFunction;
1042
1043 // The device object
1044 PDEVICE_OBJECT DeviceObject;
1045
1046 // The real device object
1047 PDEVICE_OBJECT RealDevice;
1048
1049 // The file object
1050 PFILE_OBJECT FileObject;
1051
1052 PEXT2_FCB Fcb;
1053 PEXT2_CCB Ccb;
1054
1055 // If the request is top level
1056 BOOLEAN IsTopLevel;
1057
1058 // Used if the request needs to be queued for later processing
1059 WORK_QUEUE_ITEM WorkQueueItem;
1060
1061 // If an exception is currently in progress
1062 BOOLEAN ExceptionInProgress;
1063
1064 // The exception code when an exception is in progress
1065 NTSTATUS ExceptionCode;
1066
1067 } EXT2_IRP_CONTEXT, *PEXT2_IRP_CONTEXT;
1068
1069
1070 #define IRP_CONTEXT_FLAG_FROM_POOL (0x00000001)
1071 #define IRP_CONTEXT_FLAG_WAIT (0x00000002)
1072 #define IRP_CONTEXT_FLAG_WRITE_THROUGH (0x00000004)
1073 #define IRP_CONTEXT_FLAG_FLOPPY (0x00000008)
1074 #define IRP_CONTEXT_FLAG_DISABLE_POPUPS (0x00000020)
1075 #define IRP_CONTEXT_FLAG_DEFERRED (0x00000040)
1076 #define IRP_CONTEXT_FLAG_VERIFY_READ (0x00000080)
1077 #define IRP_CONTEXT_STACK_IO_CONTEXT (0x00000100)
1078 #define IRP_CONTEXT_FLAG_REQUEUED (0x00000200)
1079 #define IRP_CONTEXT_FLAG_USER_IO (0x00000400)
1080 #define IRP_CONTEXT_FLAG_DELAY_CLOSE (0x00000800)
1081 #define IRP_CONTEXT_FLAG_FILE_BUSY (0x00001000)
1082
1083
1084 #define Ext2CanIWait() (!IrpContext || IsFlagOn(IrpContext->Flags, IRP_CONTEXT_FLAG_WAIT))
1085
1086 //
1087 // EXT2_ALLOC_HEADER
1088 //
1089 // In the checked version of the driver this header is put in the beginning of
1090 // every memory allocation
1091 //
1092 typedef struct _EXT2_ALLOC_HEADER {
1093 EXT2_IDENTIFIER Identifier;
1094 } EXT2_ALLOC_HEADER, *PEXT2_ALLOC_HEADER;
1095
1096 typedef struct _FCB_LIST_ENTRY {
1097 PEXT2_FCB Fcb;
1098 LIST_ENTRY Next;
1099 } FCB_LIST_ENTRY, *PFCB_LIST_ENTRY;
1100
1101
1102 // Block Description List
1103 typedef struct _EXT2_EXTENT {
1104 LONGLONG Lba;
1105 ULONG Offset;
1106 ULONG Length;
1107 PIRP Irp;
1108 struct _EXT2_EXTENT * Next;
1109 } EXT2_EXTENT, *PEXT2_EXTENT;
1110
1111
1112 /* FUNCTIONS DECLARATION *****************************************************/
1113
1114 // Include this so we don't need the latest WDK to build the driver.
1115 #ifndef FSCTL_GET_RETRIEVAL_POINTER_BASE
1116 #define FSCTL_GET_RETRIEVAL_POINTER_BASE CTL_CODE(FILE_DEVICE_FILE_SYSTEM, 141, METHOD_BUFFERED, FILE_ANY_ACCESS) // RETRIEVAL_POINTER_BASE
1117 #endif
1118
1119 //
1120 // The following macro is used to determine if an FSD thread can block
1121 // for I/O or wait for a resource. It returns TRUE if the thread can
1122 // block and FALSE otherwise. This attribute can then be used to call
1123 // the FSD & FSP common work routine with the proper wait value.
1124 //
1125
1126 #define CanExt2Wait(IRP) IoIsOperationSynchronous(Irp)
1127
1128 //
1129 // memory allocation statistics
1130 //
1131
1132 #ifdef __REACTOS__
1133 static
1134 #endif
1135 __inline
1136 VOID
1137 Ext2TraceMemory(BOOLEAN _n, int _i, PVOID _p, LONG _s)
1138 {
1139 if (_n) {
1140 InterlockedIncrement(&Ext2Global->PerfStat.Current.Slot[_i]);
1141 InterlockedIncrement(&Ext2Global->PerfStat.Total.Slot[_i]);
1142 InterlockedExchangeAdd(&Ext2Global->PerfStat.Size.Slot[_i], _s);
1143 } else {
1144 InterlockedDecrement(&Ext2Global->PerfStat.Current.Slot[_i]);
1145 InterlockedExchangeAdd(&Ext2Global->PerfStat.Size.Slot[_i], -1 * _s);
1146 }
1147 }
1148
1149 #ifdef __REACTOS__
1150 static
1151 #endif
1152 __inline
1153 VOID
1154 Ext2TraceIrpContext(BOOLEAN _n, PEXT2_IRP_CONTEXT IrpContext)
1155 {
1156 if (_n) {
1157 INC_MEM_COUNT(PS_IRP_CONTEXT, IrpContext, sizeof(EXT2_IRP_CONTEXT));
1158 InterlockedIncrement(&(Ext2Global->PerfStat.Irps[IrpContext->MajorFunction].Current));
1159 } else {
1160 DEC_MEM_COUNT(PS_IRP_CONTEXT, IrpContext, sizeof(EXT2_IRP_CONTEXT));
1161 InterlockedIncrement(&Ext2Global->PerfStat.Irps[IrpContext->MajorFunction].Processed);
1162 InterlockedDecrement(&Ext2Global->PerfStat.Irps[IrpContext->MajorFunction].Current);
1163 }
1164 }
1165
1166 typedef struct _EXT2_FILLDIR_CONTEXT {
1167 PEXT2_IRP_CONTEXT efc_irp;
1168 PUCHAR efc_buf;
1169 ULONG efc_size;
1170 ULONG efc_start;
1171 ULONG efc_prev;
1172 NTSTATUS efc_status;
1173 FILE_INFORMATION_CLASS efc_fi;
1174 BOOLEAN efc_single;
1175 } EXT2_FILLDIR_CONTEXT, *PEXT2_FILLDIR_CONTEXT;
1176
1177 //
1178 // Access.c
1179 //
1180
1181
1182 int Ext2CheckInodeAccess(PEXT2_VCB Vcb, struct inode *in, int attempt);
1183 int Ext2CheckFileAccess (PEXT2_VCB Vcb, PEXT2_MCB Mcb, int attempt);
1184
1185 //
1186 // Block.c
1187 //
1188
1189 PMDL
1190 Ext2CreateMdl (
1191 IN PVOID Buffer,
1192 IN ULONG Length,
1193 IN LOCK_OPERATION Operation
1194 );
1195
1196 VOID
1197 Ext2DestroyMdl (IN PMDL Mdl);
1198
1199 NTSTATUS
1200 Ext2LockUserBuffer (
1201 IN PIRP Irp,
1202 IN ULONG Length,
1203 IN LOCK_OPERATION Operation);
1204 PVOID
1205 Ext2GetUserBuffer (IN PIRP Irp);
1206
1207
1208 NTSTATUS
1209 Ext2ReadWriteBlocks(
1210 IN PEXT2_IRP_CONTEXT IrpContext,
1211 IN PEXT2_VCB Vcb,
1212 IN PEXT2_EXTENT Extent,
1213 IN ULONG Length
1214 );
1215
1216 NTSTATUS
1217 Ext2ReadSync(
1218 IN PEXT2_VCB Vcb,
1219 IN ULONGLONG Offset,
1220 IN ULONG Length,
1221 OUT PVOID Buffer,
1222 IN BOOLEAN bVerify );
1223
1224 NTSTATUS
1225 Ext2ReadDisk(
1226 IN PEXT2_VCB Vcb,
1227 IN ULONGLONG Offset,
1228 IN ULONG Size,
1229 IN PVOID Buffer,
1230 IN BOOLEAN bVerify );
1231
1232 NTSTATUS
1233 Ext2DiskIoControl (
1234 IN PDEVICE_OBJECT DeviceOjbect,
1235 IN ULONG IoctlCode,
1236 IN PVOID InputBuffer,
1237 IN ULONG InputBufferSize,
1238 IN OUT PVOID OutputBuffer,
1239 IN OUT PULONG OutputBufferSize );
1240
1241 VOID
1242 Ext2MediaEjectControl (
1243 IN PEXT2_IRP_CONTEXT IrpContext,
1244 IN PEXT2_VCB Vcb,
1245 IN BOOLEAN bPrevent );
1246
1247 NTSTATUS
1248 Ext2DiskShutDown(PEXT2_VCB Vcb);
1249
1250
1251 //
1252 // Cleanup.c
1253 //
1254
1255 NTSTATUS
1256 Ext2Cleanup (IN PEXT2_IRP_CONTEXT IrpContext);
1257
1258 //
1259 // Close.c
1260 //
1261
1262 NTSTATUS
1263 Ext2Close (IN PEXT2_IRP_CONTEXT IrpContext);
1264
1265 VOID
1266 Ext2QueueCloseRequest (IN PEXT2_IRP_CONTEXT IrpContext);
1267
1268 VOID NTAPI
1269 Ext2DeQueueCloseRequest (IN PVOID Context);
1270
1271 //
1272 // Cmcb.c
1273 //
1274
1275 BOOLEAN NTAPI
1276 Ext2AcquireForLazyWrite (
1277 IN PVOID Context,
1278 IN BOOLEAN Wait );
1279 VOID NTAPI
1280 Ext2ReleaseFromLazyWrite (IN PVOID Context);
1281
1282 BOOLEAN NTAPI
1283 Ext2AcquireForReadAhead (
1284 IN PVOID Context,
1285 IN BOOLEAN Wait );
1286
1287 VOID NTAPI
1288 Ext2ReleaseFromReadAhead (IN PVOID Context);
1289
1290 BOOLEAN NTAPI
1291 Ext2NoOpAcquire (
1292 IN PVOID Fcb,
1293 IN BOOLEAN Wait );
1294
1295 VOID NTAPI
1296 Ext2NoOpRelease (IN PVOID Fcb);
1297
1298 //
1299 // Create.c
1300 //
1301
1302
1303 BOOLEAN
1304 Ext2IsNameValid(PUNICODE_STRING FileName);
1305
1306 NTSTATUS
1307 Ext2FollowLink (
1308 IN PEXT2_IRP_CONTEXT IrpContext,
1309 IN PEXT2_VCB Vcb,
1310 IN PEXT2_MCB Parent,
1311 IN PEXT2_MCB Mcb,
1312 IN ULONG Linkdep
1313 );
1314
1315 NTSTATUS
1316 Ext2ScanDir (
1317 IN PEXT2_IRP_CONTEXT IrpContext,
1318 IN PEXT2_VCB Vcb,
1319 IN PEXT2_MCB Parent,
1320 IN PUNICODE_STRING FileName,
1321 OUT PULONG Inode,
1322 struct dentry **dentry
1323 );
1324
1325 BOOLEAN
1326 Ext2IsSpecialSystemFile(
1327 IN PUNICODE_STRING FileName,
1328 IN BOOLEAN bDirectory
1329 );
1330
1331 #define EXT2_LOOKUP_FLAG_MASK (0xFF00000)
1332 #define EXT2_LOOKUP_NOT_FOLLOW (0x8000000)
1333
1334 NTSTATUS
1335 Ext2LookupFile (
1336 IN PEXT2_IRP_CONTEXT IrpContext,
1337 IN PEXT2_VCB Vcb,
1338 IN PUNICODE_STRING FullName,
1339 IN PEXT2_MCB Parent,
1340 OUT PEXT2_MCB * Ext2Mcb,
1341 IN ULONG Linkdep
1342 );
1343
1344 NTSTATUS
1345 Ext2CreateFile(
1346 IN PEXT2_IRP_CONTEXT IrpContext,
1347 IN PEXT2_VCB Vcb,
1348 OUT PBOOLEAN OpPostIrp
1349 );
1350
1351 NTSTATUS
1352 Ext2CreateVolume(
1353 IN PEXT2_IRP_CONTEXT IrpContext,
1354 IN PEXT2_VCB Vcb );
1355
1356 NTSTATUS
1357 Ext2Create (IN PEXT2_IRP_CONTEXT IrpContext);
1358
1359 NTSTATUS
1360 Ext2CreateInode(
1361 IN PEXT2_IRP_CONTEXT IrpContext,
1362 IN PEXT2_VCB Vcb,
1363 IN PEXT2_FCB pParentFcb,
1364 IN ULONG Type,
1365 IN ULONG FileAttr,
1366 IN PUNICODE_STRING FileName);
1367
1368
1369 NTSTATUS
1370 Ext2SupersedeOrOverWriteFile(
1371 IN PEXT2_IRP_CONTEXT IrpContext,
1372 IN PFILE_OBJECT FileObject,
1373 IN PEXT2_VCB Vcb,
1374 IN PEXT2_FCB Fcb,
1375 IN PLARGE_INTEGER AllocationSize,
1376 IN ULONG Disposition
1377 );
1378
1379 //
1380 // Debug.c
1381 //
1382
1383 /* debug levels */
1384 #define DL_NVR 0
1385 #define DL_VIT 0x00000001
1386 #define DL_ERR 0x00000002
1387 #define DL_DBG 0x00000004
1388 #define DL_INF 0x00000008
1389 #define DL_FUN 0x00000010
1390 #define DL_LOW 0x00000020
1391 #define DL_REN 0x00000040 /* renaming operation */
1392 #define DL_RES 0x00000080 /* entry reference managment */
1393 #define DL_BLK 0x00000100 /* data block allocation / free */
1394 #define DL_CP 0x00000200 /* code pages (create, querydir) */
1395 #define DL_EXT 0x00000400 /* mcb extents */
1396 #define DL_MAP 0x00000800 /* retrieval points */
1397 #define DL_JNL 0x00001000 /* dump journal operations */
1398 #define DL_HTI 0x00002000 /* htree index */
1399 #define DL_WRN 0x00004000 /* warning */
1400 #define DL_BH 0x00008000 /* buffer head */
1401 #define DL_PNP 0x00010000 /* pnp */
1402 #define DL_IO 0x00020000 /* file i/o */
1403
1404 #define DL_DEFAULT (DL_ERR|DL_VIT)
1405
1406 #if EXT2_DEBUG
1407 extern ULONG DebugFilter;
1408
1409 VOID
1410 __cdecl
1411 Ext2NiPrintf(
1412 PCHAR DebugMessage,
1413 ...
1414 );
1415
1416 #define DEBUG(_DL, arg) do {if ((_DL) & DebugFilter) Ext2Printf arg;} while(0)
1417 #define DEBUGNI(_DL, arg) do {if ((_DL) & DebugFilter) Ext2NiPrintf arg;} while(0)
1418
1419 #define Ext2CompleteRequest(Irp, bPrint, PriorityBoost) \
1420 Ext2DbgPrintComplete(Irp, bPrint); \
1421 IoCompleteRequest(Irp, PriorityBoost)
1422
1423 #else
1424
1425 #define DEBUG(_DL, arg) do {if ((_DL) & DL_ERR) DbgPrint arg;} while(0)
1426
1427 #define Ext2CompleteRequest(Irp, bPrint, PriorityBoost) \
1428 IoCompleteRequest(Irp, PriorityBoost)
1429
1430 #endif // EXT2_DEBUG
1431
1432 VOID
1433 __cdecl
1434 Ext2Printf(
1435 PCHAR DebugMessage,
1436 ...
1437 );
1438
1439 extern ULONG ProcessNameOffset;
1440
1441 #define Ext2GetCurrentProcessName() ( \
1442 (PUCHAR) PsGetCurrentProcess() + ProcessNameOffset \
1443 )
1444
1445 ULONG
1446 Ext2GetProcessNameOffset (VOID);
1447
1448 VOID
1449 Ext2DbgPrintCall (
1450 IN PDEVICE_OBJECT DeviceObject,
1451 IN PIRP Irp );
1452
1453 VOID
1454 Ext2DbgPrintComplete (
1455 IN PIRP Irp,
1456 IN BOOLEAN bPrint
1457 );
1458
1459 PUCHAR
1460 Ext2NtStatusToString (IN NTSTATUS Status );
1461
1462 PVOID Ext2AllocatePool(
1463 IN POOL_TYPE PoolType,
1464 IN SIZE_T NumberOfBytes,
1465 IN ULONG Tag
1466 );
1467
1468 VOID
1469 Ext2FreePool(
1470 IN PVOID P,
1471 IN ULONG Tag
1472 );
1473
1474 //
1475 // Devctl.c
1476 //
1477
1478 NTSTATUS
1479 Ext2ProcessGlobalProperty(
1480 IN PDEVICE_OBJECT DeviceObject,
1481 IN PEXT2_VOLUME_PROPERTY3 Property,
1482 IN ULONG Length
1483 );
1484
1485 NTSTATUS
1486 Ext2ProcessVolumeProperty(
1487 IN PEXT2_VCB Vcb,
1488 IN PEXT2_VOLUME_PROPERTY3 Property,
1489 IN ULONG Length
1490 );
1491
1492 NTSTATUS
1493 Ext2ProcessUserProperty(
1494 IN PEXT2_IRP_CONTEXT IrpContext,
1495 IN PEXT2_VOLUME_PROPERTY3 Property,
1496 IN ULONG Length
1497 );
1498
1499 NTSTATUS
1500 Ex2ProcessUserPerfStat(
1501 IN PEXT2_IRP_CONTEXT IrpContext,
1502 IN PEXT2_QUERY_PERFSTAT QueryPerf,
1503 IN ULONG Length
1504 );
1505
1506 NTSTATUS
1507 Ex2ProcessMountPoint(
1508 IN PEXT2_IRP_CONTEXT IrpContext,
1509 IN PEXT2_MOUNT_POINT MountPoint,
1510 IN ULONG Length
1511 );
1512
1513 NTSTATUS
1514 Ext2DeviceControlNormal (IN PEXT2_IRP_CONTEXT IrpContext);
1515
1516 NTSTATUS
1517 Ext2PrepareToUnload (IN PEXT2_IRP_CONTEXT IrpContext);
1518
1519 NTSTATUS
1520 Ext2DeviceControl (IN PEXT2_IRP_CONTEXT IrpContext);
1521
1522 //
1523 // Dirctl.c
1524 //
1525
1526 ULONG
1527 Ext2GetInfoLength(IN FILE_INFORMATION_CLASS FileInformationClass);
1528
1529 NTSTATUS
1530 Ext2ProcessEntry(
1531 IN PEXT2_IRP_CONTEXT IrpContext,
1532 IN PEXT2_VCB Vcb,
1533 IN PEXT2_FCB Dcb,
1534 IN FILE_INFORMATION_CLASS FileInformationClass,
1535 IN ULONG in,
1536 IN PVOID Buffer,
1537 IN ULONG UsedLength,
1538 IN ULONG Length,
1539 IN ULONG FileIndex,
1540 IN PUNICODE_STRING pName,
1541 OUT PULONG EntrySize,
1542 IN BOOLEAN Single
1543 );
1544
1545 BOOLEAN
1546 Ext2IsWearingCloak(
1547 IN PEXT2_VCB Vcb,
1548 IN POEM_STRING OeName
1549 );
1550
1551 NTSTATUS Ext2QueryDirectory (IN PEXT2_IRP_CONTEXT IrpContext);
1552
1553 NTSTATUS
1554 Ext2NotifyChangeDirectory (
1555 IN PEXT2_IRP_CONTEXT IrpContext
1556 );
1557
1558 VOID
1559 Ext2NotifyReportChange (
1560 IN PEXT2_IRP_CONTEXT IrpContext,
1561 IN PEXT2_VCB Vcb,
1562 IN PEXT2_MCB Mcb,
1563 IN ULONG Filter,
1564 IN ULONG Action
1565 );
1566
1567 NTSTATUS
1568 Ext2DirectoryControl (IN PEXT2_IRP_CONTEXT IrpContext);
1569
1570 BOOLEAN
1571 Ext2IsDirectoryEmpty (
1572 IN PEXT2_IRP_CONTEXT IrpContext,
1573 IN PEXT2_VCB Vcb,
1574 IN PEXT2_MCB Mcb
1575 );
1576
1577 //
1578 // Dispatch.c
1579 //
1580
1581 VOID NTAPI
1582 Ext2OplockComplete (
1583 IN PVOID Context,
1584 IN PIRP Irp
1585 );
1586
1587 VOID NTAPI
1588 Ext2LockIrp (
1589 IN PVOID Context,
1590 IN PIRP Irp
1591 );
1592
1593 NTSTATUS
1594 Ext2QueueRequest (IN PEXT2_IRP_CONTEXT IrpContext);
1595
1596 VOID NTAPI
1597 Ext2DeQueueRequest (IN PVOID Context);
1598
1599 NTSTATUS
1600 Ext2DispatchRequest (IN PEXT2_IRP_CONTEXT IrpContext);
1601
1602 NTSTATUS NTAPI
1603 Ext2BuildRequest (
1604 IN PDEVICE_OBJECT DeviceObject,
1605 IN PIRP Irp
1606 );
1607
1608 //
1609 // Except.c
1610 //
1611
1612 NTSTATUS
1613 Ext2ExceptionFilter (
1614 IN PEXT2_IRP_CONTEXT IrpContext,
1615 IN PEXCEPTION_POINTERS ExceptionPointer
1616 );
1617
1618 NTSTATUS
1619 Ext2ExceptionHandler (IN PEXT2_IRP_CONTEXT IrpContext);
1620
1621
1622 //
1623 // Extents.c
1624 //
1625
1626
1627 NTSTATUS
1628 Ext2MapExtent(
1629 IN PEXT2_IRP_CONTEXT IrpContext,
1630 IN PEXT2_VCB Vcb,
1631 IN PEXT2_MCB Mcb,
1632 IN ULONG Index,
1633 IN BOOLEAN Alloc,
1634 OUT PULONG Block,
1635 OUT PULONG Number
1636 );
1637
1638 NTSTATUS
1639 Ext2ExpandExtent(
1640 PEXT2_IRP_CONTEXT IrpContext,
1641 PEXT2_VCB Vcb,
1642 PEXT2_MCB Mcb,
1643 ULONG Start,
1644 ULONG End,
1645 PLARGE_INTEGER Size
1646 );
1647
1648 NTSTATUS
1649 Ext2TruncateExtent(
1650 PEXT2_IRP_CONTEXT IrpContext,
1651 PEXT2_VCB Vcb,
1652 PEXT2_MCB Mcb,
1653 PLARGE_INTEGER Size
1654 );
1655
1656
1657 //
1658 // generic.c
1659 //
1660
1661 static inline ext3_fsblk_t ext3_blocks_count(struct ext3_super_block *es)
1662 {
1663 return ((ext3_fsblk_t)le32_to_cpu(es->s_blocks_count_hi) << 32) |
1664 le32_to_cpu(es->s_blocks_count);
1665 }
1666
1667 static inline ext3_fsblk_t ext3_r_blocks_count(struct ext3_super_block *es)
1668 {
1669 return ((ext3_fsblk_t)le32_to_cpu(es->s_r_blocks_count_hi) << 32) |
1670 le32_to_cpu(es->s_r_blocks_count);
1671 }
1672
1673 static inline ext3_fsblk_t ext3_free_blocks_count(struct ext3_super_block *es)
1674 {
1675 return ((ext3_fsblk_t)le32_to_cpu(es->s_free_blocks_count_hi) << 32) |
1676 le32_to_cpu(es->s_free_blocks_count);
1677 }
1678
1679 static inline void ext3_blocks_count_set(struct ext3_super_block *es,
1680 ext3_fsblk_t blk)
1681 {
1682 es->s_blocks_count = cpu_to_le32((u32)blk);
1683 es->s_blocks_count_hi = cpu_to_le32(blk >> 32);
1684 }
1685
1686 static inline void ext3_free_blocks_count_set(struct ext3_super_block *es,
1687 ext3_fsblk_t blk)
1688 {
1689 es->s_free_blocks_count = cpu_to_le32((u32)blk);
1690 es->s_free_blocks_count_hi = cpu_to_le32(blk >> 32);
1691 }
1692
1693 static inline void ext3_r_blocks_count_set(struct ext3_super_block *es,
1694 ext3_fsblk_t blk)
1695 {
1696 es->s_r_blocks_count = cpu_to_le32((u32)blk);
1697 es->s_r_blocks_count_hi = cpu_to_le32(blk >> 32);
1698 }
1699
1700 blkcnt_t ext3_inode_blocks(struct ext3_inode *raw_inode,
1701 struct inode *inode);
1702
1703 int ext3_inode_blocks_set(struct ext3_inode *raw_inode,
1704 struct inode * inode);
1705 ext4_fsblk_t ext4_block_bitmap(struct super_block *sb,
1706 struct ext4_group_desc *bg);
1707
1708 ext4_fsblk_t ext4_inode_bitmap(struct super_block *sb,
1709 struct ext4_group_desc *bg);
1710 ext4_fsblk_t ext4_inode_table(struct super_block *sb,
1711 struct ext4_group_desc *bg);
1712 __u32 ext4_free_blks_count(struct super_block *sb,
1713 struct ext4_group_desc *bg);
1714 __u32 ext4_free_inodes_count(struct super_block *sb,
1715 struct ext4_group_desc *bg);
1716 __u32 ext4_used_dirs_count(struct super_block *sb,
1717 struct ext4_group_desc *bg);
1718 __u32 ext4_itable_unused_count(struct super_block *sb,
1719 struct ext4_group_desc *bg);
1720 void ext4_block_bitmap_set(struct super_block *sb,
1721 struct ext4_group_desc *bg, ext4_fsblk_t blk);
1722 void ext4_inode_bitmap_set(struct super_block *sb,
1723 struct ext4_group_desc *bg, ext4_fsblk_t blk);
1724 void ext4_inode_table_set(struct super_block *sb,
1725 struct ext4_group_desc *bg, ext4_fsblk_t blk);
1726 void ext4_free_blks_set(struct super_block *sb,
1727 struct ext4_group_desc *bg, __u32 count);
1728 void ext4_free_inodes_set(struct super_block *sb,
1729 struct ext4_group_desc *bg, __u32 count);
1730 void ext4_used_dirs_set(struct super_block *sb,
1731 struct ext4_group_desc *bg, __u32 count);
1732 void ext4_itable_unused_set(struct super_block *sb,
1733 struct ext4_group_desc *bg, __u32 count);
1734
1735 int ext3_bg_has_super(struct super_block *sb, ext3_group_t group);
1736 unsigned long ext4_bg_num_gdb(struct super_block *sb, ext4_group_t group);
1737 unsigned ext4_init_inode_bitmap(struct super_block *sb, struct buffer_head *bh,
1738 ext4_group_t block_group,
1739 struct ext4_group_desc *gdp);
1740 unsigned ext4_init_block_bitmap(struct super_block *sb, struct buffer_head *bh,
1741 ext4_group_t block_group, struct ext4_group_desc *gdp);
1742 struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb,
1743 ext4_group_t block_group, struct buffer_head **bh);
1744 ext4_fsblk_t ext4_count_free_blocks(struct super_block *sb);
1745 unsigned long ext4_count_free_inodes(struct super_block *sb);
1746 int ext4_check_descriptors(struct super_block *sb);
1747
1748 NTSTATUS
1749 Ext2LoadSuper(
1750 IN PEXT2_VCB Vcb,
1751 IN BOOLEAN bVerify,
1752 OUT PEXT2_SUPER_BLOCK * Sb
1753 );
1754
1755
1756 BOOLEAN
1757 Ext2SaveSuper(
1758 IN PEXT2_IRP_CONTEXT IrpContext,
1759 IN PEXT2_VCB Vcb
1760 );
1761
1762 BOOLEAN
1763 Ext2RefreshSuper(
1764 IN PEXT2_IRP_CONTEXT IrpContext,
1765 IN PEXT2_VCB Vcb
1766 );
1767
1768 BOOLEAN
1769 Ext2LoadGroup(IN PEXT2_VCB Vcb);
1770
1771 VOID
1772 Ext2PutGroup(IN PEXT2_VCB Vcb);
1773
1774 VOID
1775 Ext2DropBH(IN PEXT2_VCB Vcb);
1776
1777 BOOLEAN
1778 Ext2SaveGroup(
1779 IN PEXT2_IRP_CONTEXT IrpContext,
1780 IN PEXT2_VCB Vcb,
1781 IN ULONG Group
1782 );
1783
1784 BOOLEAN
1785 Ext2RefreshGroup(
1786 IN PEXT2_IRP_CONTEXT IrpContext,
1787 IN PEXT2_VCB Vcb
1788 );
1789
1790 BOOLEAN
1791 Ext2GetInodeLba (
1792 IN PEXT2_VCB Vcb,
1793 IN ULONG inode,
1794 OUT PLONGLONG offset
1795 );
1796
1797 BOOLEAN
1798 Ext2LoadInode (
1799 IN PEXT2_VCB Vcb,
1800 IN struct inode *Inode
1801 );
1802
1803 BOOLEAN
1804 Ext2ClearInode (
1805 IN PEXT2_IRP_CONTEXT IrpContext,
1806 IN PEXT2_VCB Vcb,
1807 IN ULONG inode
1808 );
1809
1810 BOOLEAN
1811 Ext2SaveInode (
1812 IN PEXT2_IRP_CONTEXT IrpContext,
1813 IN PEXT2_VCB Vcb,
1814 IN struct inode *Inode
1815 );
1816
1817 BOOLEAN
1818 Ext2LoadBlock (
1819 IN PEXT2_VCB Vcb,
1820 IN ULONG dwBlk,
1821 IN PVOID Buffer
1822 );
1823
1824 BOOLEAN
1825 Ext2SaveBlock (
1826 IN PEXT2_IRP_CONTEXT IrpContext,
1827 IN PEXT2_VCB Vcb,
1828 IN ULONG dwBlk,
1829 IN PVOID Buf
1830 );
1831
1832 BOOLEAN
1833 Ext2ZeroBuffer(
1834 IN PEXT2_IRP_CONTEXT IrpContext,
1835 IN PEXT2_VCB Vcb,
1836 IN LONGLONG Offset,
1837 IN ULONG Size
1838 );
1839
1840 BOOLEAN
1841 Ext2SaveBuffer(
1842 IN PEXT2_IRP_CONTEXT IrpContext,
1843 IN PEXT2_VCB Vcb,
1844 IN LONGLONG Offset,
1845 IN ULONG Size,
1846 IN PVOID Buf
1847 );
1848
1849 NTSTATUS
1850 Ext2GetBlock(
1851 IN PEXT2_IRP_CONTEXT IrpContext,
1852 IN PEXT2_VCB Vcb,
1853 IN PEXT2_MCB Mcb,
1854 IN ULONG Base,
1855 IN ULONG Layer,
1856 IN ULONG Start,
1857 IN ULONG SizeArray,
1858 IN PULONG BlockArray,
1859 IN BOOLEAN bAlloc,
1860 IN OUT PULONG Hint,
1861 OUT PULONG Block,
1862 OUT PULONG Number
1863 );
1864
1865 NTSTATUS
1866 Ext2BlockMap(
1867 IN PEXT2_IRP_CONTEXT IrpContext,
1868 IN PEXT2_VCB Vcb,
1869 IN PEXT2_MCB Mcb,
1870 IN ULONG Index,
1871 IN BOOLEAN bAlloc,
1872 OUT PULONG pBlock,
1873 OUT PULONG Number
1874 );
1875
1876 VOID
1877 Ext2UpdateVcbStat(
1878 IN PEXT2_IRP_CONTEXT IrpContext,
1879 IN PEXT2_VCB Vcb
1880 );
1881
1882 NTSTATUS
1883 Ext2NewBlock(
1884 IN PEXT2_IRP_CONTEXT IrpContext,
1885 IN PEXT2_VCB Vcb,
1886 IN ULONG GroupHint,
1887 IN ULONG BlockHint,
1888 OUT PULONG Block,
1889 IN OUT PULONG Number
1890 );
1891
1892 NTSTATUS
1893 Ext2FreeBlock(
1894 IN PEXT2_IRP_CONTEXT IrpContext,
1895 IN PEXT2_VCB Vcb,
1896 IN ULONG Block,
1897 IN ULONG Number
1898 );
1899
1900
1901 NTSTATUS
1902 Ext2NewInode(
1903 IN PEXT2_IRP_CONTEXT IrpContext,
1904 IN PEXT2_VCB Vcb,
1905 IN ULONG GroupHint,
1906 IN ULONG Type,
1907 OUT PULONG Inode
1908 );
1909
1910 NTSTATUS
1911 Ext2UpdateGroupDirStat(
1912 IN PEXT2_IRP_CONTEXT IrpContext,
1913 IN PEXT2_VCB Vcb,
1914 IN ULONG Group
1915 );
1916
1917 NTSTATUS
1918 Ext2FreeInode(
1919 IN PEXT2_IRP_CONTEXT IrpContext,
1920 IN PEXT2_VCB Vcb,
1921 IN ULONG Inode,
1922 IN ULONG Type
1923 );
1924
1925 NTSTATUS
1926 Ext2AddEntry (
1927 IN PEXT2_IRP_CONTEXT IrpContext,
1928 IN PEXT2_VCB Vcb,
1929 IN PEXT2_FCB Dcb,
1930 IN struct inode *Inode,
1931 IN PUNICODE_STRING FileName,
1932 OUT struct dentry **dentry
1933 );
1934
1935 NTSTATUS
1936 Ext2SetFileType (
1937 IN PEXT2_IRP_CONTEXT IrpContext,
1938 IN PEXT2_VCB Vcb,
1939 IN PEXT2_FCB Dcb,
1940 IN PEXT2_MCB Mcb,
1941 IN umode_t mode
1942 );
1943
1944 NTSTATUS
1945 Ext2RemoveEntry (
1946 IN PEXT2_IRP_CONTEXT IrpContext,
1947 IN PEXT2_VCB Vcb,
1948 IN PEXT2_FCB Dcb,
1949 IN PEXT2_MCB Mcb
1950 );
1951
1952 NTSTATUS
1953 Ext2SetParentEntry (
1954 IN PEXT2_IRP_CONTEXT IrpContext,
1955 IN PEXT2_VCB Vcb,
1956 IN PEXT2_FCB Dcb,
1957 IN ULONG OldParent,
1958 IN ULONG NewParent );
1959
1960
1961 NTSTATUS
1962 Ext2TruncateBlock(
1963 IN PEXT2_IRP_CONTEXT IrpContext,
1964 IN PEXT2_VCB Vcb,
1965 IN PEXT2_MCB Mcb,
1966 IN ULONG Base,
1967 IN ULONG Start,
1968 IN ULONG Layer,
1969 IN ULONG SizeArray,
1970 IN PULONG BlockArray,
1971 IN PULONG Extra
1972 );
1973
1974 struct ext3_dir_entry_2 *ext3_next_entry(struct ext3_dir_entry_2 *p);
1975
1976 int ext3_check_dir_entry (const char * function, struct inode * dir,
1977 struct ext3_dir_entry_2 * de,
1978 struct buffer_head * bh,
1979 unsigned long offset);
1980
1981 loff_t ext3_max_size(int blkbits, int has_huge_files);
1982 loff_t ext3_max_bitmap_size(int bits, int has_huge_files);
1983
1984
1985 __le16 ext4_group_desc_csum(struct ext3_sb_info *sbi, __u32 block_group,
1986 struct ext4_group_desc *gdp);
1987 int ext4_group_desc_csum_verify(struct ext3_sb_info *sbi, __u32 block_group,
1988 struct ext4_group_desc *gdp);
1989
1990 ext3_fsblk_t descriptor_loc(struct super_block *sb,
1991 ext3_fsblk_t logical_sb_block, unsigned int nr);
1992 struct ext4_group_desc * ext4_get_group_desc(struct super_block *sb,
1993 ext4_group_t block_group, struct buffer_head **bh);
1994 int ext4_check_descriptors(struct super_block *sb);
1995
1996 //
1997 // Fastio.c
1998 //
1999
2000 FAST_IO_POSSIBLE
2001 Ext2IsFastIoPossible(
2002 IN PEXT2_FCB Fcb
2003 );
2004
2005 BOOLEAN NTAPI
2006 Ext2FastIoCheckIfPossible (
2007 IN PFILE_OBJECT FileObject,
2008 IN PLARGE_INTEGER FileOffset,
2009 IN ULONG Length,
2010 IN BOOLEAN Wait,
2011 IN ULONG LockKey,
2012 IN BOOLEAN CheckForReadOperation,
2013 OUT PIO_STATUS_BLOCK IoStatus,
2014 IN PDEVICE_OBJECT DeviceObject
2015 );
2016
2017
2018 BOOLEAN NTAPI
2019 Ext2FastIoRead (IN PFILE_OBJECT FileObject,
2020 IN PLARGE_INTEGER FileOffset,
2021 IN ULONG Length,
2022 IN BOOLEAN Wait,
2023 IN ULONG LockKey,
2024 OUT PVOID Buffer,
2025 OUT PIO_STATUS_BLOCK IoStatus,
2026 IN PDEVICE_OBJECT DeviceObject);
2027
2028 BOOLEAN NTAPI
2029 Ext2FastIoWrite (
2030 IN PFILE_OBJECT FileObject,
2031 IN PLARGE_INTEGER FileOffset,
2032 IN ULONG Length,
2033 IN BOOLEAN Wait,
2034 IN ULONG LockKey,
2035 OUT PVOID Buffer,
2036 OUT PIO_STATUS_BLOCK IoStatus,
2037 IN PDEVICE_OBJECT DeviceObject);
2038
2039 BOOLEAN NTAPI
2040 Ext2FastIoQueryBasicInfo (
2041 IN PFILE_OBJECT FileObject,
2042 IN BOOLEAN Wait,
2043 OUT PFILE_BASIC_INFORMATION Buffer,
2044 OUT PIO_STATUS_BLOCK IoStatus,
2045 IN PDEVICE_OBJECT DeviceObject);
2046
2047 BOOLEAN NTAPI
2048 Ext2FastIoQueryStandardInfo (
2049 IN PFILE_OBJECT FileObject,
2050 IN BOOLEAN Wait,
2051 OUT PFILE_STANDARD_INFORMATION Buffer,
2052 OUT PIO_STATUS_BLOCK IoStatus,
2053 IN PDEVICE_OBJECT DeviceObject);
2054
2055 BOOLEAN NTAPI
2056 Ext2FastIoLock (
2057 IN PFILE_OBJECT FileObject,
2058 IN PLARGE_INTEGER FileOffset,
2059 IN PLARGE_INTEGER Length,
2060 IN PEPROCESS Process,
2061 IN ULONG Key,
2062 IN BOOLEAN FailImmediately,
2063 IN BOOLEAN ExclusiveLock,
2064 OUT PIO_STATUS_BLOCK IoStatus,
2065 IN PDEVICE_OBJECT DeviceObject
2066 );
2067
2068 BOOLEAN NTAPI
2069 Ext2FastIoUnlockSingle (
2070 IN PFILE_OBJECT FileObject,
2071 IN PLARGE_INTEGER FileOffset,
2072 IN PLARGE_INTEGER Length,
2073 IN PEPROCESS Process,
2074 IN ULONG Key,
2075 OUT PIO_STATUS_BLOCK IoStatus,
2076 IN PDEVICE_OBJECT DeviceObject
2077 );
2078
2079 BOOLEAN NTAPI
2080 Ext2FastIoUnlockAll (
2081 IN PFILE_OBJECT FileObject,
2082 IN PEPROCESS Process,
2083 OUT PIO_STATUS_BLOCK IoStatus,
2084 IN PDEVICE_OBJECT DeviceObject
2085 );
2086
2087 BOOLEAN NTAPI
2088 Ext2FastIoUnlockAllByKey (
2089 IN PFILE_OBJECT FileObject,
2090 #ifdef __REACTOS__
2091 IN PVOID Process,
2092 #else
2093 IN PEPROCESS Process,
2094 #endif
2095 IN ULONG Key,
2096 OUT PIO_STATUS_BLOCK IoStatus,
2097 IN PDEVICE_OBJECT DeviceObject
2098 );
2099
2100
2101 BOOLEAN NTAPI
2102 Ext2FastIoQueryNetworkOpenInfo (
2103 IN PFILE_OBJECT FileObject,
2104 IN BOOLEAN Wait,
2105 OUT PFILE_NETWORK_OPEN_INFORMATION Buffer,
2106 OUT PIO_STATUS_BLOCK IoStatus,
2107 IN PDEVICE_OBJECT DeviceObject );
2108
2109 BOOLEAN NTAPI
2110 Ext2FastIoQueryNetworkOpenInfo (
2111 IN PFILE_OBJECT FileObject,
2112 IN BOOLEAN Wait,
2113 OUT PFILE_NETWORK_OPEN_INFORMATION Buffer,
2114 OUT PIO_STATUS_BLOCK IoStatus,
2115 IN PDEVICE_OBJECT DeviceObject);
2116
2117 VOID
2118 NTAPI
2119 Ext2AcquireForCreateSection (
2120 IN PFILE_OBJECT FileObject
2121 );
2122
2123 VOID
2124 NTAPI
2125 Ext2ReleaseForCreateSection (
2126 IN PFILE_OBJECT FileObject
2127 );
2128
2129 NTSTATUS
2130 NTAPI
2131 Ext2AcquireFileForModWrite (
2132 IN PFILE_OBJECT FileObject,
2133 IN PLARGE_INTEGER EndingOffset,
2134 OUT PERESOURCE *ResourceToRelease,
2135 IN PDEVICE_OBJECT DeviceObject
2136 );
2137
2138 NTSTATUS
2139 NTAPI
2140 Ext2ReleaseFileForModWrite (
2141 IN PFILE_OBJECT FileObject,
2142 IN PERESOURCE ResourceToRelease,
2143 IN PDEVICE_OBJECT DeviceObject
2144 );
2145
2146 NTSTATUS
2147 NTAPI
2148 Ext2AcquireFileForCcFlush (
2149 IN PFILE_OBJECT FileObject,
2150 IN PDEVICE_OBJECT DeviceObject
2151 );
2152
2153 NTSTATUS
2154 NTAPI
2155 Ext2ReleaseFileForCcFlush (
2156 IN PFILE_OBJECT FileObject,
2157 IN PDEVICE_OBJECT DeviceObject
2158 );
2159
2160
2161 NTSTATUS
2162 NTAPI
2163 Ext2PreAcquireForCreateSection(
2164 IN PFS_FILTER_CALLBACK_DATA cd,
2165 OUT PVOID *cc
2166 );
2167
2168 //
2169 // FileInfo.c
2170 //
2171
2172
2173 NTSTATUS
2174 Ext2QueryFileInformation (IN PEXT2_IRP_CONTEXT IrpContext);
2175
2176 NTSTATUS
2177 Ext2SetFileInformation (IN PEXT2_IRP_CONTEXT IrpContext);
2178
2179 ULONG
2180 Ext2TotalBlocks(
2181 PEXT2_VCB Vcb,
2182 PLARGE_INTEGER Size,
2183 PULONG pMeta
2184 );
2185
2186 NTSTATUS
2187 Ext2ExpandFile(
2188 PEXT2_IRP_CONTEXT IrpContext,
2189 PEXT2_VCB Vcb,
2190 PEXT2_MCB Mcb,
2191 PLARGE_INTEGER Size
2192 );
2193
2194 NTSTATUS
2195 Ext2TruncateFile (
2196 PEXT2_IRP_CONTEXT IrpContext,
2197 PEXT2_VCB Vcb,
2198 PEXT2_MCB Mcb,
2199 PLARGE_INTEGER AllocationSize );
2200
2201 NTSTATUS
2202 Ext2IsFileRemovable(
2203 IN PEXT2_IRP_CONTEXT IrpContext,
2204 IN PEXT2_VCB Vcb,
2205 IN PEXT2_FCB Fcb,
2206 IN PEXT2_CCB Ccb
2207 );
2208
2209 NTSTATUS
2210 Ext2SetDispositionInfo(
2211 PEXT2_IRP_CONTEXT IrpContext,
2212 PEXT2_VCB Vcb,
2213 PEXT2_FCB Fcb,
2214 PEXT2_CCB Ccb,
2215 BOOLEAN bDelete
2216 );
2217
2218 NTSTATUS
2219 Ext2SetRenameInfo(
2220 PEXT2_IRP_CONTEXT IrpContext,
2221 PEXT2_VCB Vcb,
2222 PEXT2_FCB Fcb,
2223 PEXT2_CCB Ccb
2224 );
2225
2226 NTSTATUS
2227 Ext2SetLinkInfo(
2228 PEXT2_IRP_CONTEXT IrpContext,
2229 PEXT2_VCB Vcb,
2230 PEXT2_FCB Fcb,
2231 PEXT2_CCB Ccb
2232 );
2233
2234 ULONG
2235 Ext2InodeType(PEXT2_MCB Mcb);
2236
2237 NTSTATUS
2238 Ext2DeleteFile(
2239 PEXT2_IRP_CONTEXT IrpContext,
2240 PEXT2_VCB Vcb,
2241 PEXT2_FCB Fcb,
2242 PEXT2_MCB Mcb
2243 );
2244
2245
2246 //
2247 // Flush.c
2248 //
2249
2250 NTSTATUS
2251 Ext2FlushFiles(
2252 IN PEXT2_IRP_CONTEXT IrpContext,
2253 IN PEXT2_VCB Vcb,
2254 IN BOOLEAN bShutDown
2255 );
2256
2257 NTSTATUS
2258 Ext2FlushVolume (
2259 IN PEXT2_IRP_CONTEXT IrpContext,
2260 IN PEXT2_VCB Vcb,
2261 IN BOOLEAN bShutDown
2262 );
2263
2264 NTSTATUS
2265 Ext2FlushFile (
2266 IN PEXT2_IRP_CONTEXT IrpContext,
2267 IN PEXT2_FCB Fcb,
2268 IN PEXT2_CCB Ccb
2269 );
2270
2271 NTSTATUS
2272 Ext2Flush (IN PEXT2_IRP_CONTEXT IrpContext);
2273
2274
2275 //
2276 // Fsctl.c
2277 //
2278
2279 NTSTATUS
2280 Ext2ReadSymlink (
2281 IN PEXT2_IRP_CONTEXT IrpContext,
2282 IN PEXT2_VCB Vcb,
2283 IN PEXT2_MCB Mcb,
2284 IN PVOID Buffer,
2285 IN ULONG Size,
2286 OUT PULONG BytesRead
2287 );
2288
2289 NTSTATUS
2290 Ext2WriteSymlink (
2291 IN PEXT2_IRP_CONTEXT IrpContext,
2292 IN PEXT2_VCB Vcb,
2293 IN PEXT2_MCB Mcb,
2294 IN PVOID Buffer,
2295 IN ULONG Size,
2296 OUT PULONG BytesWritten
2297 );
2298
2299 NTSTATUS
2300 Ext2TruncateSymlink(
2301 PEXT2_IRP_CONTEXT IrpContext,
2302 PEXT2_VCB Vcb,
2303 PEXT2_MCB Mcb,
2304 ULONG Size
2305 );
2306
2307 //
2308 // MountPoint process workitem
2309 //
2310
2311 VOID
2312 Ext2SetVpbFlag (IN PVPB Vpb,
2313 IN USHORT Flag );
2314
2315 VOID
2316 Ext2ClearVpbFlag (IN PVPB Vpb,
2317 IN USHORT Flag );
2318
2319 BOOLEAN
2320 Ext2CheckDismount (
2321 IN PEXT2_IRP_CONTEXT IrpContext,
2322 IN PEXT2_VCB Vcb,
2323 IN BOOLEAN bForce );
2324
2325 NTSTATUS
2326 Ext2PurgeVolume (IN PEXT2_VCB Vcb,
2327 IN BOOLEAN FlushBeforePurge);
2328
2329 NTSTATUS
2330 Ext2PurgeFile (IN PEXT2_FCB Fcb,
2331 IN BOOLEAN FlushBeforePurge);
2332
2333 BOOLEAN
2334 Ext2IsHandleCountZero(IN PEXT2_VCB Vcb);
2335
2336 NTSTATUS
2337 Ext2LockVcb (IN PEXT2_VCB Vcb,
2338 IN PFILE_OBJECT FileObject);
2339
2340 NTSTATUS
2341 Ext2LockVolume (IN PEXT2_IRP_CONTEXT IrpContext);
2342
2343 NTSTATUS
2344 Ext2UnlockVcb (IN PEXT2_VCB Vcb,
2345 IN PFILE_OBJECT FileObject);
2346
2347 NTSTATUS
2348 Ext2UnlockVolume (IN PEXT2_IRP_CONTEXT IrpContext);
2349
2350 NTSTATUS
2351 Ext2AllowExtendedDasdIo(IN PEXT2_IRP_CONTEXT IrpContext);
2352
2353 NTSTATUS
2354 Ext2OplockRequest (IN PEXT2_IRP_CONTEXT IrpContext);
2355
2356 NTSTATUS
2357 Ext2QueryExtentMappings(
2358 IN PEXT2_IRP_CONTEXT IrpContext,
2359 IN PEXT2_VCB Vcb,
2360 IN PEXT2_FCB Fcb,
2361 IN PLARGE_INTEGER RequestVbn,
2362 OUT PLARGE_INTEGER * pMappedRuns
2363 );
2364
2365 NTSTATUS
2366 Ext2QueryRetrievalPointers(IN PEXT2_IRP_CONTEXT IrpContext);
2367
2368 NTSTATUS
2369 Ext2GetRetrievalPointers(IN PEXT2_IRP_CONTEXT IrpContext);
2370
2371 NTSTATUS
2372 Ext2GetRetrievalPointerBase(IN PEXT2_IRP_CONTEXT IrpContext);
2373
2374 NTSTATUS
2375 Ext2UserFsRequest (IN PEXT2_IRP_CONTEXT IrpContext);
2376
2377 BOOLEAN
2378 Ext2IsMediaWriteProtected (
2379 IN PEXT2_IRP_CONTEXT IrpContext,
2380 IN PDEVICE_OBJECT TargetDevice
2381 );
2382
2383 NTSTATUS
2384 Ext2MountVolume (IN PEXT2_IRP_CONTEXT IrpContext);
2385
2386 VOID
2387 Ext2VerifyVcb (IN PEXT2_IRP_CONTEXT IrpContext,
2388 IN PEXT2_VCB Vcb );
2389 NTSTATUS
2390 Ext2VerifyVolume (IN PEXT2_IRP_CONTEXT IrpContext);
2391
2392 NTSTATUS
2393 Ext2IsVolumeMounted (IN PEXT2_IRP_CONTEXT IrpContext);
2394
2395 NTSTATUS
2396 Ext2DismountVolume (IN PEXT2_IRP_CONTEXT IrpContext);
2397
2398 NTSTATUS
2399 Ext2FileSystemControl (IN PEXT2_IRP_CONTEXT IrpContext);
2400
2401 //
2402 // HTree.c
2403 //
2404
2405 struct buffer_head *ext3_append(struct ext2_icb *icb, struct inode *inode,
2406 ext3_lblk_t *block, int *err);
2407
2408 void ext3_set_de_type(struct super_block *sb,
2409 struct ext3_dir_entry_2 *de,
2410 umode_t mode);
2411
2412 __u32 ext3_current_time(struct inode *in);
2413 void ext3_warning (struct super_block * sb, const char * function,
2414 char * fmt, ...);
2415 #define ext3_error ext3_warning
2416 #define ext4_error ext3_error
2417
2418 void ext3_update_dx_flag(struct inode *inode);
2419 int ext3_mark_inode_dirty(struct ext2_icb *icb, struct inode *in);
2420
2421 void ext3_inc_count(struct inode *inode);
2422 void ext3_dec_count(struct inode *inode);
2423
2424 struct buffer_head *
2425 ext3_find_entry (struct ext2_icb *icb, struct dentry *dentry,
2426 struct ext3_dir_entry_2 ** res_dir);
2427 struct buffer_head *
2428 ext3_dx_find_entry(struct ext2_icb *, struct dentry *dentry,
2429 struct ext3_dir_entry_2 **res_dir, int *err);
2430
2431 typedef int (*filldir_t)(void *, const char *, int, unsigned long, __u32, unsigned);
2432 int ext3_dx_readdir(struct file *filp, filldir_t filldir, void * context);
2433
2434 struct buffer_head *ext3_bread(struct ext2_icb *icb, struct inode *inode,
2435 unsigned long block, int *err);
2436 int add_dirent_to_buf(struct ext2_icb *icb, struct dentry *dentry,
2437 struct inode *inode, struct ext3_dir_entry_2 *de,
2438 struct buffer_head *bh);
2439 #if !defined(__REACTOS__) || defined(_MSC_VER)
2440 struct ext3_dir_entry_2 *
2441 do_split(struct ext2_icb *icb, struct inode *dir,
2442 struct buffer_head **bh,struct dx_frame *frame,
2443 struct dx_hash_info *hinfo, int *error);
2444 #endif
2445
2446 int ext3_add_entry(struct ext2_icb *icb, struct dentry *dentry, struct inode *inode);
2447
2448 int ext3_delete_entry(struct ext2_icb *icb, struct inode *dir,
2449 struct ext3_dir_entry_2 *de_del,
2450 struct buffer_head *bh);
2451
2452 int ext3_is_dir_empty(struct ext2_icb *icb, struct inode *inode);
2453
2454 //
2455 // Init.c
2456 //
2457
2458 NTSTATUS
2459 Ext2QueryGlobalParameters(IN PUNICODE_STRING RegistryPath);
2460 BOOLEAN
2461 Ext2QueryRegistrySettings(IN PUNICODE_STRING RegistryPath);
2462
2463 VOID NTAPI
2464 DriverUnload (IN PDRIVER_OBJECT DriverObject);
2465
2466 //
2467 // Indirect.c
2468 //
2469
2470 NTSTATUS
2471 Ext2MapIndirect(
2472 IN PEXT2_IRP_CONTEXT IrpContext,
2473 IN PEXT2_VCB Vcb,
2474 IN PEXT2_MCB Mcb,
2475 IN ULONG Index,
2476 IN BOOLEAN bAlloc,
2477 OUT PULONG pBlock,
2478 OUT PULONG Number
2479 );
2480
2481 NTSTATUS
2482 Ext2ExpandIndirect(
2483 PEXT2_IRP_CONTEXT IrpContext,
2484 PEXT2_VCB Vcb,
2485 PEXT2_MCB Mcb,
2486 ULONG Start,
2487 ULONG End,
2488 PLARGE_INTEGER Size
2489 );
2490
2491 NTSTATUS
2492 Ext2TruncateIndirect(
2493 PEXT2_IRP_CONTEXT IrpContext,
2494 PEXT2_VCB Vcb,
2495 PEXT2_MCB Mcb,
2496 PLARGE_INTEGER Size
2497 );
2498
2499
2500 //
2501 // linux.c: linux lib implemenation
2502 //
2503
2504 int
2505 ext2_init_linux();
2506
2507 void
2508 ext2_destroy_linux();
2509
2510
2511 //
2512 // Lock.c
2513 //
2514
2515 NTSTATUS
2516 Ext2LockControl (IN PEXT2_IRP_CONTEXT IrpContext);
2517
2518
2519 //
2520 // Memory.c
2521 //
2522
2523 VOID
2524 NTAPI
2525 Ext2FcbReaperThread(
2526 PVOID Context
2527 );
2528
2529 VOID
2530 NTAPI
2531 Ext2McbReaperThread(
2532 PVOID Context
2533 );
2534
2535 VOID
2536 NTAPI
2537 Ext2bhReaperThread(
2538 PVOID Context
2539 );
2540
2541
2542 PEXT2_IRP_CONTEXT
2543 Ext2AllocateIrpContext (IN PDEVICE_OBJECT DeviceObject,
2544 IN PIRP Irp );
2545
2546 VOID
2547 Ext2FreeIrpContext (IN PEXT2_IRP_CONTEXT IrpContext);
2548
2549
2550 PEXT2_FCB
2551 Ext2AllocateFcb (
2552 IN PEXT2_VCB Vcb,
2553 IN PEXT2_MCB Mcb
2554 );
2555
2556 VOID
2557 Ext2UnlinkFcb(IN PEXT2_FCB Fcb);
2558
2559 VOID
2560 Ext2FreeFcb (IN PEXT2_FCB Fcb);
2561 VOID
2562 Ext2ReleaseFcb (IN PEXT2_FCB Fcb);
2563
2564 VOID
2565 Ext2InsertFcb(PEXT2_VCB Vcb, PEXT2_FCB Fcb);
2566
2567 PEXT2_CCB
2568 Ext2AllocateCcb (ULONG Flags, PEXT2_MCB SymLink);
2569
2570 VOID
2571 Ext2FreeMcb (
2572 IN PEXT2_VCB Vcb,
2573 IN PEXT2_MCB Mcb
2574 );
2575
2576 VOID
2577 Ext2FreeCcb (IN PEXT2_VCB Vcb, IN PEXT2_CCB Ccb);
2578
2579 PEXT2_INODE
2580 Ext2AllocateInode (PEXT2_VCB Vcb);
2581
2582 VOID
2583 Ext2DestroyInode (IN PEXT2_VCB Vcb, IN PEXT2_INODE inode);
2584
2585 struct dentry * Ext2AllocateEntry();
2586 VOID Ext2FreeEntry (IN struct dentry *de);
2587 struct dentry *Ext2BuildEntry(PEXT2_VCB Vcb, PEXT2_MCB Dcb, PUNICODE_STRING FileName);
2588
2589 PEXT2_EXTENT
2590 Ext2AllocateExtent();
2591
2592 VOID
2593 Ext2FreeExtent (IN PEXT2_EXTENT Extent);
2594
2595 ULONG
2596 Ext2CountExtents(IN PEXT2_EXTENT Chain);
2597
2598 VOID
2599 Ext2JointExtents(
2600 IN PEXT2_EXTENT Chain,
2601 IN PEXT2_EXTENT Extent
2602 );
2603
2604 VOID
2605 Ext2DestroyExtentChain(IN PEXT2_EXTENT Chain);
2606
2607 NTSTATUS
2608 Ext2BuildExtents(
2609 IN PEXT2_IRP_CONTEXT IrpContext,
2610 IN PEXT2_VCB Vcb,
2611 IN PEXT2_MCB Mcb,
2612 IN ULONGLONG Offset,
2613 IN ULONG Size,
2614 IN BOOLEAN bAlloc,
2615 OUT PEXT2_EXTENT * Chain
2616 );
2617
2618 BOOLEAN
2619 Ext2ListExtents(PLARGE_MCB Extents);
2620
2621 VOID
2622 Ext2CheckExtent(
2623 PLARGE_MCB Zone,
2624 LONGLONG Vbn,
2625 LONGLONG Lbn,
2626 LONGLONG Length,
2627 BOOLEAN bAdded
2628 );
2629
2630 VOID
2631 Ext2ClearAllExtents(PLARGE_MCB Zone);
2632
2633 BOOLEAN
2634 Ext2AddVcbExtent (
2635 IN PEXT2_VCB Vcb,
2636 IN LONGLONG Vbn,
2637 IN LONGLONG Length
2638 );
2639
2640 BOOLEAN
2641 Ext2RemoveVcbExtent (
2642 IN PEXT2_VCB Vcb,
2643 IN LONGLONG Vbn,
2644 IN LONGLONG Length
2645 );
2646
2647 BOOLEAN
2648 Ext2LookupVcbExtent (
2649 IN PEXT2_VCB Vcb,
2650 IN LONGLONG Vbn,
2651 OUT PLONGLONG Lbn,
2652 OUT PLONGLONG Length
2653 );
2654
2655 BOOLEAN
2656 Ext2AddMcbExtent (
2657 IN PEXT2_VCB Vcb,
2658 IN PEXT2_MCB Mcb,
2659 IN LONGLONG Vbn,
2660 IN LONGLONG Lbn,
2661 IN LONGLONG Length
2662 );
2663
2664 BOOLEAN
2665 Ext2RemoveMcbExtent (
2666 IN PEXT2_VCB Vcb,
2667 IN PEXT2_MCB Mcb,
2668 IN LONGLONG Vbn,
2669 IN LONGLONG Length
2670 );
2671
2672 BOOLEAN
2673 Ext2LookupMcbExtent (
2674 IN PEXT2_VCB Vcb,
2675 IN PEXT2_MCB Mcb,
2676 IN LONGLONG Vbn,
2677 OUT PLONGLONG Lbn,
2678 OUT PLONGLONG Length
2679 );
2680
2681 BOOLEAN
2682 Ext2AddMcbMetaExts (
2683 IN PEXT2_VCB Vcb,
2684 IN PEXT2_MCB Mcb,
2685 IN ULONG Block,
2686 IN ULONG Length
2687 );
2688
2689 BOOLEAN
2690 Ext2RemoveMcbMetaExts (
2691 IN PEXT2_VCB Vcb,
2692 IN PEXT2_MCB Mcb,
2693 IN ULONG Block,
2694 IN ULONG Length
2695 );
2696
2697 BOOLEAN
2698 Ext2AddBlockExtent(
2699 IN PEXT2_VCB Vcb,
2700 IN PEXT2_MCB Mcb,
2701 IN ULONG Start,
2702 IN ULONG Block,
2703 IN ULONG Number
2704 );
2705
2706 BOOLEAN
2707 Ext2LookupBlockExtent(
2708 IN PEXT2_VCB Vcb,
2709 IN PEXT2_MCB Mcb,
2710 IN ULONG Start,
2711 IN PULONG Block,
2712 IN PULONG Mapped
2713 );
2714
2715 BOOLEAN
2716 Ext2RemoveBlockExtent(
2717 IN PEXT2_VCB Vcb,
2718 IN PEXT2_MCB Mcb,
2719 IN ULONG Start,
2720 IN ULONG Number
2721 );
2722
2723 NTSTATUS
2724 Ext2InitializeZone(
2725 IN PEXT2_IRP_CONTEXT IrpContext,
2726 IN PEXT2_VCB Vcb,
2727 IN PEXT2_MCB Mcb
2728 );
2729
2730 BOOLEAN
2731 Ext2BuildName(
2732 IN OUT PUNICODE_STRING Target,
2733 IN PUNICODE_STRING File,
2734 IN PUNICODE_STRING Parent
2735 );
2736
2737
2738 PEXT2_MCB
2739 Ext2AllocateMcb (
2740 IN PEXT2_VCB Vcb,
2741 IN PUNICODE_STRING FileName,
2742 IN PUNICODE_STRING Parent,
2743 IN ULONG FileAttr
2744 );
2745
2746 PEXT2_MCB
2747 Ext2SearchMcb(
2748 PEXT2_VCB Vcb,
2749 PEXT2_MCB Parent,
2750 PUNICODE_STRING FileName
2751 );
2752
2753 PEXT2_MCB
2754 Ext2SearchMcbWithoutLock(
2755 PEXT2_MCB Parent,
2756 PUNICODE_STRING FileName
2757 );
2758
2759 VOID
2760 Ext2InsertMcb(
2761 PEXT2_VCB Vcb,
2762 PEXT2_MCB Parent,
2763 PEXT2_MCB Child
2764 );
2765
2766 BOOLEAN
2767 Ext2RemoveMcb(
2768 PEXT2_VCB Vcb,
2769 PEXT2_MCB Mcb
2770 );
2771
2772 VOID
2773 Ext2CleanupAllMcbs(
2774 PEXT2_VCB Vcb
2775 );
2776
2777 BOOLEAN
2778 Ext2CheckSetBlock(
2779 PEXT2_IRP_CONTEXT IrpContext,
2780 PEXT2_VCB Vcb, LONGLONG Block
2781 );
2782
2783 BOOLEAN
2784 Ext2CheckBitmapConsistency(
2785 PEXT2_IRP_CONTEXT IrpContext,
2786 PEXT2_VCB Vcb
2787 );
2788
2789 VOID
2790 Ext2InsertVcb(PEXT2_VCB Vcb);
2791
2792 VOID
2793 Ext2RemoveVcb(PEXT2_VCB Vcb);
2794
2795 NTSTATUS
2796 Ext2InitializeLabel(
2797 IN PEXT2_VCB Vcb,
2798 IN PEXT2_SUPER_BLOCK Sb
2799 );
2800
2801 NTSTATUS
2802 Ext2InitializeVcb(
2803 PEXT2_IRP_CONTEXT IrpContext,
2804 PEXT2_VCB Vcb,
2805 PEXT2_SUPER_BLOCK Ext2Sb,
2806 PDEVICE_OBJECT TargetDevice,
2807 PDEVICE_OBJECT VolumeDevice,
2808 PVPB Vpb );
2809
2810 VOID
2811 Ext2TearDownStream (IN PEXT2_VCB Vcb);
2812
2813 VOID
2814 Ext2DestroyVcb (IN PEXT2_VCB Vcb);
2815
2816 NTSTATUS
2817 Ext2CompleteIrpContext (
2818 IN PEXT2_IRP_CONTEXT IrpContext,
2819 IN NTSTATUS Status );
2820
2821 VOID
2822 Ext2SyncUninitializeCacheMap (
2823 IN PFILE_OBJECT FileObject );
2824
2825 VOID
2826 Ext2LinkTailMcb(PEXT2_VCB Vcb, PEXT2_MCB Mcb);
2827
2828
2829 VOID
2830 Ext2LinkHeadMcb(PEXT2_VCB Vcb, PEXT2_MCB Mcb);
2831
2832 VOID
2833 Ext2UnlinkMcb(PEXT2_VCB Vcb, PEXT2_MCB Mcb);
2834
2835 PEXT2_MCB
2836 Ext2FirstUnusedMcb(
2837 PEXT2_VCB Vcb,
2838 BOOLEAN Wait,
2839 ULONG Number
2840 );
2841
2842 VOID NTAPI
2843 Ext2ReaperThread(
2844 PVOID Context
2845 );
2846
2847 NTSTATUS
2848 Ext2StartReaper(PEXT2_REAPER, EXT2_REAPER_RELEASE);
2849 VOID
2850 NTAPI
2851 Ext2StopReaper(PEXT2_REAPER Reaper);
2852
2853 //
2854 // Misc.c
2855 //
2856
2857 ULONG
2858 Ext2Log2(ULONG Value);
2859
2860 LARGE_INTEGER
2861 Ext2NtTime (IN ULONG i_time);
2862
2863 ULONG
2864 Ext2LinuxTime (IN LARGE_INTEGER SysTime);
2865
2866 ULONG
2867 Ext2OEMToUnicodeSize(
2868 IN PEXT2_VCB Vcb,
2869 IN PANSI_STRING Oem
2870 );
2871
2872 NTSTATUS
2873 Ext2OEMToUnicode(
2874 IN PEXT2_VCB Vcb,
2875 IN OUT PUNICODE_STRING Oem,
2876 IN POEM_STRING Unicode
2877 );
2878
2879 ULONG
2880 Ext2UnicodeToOEMSize(
2881 IN PEXT2_VCB Vcb,
2882 IN PUNICODE_STRING Unicode
2883 );
2884
2885 NTSTATUS
2886 Ext2UnicodeToOEM (
2887 IN PEXT2_VCB Vcb,
2888 IN OUT POEM_STRING Oem,
2889 IN PUNICODE_STRING Unicode
2890 );
2891
2892 VOID
2893 Ext2Sleep(ULONG ms);
2894
2895 int Ext2LinuxError (NTSTATUS Status);
2896 NTSTATUS Ext2WinntError(int rc);
2897
2898 BOOLEAN Ext2IsDot(PUNICODE_STRING name);
2899 BOOLEAN Ext2IsDotDot(PUNICODE_STRING name);
2900 //
2901 // nls/nls_rtl.c
2902 //
2903
2904 int
2905 Ext2LoadAllNls();
2906
2907 VOID
2908 Ext2UnloadAllNls();
2909
2910 //
2911 // Pnp.c
2912 //
2913
2914 NTSTATUS
2915 Ext2Pnp(IN PEXT2_IRP_CONTEXT IrpContext);
2916
2917 NTSTATUS
2918 Ext2PnpQueryRemove(
2919 PEXT2_IRP_CONTEXT IrpContext,
2920 PEXT2_VCB Vcb );
2921
2922 NTSTATUS
2923 Ext2PnpRemove(
2924 PEXT2_IRP_CONTEXT IrpContext,
2925 PEXT2_VCB Vcb );
2926
2927 NTSTATUS
2928 Ext2PnpCancelRemove(
2929 PEXT2_IRP_CONTEXT IrpContext,
2930 PEXT2_VCB Vcb );
2931
2932 NTSTATUS
2933 Ext2PnpSurpriseRemove(
2934 PEXT2_IRP_CONTEXT IrpContext,
2935 PEXT2_VCB Vcb );
2936
2937
2938 //
2939 // Read.c
2940 //
2941
2942 NTSTATUS
2943 Ext2ReadInode (
2944 IN PEXT2_IRP_CONTEXT IrpContext,
2945 IN PEXT2_VCB Vcb,
2946 IN PEXT2_MCB Mcb,
2947 IN ULONGLONG Offset,
2948 IN PVOID Buffer,
2949 IN ULONG Size,
2950 IN BOOLEAN bDirectIo,
2951 OUT PULONG dwReturn
2952 );
2953
2954 NTSTATUS
2955 Ext2Read (IN PEXT2_IRP_CONTEXT IrpContext);
2956
2957
2958 //
2959 // ext3\recover.c
2960 //
2961
2962 PEXT2_MCB
2963 Ext2LoadInternalJournal(
2964 PEXT2_VCB Vcb,
2965 ULONG jNo
2966 );
2967
2968 INT
2969 Ext2CheckJournal(
2970 PEXT2_VCB Vcb,
2971 PULONG jNo
2972 );
2973
2974 INT
2975 Ext2RecoverJournal(
2976 PEXT2_IRP_CONTEXT IrpContext,
2977 PEXT2_VCB Vcb
2978 );
2979
2980 //
2981 // Shutdown.c
2982 //
2983
2984
2985 NTSTATUS
2986 Ext2ShutDown (IN PEXT2_IRP_CONTEXT IrpContext);
2987
2988
2989 //
2990 // Volinfo.c
2991 //
2992
2993 NTSTATUS
2994 Ext2QueryVolumeInformation (IN PEXT2_IRP_CONTEXT IrpContext);
2995
2996 NTSTATUS
2997 Ext2SetVolumeInformation (IN PEXT2_IRP_CONTEXT IrpContext);
2998
2999 //
3000 // Write.c
3001 //
3002
3003 typedef struct _EXT2_RW_CONTEXT {
3004 PIRP MasterIrp;
3005 KEVENT Event;
3006 ULONG Blocks;
3007 ULONG Length;
3008 PERESOURCE Resource;
3009 ERESOURCE_THREAD ThreadId;
3010 PFILE_OBJECT FileObject;
3011 ULONG Flags;
3012 BOOLEAN Wait;
3013
3014 } EXT2_RW_CONTEXT, *PEXT2_RW_CONTEXT;
3015
3016 #define EXT2_RW_CONTEXT_WRITE 1
3017
3018 NTSTATUS
3019 Ext2WriteInode (
3020 IN PEXT2_IRP_CONTEXT IrpContext,
3021 IN PEXT2_VCB Vcb,
3022 IN PEXT2_MCB Mcb,
3023 IN ULONGLONG Offset,
3024 IN PVOID Buffer,
3025 IN ULONG Size,
3026 IN BOOLEAN bDirectIo,
3027 OUT PULONG dwReturn
3028 );
3029
3030
3031 VOID
3032 Ext2StartFloppyFlushDpc (
3033 PEXT2_VCB Vcb,
3034 PEXT2_FCB Fcb,
3035 PFILE_OBJECT FileObject );
3036
3037 BOOLEAN
3038 Ext2ZeroData (
3039 IN PEXT2_IRP_CONTEXT IrpContext,
3040 IN PEXT2_VCB Vcb,
3041 IN PFILE_OBJECT FileObject,
3042 IN PLARGE_INTEGER Start,
3043 IN PLARGE_INTEGER End );
3044
3045 NTSTATUS
3046 Ext2Write (IN PEXT2_IRP_CONTEXT IrpContext);
3047
3048 #endif /* _EXT2_HEADER_ */