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