[DRIVERS][NTOS][NDK] Use IO_STACK_LOCATION instead of EXTENDED_IO_STACK_LOCATION...
[reactos.git] / drivers / filesystems / reiserfs / inc / rfsd.h
1 /*
2 * COPYRIGHT: GNU GENERAL PUBLIC LICENSE VERSION 2
3 * PROJECT: ReiserFs file system driver for Windows NT/2000/XP/Vista.
4 * FILE: rfsd.h
5 * PURPOSE: Header file: rfsd structures.
6 * PROGRAMMER: Mark Piper, Matt Wu, Bo Brantén.
7 * HOMEPAGE:
8 * UPDATE HISTORY:
9 */
10
11 #ifndef _RFSD_HEADER_
12 #define _RFSD_HEADER_
13
14 #ifdef _MSC_VER
15 #ifndef _PREFAST_
16 #pragma warning(disable:4068)
17 #define __drv_mustHoldCriticalRegion
18 #endif // !_PREFAST_
19 #endif
20
21 /* INCLUDES *************************************************************/
22
23 #include <linux/module.h>
24 //#include <linux/reiserfs_fs.h> // Full ReiserFS header
25 #include "reiserfs.h" // Simplified ReiserFS header
26 #ifdef __REACTOS__
27 #include <ndk/rtlfuncs.h>
28 #include <pseh/pseh2.h>
29 typedef IO_STACK_LOCATION EXTENDED_IO_STACK_LOCATION, *PEXTENDED_IO_STACK_LOCATION;
30 #endif
31
32 typedef struct reiserfs_super_block_v1 RFSD_SUPER_BLOCK, *PRFSD_SUPER_BLOCK;
33 typedef struct stat_data RFSD_INODE, *PRFSD_INODE;
34
35 #define RFSD_CALLBACK(name) NTSTATUS(* name )(ULONG BlockNumber, PVOID pContext)
36
37
38 typedef struct block_head RFSD_BLOCK_HEAD, *PRFSD_BLOCK_HEAD; // [mark]
39 typedef struct reiserfs_de_head RFSD_DENTRY_HEAD, *PRFSD_DENTRY_HEAD; // [mark]
40 typedef struct item_head RFSD_ITEM_HEAD, *PRFSD_ITEM_HEAD; // [mark]
41 typedef struct reiserfs_key RFSD_KEY_ON_DISK, *PRFSD_KEY_ON_DISK;
42 typedef struct reiserfs_cpu_key RFSD_KEY_IN_MEMORY, *PRFSD_KEY_IN_MEMORY;
43 typedef struct disk_child RFSD_DISK_NODE_REF, *PRFSD_DISK_NODE_REF;
44
45 #define RFSD_NAME_LEN 255 /// Default length of buffers for filenames (although filenames may be longer)
46
47 #define SUPER_BLOCK_OFFSET REISERFS_DISK_OFFSET_IN_BYTES
48 #define SUPER_BLOCK_SIZE sizeof(RFSD_SUPER_BLOCK)
49
50 #define RFSD_ROOT_PARENT_ID 1 /// Part of the key for the root node
51 #define RFSD_ROOT_OBJECT_ID 2 /// Part of the key for the root node
52 #define RFSD_IS_ROOT_KEY(x) (x.k_dir_id == RFSD_ROOT_PARENT_ID && x.k_objectid == RFSD_ROOT_OBJECT_ID)
53 #define RFSD_IS_PTR_TO_ROOT_KEY(x) (x->k_dir_id == RFSD_ROOT_PARENT_ID && x->k_objectid == RFSD_ROOT_OBJECT_ID)
54
55 typedef short RFSD_KEY_COMPARISON;
56 typedef __u16 RFSD_KEY_VERSION;
57
58 #define RFSD_KEY_VERSION_1 0
59 #define RFSD_KEY_VERSION_2 1
60 #define RFSD_KEY_VERSION_UNKNOWN 7
61
62 // Results of a key comparison (as returned by CompareKeys)
63 #define RFSD_KEYS_MATCH 0
64 #define RFSD_KEY_SMALLER -1
65 #define RFSD_KEY_LARGER 1
66
67
68 #define RFSD_LEAF_BLOCK_LEVEL 1
69
70 #include <ntdddisk.h>
71
72 #pragma pack(1)
73
74 /* DEBUG ****************************************************************/
75 #if DBG
76 #define DbgBreak() DbgPrint("rfsd: breakpoint requested.\n");DbgBreakPoint()
77 #else
78 #define DbgBreak() DbgPrint("rfsd: breakpoint ignored.\n")
79 #endif
80
81 /* STRUCTS & CONSTS******************************************************/
82
83 #define RFSD_VERSION "0.26"
84
85 //
86 // Rfsd build options
87 //
88
89 // To build read-only driver
90
91 #define RFSD_READ_ONLY TRUE
92
93 // To support driver dynamics unload
94
95 #define RFSD_UNLOAD TRUE
96
97 // The Pool Tag
98
99 #define RFSD_POOL_TAG 'dsfR'
100
101 //
102 // Constants
103 //
104
105 #define RFSD_BLOCK_TYPES (0x04)
106
107 #define MAXIMUM_RECORD_LENGTH (0x10000)
108
109 #define SECTOR_BITS (Vcb->SectorBits)
110 #define SECTOR_SIZE (Vcb->DiskGeometry.BytesPerSector)
111 #define DEFAULT_SECTOR_SIZE (0x200)
112
113 #define READ_AHEAD_GRANULARITY (0x10000)
114
115 #define SUPER_BLOCK (Vcb->SuperBlock)
116
117 #define BLOCK_SIZE (Vcb->BlockSize)
118 #define BLOCK_BITS (SUPER_BLOCK->s_log_block_size + 10)
119
120 #define INODES_COUNT (Vcb->SuperBlock->s_inodes_count)
121
122 #define INODES_PER_GROUP (SUPER_BLOCK->s_inodes_per_group)
123 #define BLOCKS_PER_GROUP (SUPER_BLOCK->s_blocks_per_group)
124 #define TOTAL_BLOCKS (SUPER_BLOCK->s_blocks_count)
125
126 #define RFSD_FIRST_DATA_BLOCK (SUPER_BLOCK->s_first_data_block)
127
128
129
130 #define CEILING_ALIGNED(A, B) (((A) + (B) - 1) & (~((B) - 1)))
131
132
133 // The __SLINE__ macro evaluates to a string with the line of the program from which it is called.
134 // (Note that this requires two levels of macro indirection...)
135 #define __STR2__(x) #x
136 #define __STR1__(x) __STR2__(x)
137 #define __SLINE__ __STR1__(__LINE__)
138
139
140 /* File System Releated *************************************************/
141
142 #define DRIVER_NAME "Rfsd"
143 #define DEVICE_NAME L"\\Rfsd"
144
145 // Registry
146
147 #define PARAMETERS_KEY L"\\Parameters"
148
149 #define WRITING_SUPPORT L"WritingSupport"
150 #define CHECKING_BITMAP L"CheckingBitmap"
151 #define EXT3_FORCEWRITING L"Ext3ForceWriting"
152 #define EXT3_CODEPAGE L"CodePage"
153
154 // To support rfsd unload routine
155 #if RFSD_UNLOAD
156
157 #define DOS_DEVICE_NAME L"\\DosDevices\\Rfsd"
158
159 //
160 // Private IOCTL to make the driver ready to unload
161 //
162 #define IOCTL_PREPARE_TO_UNLOAD \
163 CTL_CODE(FILE_DEVICE_UNKNOWN, 2048, METHOD_NEITHER, FILE_WRITE_ACCESS)
164
165 #endif // RFSD_UNLOAD
166
167 #ifndef SetFlag
168 #define SetFlag(x,f) ((x) |= (f))
169 #endif
170
171 #ifndef ClearFlag
172 #define ClearFlag(x,f) ((x) &= ~(f))
173 #endif
174
175 #define IsFlagOn(a,b) ((BOOLEAN)(FlagOn(a,b) == b))
176
177 #define RfsdRaiseStatus(IRPCONTEXT,STATUS) { \
178 (IRPCONTEXT)->ExceptionCode = (STATUS); \
179 ExRaiseStatus( (STATUS) ); \
180 }
181
182 #define RfsdNormalizeAndRaiseStatus(IRPCONTEXT,STATUS) { \
183 /* (IRPCONTEXT)->ExceptionStatus = (STATUS); */ \
184 if ((STATUS) == STATUS_VERIFY_REQUIRED) { ExRaiseStatus((STATUS)); } \
185 ExRaiseStatus(FsRtlNormalizeNtstatus((STATUS),STATUS_UNEXPECTED_IO_ERROR)); \
186 }
187
188 //
189 // Define IsEndofFile for read and write operations
190 //
191
192 #define FILE_WRITE_TO_END_OF_FILE 0xffffffff
193 #define FILE_USE_FILE_POINTER_POSITION 0xfffffffe
194
195 #define IsEndOfFile(Pos) ((Pos.LowPart == FILE_WRITE_TO_END_OF_FILE) && \
196 (Pos.HighPart == FILE_USE_FILE_POINTER_POSITION ))
197
198 #define IsDirectory(Fcb) IsFlagOn(Fcb->RfsdMcb->FileAttr, FILE_ATTRIBUTE_DIRECTORY)
199
200 //
201 // Bug Check Codes Definitions
202 //
203
204 #define RFSD_FILE_SYSTEM (FILE_SYSTEM)
205
206 #define RFSD_BUGCHK_BLOCK (0x00010000)
207 #define RFSD_BUGCHK_CLEANUP (0x00020000)
208 #define RFSD_BUGCHK_CLOSE (0x00030000)
209 #define RFSD_BUGCHK_CMCB (0x00040000)
210 #define RFSD_BUGCHK_CREATE (0x00050000)
211 #define RFSD_BUGCHK_DEBUG (0x00060000)
212 #define RFSD_BUGCHK_DEVCTL (0x00070000)
213 #define RFSD_BUGCHK_DIRCTL (0x00080000)
214 #define RFSD_BUGCHK_DISPATCH (0x00090000)
215 #define RFSD_BUGCHK_EXCEPT (0x000A0000)
216 #define RFSD_BUGCHK_RFSD (0x000B0000)
217 #define RFSD_BUGCHK_FASTIO (0x000C0000)
218 #define RFSD_BUGCHK_FILEINFO (0x000D0000)
219 #define RFSD_BUGCHK_FLUSH (0x000E0000)
220 #define RFSD_BUGCHK_FSCTL (0x000F0000)
221 #define RFSD_BUGCHK_INIT (0x00100000)
222 #define RFSD_BUGCHK_LOCK (0x0011000)
223 #define RFSD_BUGCHK_MEMORY (0x0012000)
224 #define RFSD_BUGCHK_MISC (0x0013000)
225 #define RFSD_BUGCHK_READ (0x00140000)
226 #define RFSD_BUGCHK_SHUTDOWN (0x00150000)
227 #define RFSD_BUGCHK_VOLINFO (0x00160000)
228 #define RFSD_BUGCHK_WRITE (0x00170000)
229
230 #define RFSD_BUGCHK_LAST (0x00170000)
231
232 #define RfsdBugCheck(A,B,C,D) { KeBugCheckEx(RFSD_FILE_SYSTEM, A | __LINE__, B, C, D ); }
233
234
235 /* Rfsd file system definions *******************************************/
236
237 #define RFSD_MIN_BLOCK 1024
238 #define RFSD_MIN_FRAG 1024
239
240 //
241 // Inode flags (Linux uses octad number, but why ? strange!!!)
242 //
243
244 #define S_IFMT 0x0F000 /* 017 0000 */
245 #define S_IFSOCK 0x0C000 /* 014 0000 */
246 #define S_IFLNK 0x0A000 /* 012 0000 */
247 #define S_IFREG 0x08000 /* 010 0000 */
248 #define S_IFBLK 0x06000 /* 006 0000 */
249 #define S_IFDIR 0x04000 /* 004 0000 */
250 #define S_IFCHR 0x02000 /* 002 0000 */
251 #define S_IFIFO 0x01000 /* 001 0000 */
252 #define S_ISUID 0x00800 /* 000 4000 */
253 #define S_ISGID 0x00400 /* 000 2000 */
254 #define S_ISVTX 0x00200 /* 000 1000 */
255
256 #define S_ISREG(m) (((m) & S_IFMT) == S_IFREG)
257 #define S_ISSOCK(m) (((m) & S_IFMT) == S_IFSOCK)
258 #define S_ISLNK(m) (((m) & S_IFMT) == S_IFLNK)
259 #define S_ISFIL(m) (((m) & S_IFMT) == S_IFFIL)
260 #define S_ISBLK(m) (((m) & S_IFMT) == S_IFBLK)
261 #define S_ISDIR(m) (((m) & S_IFMT) == S_IFDIR)
262 #define S_ISCHR(m) (((m) & S_IFMT) == S_IFCHR)
263 #define S_ISFIFO(m) (((m) & S_IFMT) == S_IFIFO)
264
265 #define S_IPERMISSION_MASK 0x1FF /* */
266
267 #define S_IRWXU 0x1C0 /* 0 0700 */
268 #define S_IRUSR 0x100 /* 0 0400 */
269 #define S_IWUSR 0x080 /* 0 0200 */
270 #define S_IXUSR 0x040 /* 0 0100 */
271
272 #define S_IRWXG 0x038 /* 0 0070 */
273 #define S_IRGRP 0x020 /* 0 0040 */
274 #define S_IWGRP 0x010 /* 0 0020 */
275 #define S_IXGRP 0x008 /* 0 0010 */
276
277 #define S_IRWXO 0x007 /* 0 0007 */
278 #define S_IROTH 0x004 /* 0 0004 */
279 #define S_IWOTH 0x002 /* 0 0002 */
280 #define S_IXOTH 0x001 /* 0 0001 */
281
282 #define S_IRWXUGO (S_IRWXU|S_IRWXG|S_IRWXO)
283 #define S_IALLUGO (S_ISUID|S_ISGID|S_ISVTX|S_IRWXUGO)
284 #define S_IRUGO (S_IRUSR|S_IRGRP|S_IROTH)
285 #define S_IWUGO (S_IWUSR|S_IWGRP|S_IWOTH)
286 #define S_IXUGO (S_IXUSR|S_IXGRP|S_IXOTH)
287
288 #define S_ISREADABLE(m) (((m) & S_IPERMISSION_MASK) == (S_IRUSR | S_IRGRP | S_IROTH))
289 #define S_ISWRITABLE(m) (((m) & S_IPERMISSION_MASK) == (S_IWUSR | S_IWGRP | S_IWOTH))
290
291 #define RfsdSetReadable(m) (m) = ((m) | (S_IRUSR | S_IRGRP | S_IROTH))
292 #define RfsdSetWritable(m) (m) = ((m) | (S_IWUSR | S_IWGRP | S_IWOTH))
293
294 #define RfsdSetReadOnly(m) (m) = ((m) & (~(S_IWUSR | S_IWGRP | S_IWOTH)))
295 #define RfsdIsReadOnly(m) (!((m) & (S_IWUSR | S_IWGRP | S_IWOTH)))
296
297 //
298 // Inode state bits
299 //
300
301 #define I_DIRTY_SYNC 1 /* Not dirty enough for O_DATASYNC */
302 #define I_DIRTY_DATASYNC 2 /* Data-related inode changes pending */
303 #define I_DIRTY_PAGES 4 /* Data-related inode changes pending */
304 #define I_LOCK 8
305 #define I_FREEING 16
306 #define I_CLEAR 32
307
308 #define I_DIRTY (I_DIRTY_SYNC | I_DIRTY_DATASYNC | I_DIRTY_PAGES)
309
310
311 //
312 // Rfsd Driver Definitions
313 //
314
315 //
316 // RFSD_IDENTIFIER_TYPE
317 //
318 // Identifiers used to mark the structures
319 //
320
321 typedef enum _RFSD_IDENTIFIER_TYPE {
322 RFSDFGD = ':DGF',
323 RFSDVCB = ':BCV',
324 RFSDFCB = ':BCF',
325 RFSDCCB = ':BCC',
326 RFSDICX = ':XCI',
327 RFSDMCB = ':BCM'
328 } RFSD_IDENTIFIER_TYPE;
329
330 //
331 // RFSD_IDENTIFIER
332 //
333 // Header used to mark the structures
334 //
335 typedef struct _RFSD_IDENTIFIER {
336 RFSD_IDENTIFIER_TYPE Type;
337 ULONG Size;
338 } RFSD_IDENTIFIER, *PRFSD_IDENTIFIER;
339
340
341 #define NodeType(Ptr) (*((RFSD_IDENTIFIER_TYPE *)(Ptr)))
342
343 typedef struct _RFSD_MCB RFSD_MCB, *PRFSD_MCB;
344
345
346 typedef PVOID PBCB;
347
348 //
349 // REPINNED_BCBS List
350 //
351
352 #define RFSD_REPINNED_BCBS_ARRAY_SIZE (8)
353
354 typedef struct _RFSD_REPINNED_BCBS {
355
356 //
357 // A pointer to the next structure contains additional repinned bcbs
358 //
359
360 struct _RFSD_REPINNED_BCBS *Next;
361
362 //
363 // A fixed size array of pinned bcbs. Whenever a new bcb is added to
364 // the repinned bcb structure it is added to this array. If the
365 // array is already full then another repinned bcb structure is allocated
366 // and pointed to with Next.
367 //
368
369 PBCB Bcb[ RFSD_REPINNED_BCBS_ARRAY_SIZE ];
370
371 } RFSD_REPINNED_BCBS, *PRFSD_REPINNED_BCBS;
372
373
374 #define CODEPAGE_MAXLEN 0x20
375
376 //
377 // RFSD_GLOBAL_DATA
378 //
379 // Data that is not specific to a mounted volume
380 //
381
382 typedef struct _RFSD_GLOBAL {
383
384 // Identifier for this structure
385 RFSD_IDENTIFIER Identifier;
386
387 // Syncronization primitive for this structure
388 ERESOURCE Resource;
389
390 // Syncronization primitive for Counting
391 ERESOURCE CountResource;
392
393 // Syncronization primitive for LookAside Lists
394 ERESOURCE LAResource;
395
396 // Table of pointers to the fast I/O entry points
397 FAST_IO_DISPATCH FastIoDispatch;
398
399 // Table of pointers to the Cache Manager callbacks
400 CACHE_MANAGER_CALLBACKS CacheManagerCallbacks;
401 CACHE_MANAGER_CALLBACKS CacheManagerNoOpCallbacks;
402
403 // Pointer to the driver object
404 PDRIVER_OBJECT DriverObject;
405
406 // Pointer to the main device object
407 PDEVICE_OBJECT DeviceObject;
408
409 // List of mounted volumes
410 LIST_ENTRY VcbList;
411
412 // Look Aside table of IRP_CONTEXT, FCB, MCB, CCB
413 USHORT MaxDepth;
414 NPAGED_LOOKASIDE_LIST RfsdIrpContextLookasideList;
415 NPAGED_LOOKASIDE_LIST RfsdFcbLookasideList;
416 NPAGED_LOOKASIDE_LIST RfsdCcbLookasideList;
417 PAGED_LOOKASIDE_LIST RfsdMcbLookasideList;
418
419 // Mcb Count ...
420 USHORT McbAllocated;
421
422 #if DBG
423 // Fcb Count
424 USHORT FcbAllocated;
425
426 // IRP_MJ_CLOSE : FCB
427 USHORT IRPCloseCount;
428 #endif
429
430 // Global flags for the driver
431 ULONG Flags;
432
433 // User specified codepage name
434 struct {
435 WCHAR UniName[CODEPAGE_MAXLEN];
436 UCHAR AnsiName[CODEPAGE_MAXLEN];
437 struct nls_table * PageTable;
438 } CodePage;
439
440 } RFSD_GLOBAL, *PRFSD_GLOBAL;
441
442 #define PAGE_TABLE RfsdGlobal->CodePage.PageTable
443
444 //
445 // Flags for RFSD_GLOBAL_DATA
446 //
447 #define RFSD_UNLOAD_PENDING 0x00000001
448 #define RFSD_SUPPORT_WRITING 0x00000002
449 #define EXT3_FORCE_WRITING 0x00000004
450 #define RFSD_CHECKING_BITMAP 0x00000008
451
452 //
453 // Driver Extension define
454 //
455 typedef struct {
456 RFSD_GLOBAL RfsdGlobal;
457 } RFSDFS_EXT, *PRFSDFS_EXT;
458
459
460 typedef struct _RFSD_FCBVCB {
461
462 // FCB header required by NT
463 FSRTL_COMMON_FCB_HEADER CommonFCBHeader;
464 SECTION_OBJECT_POINTERS SectionObject;
465 ERESOURCE MainResource;
466 ERESOURCE PagingIoResource;
467 // end FCB header required by NT
468
469 // Identifier for this structure
470 RFSD_IDENTIFIER Identifier;
471 } RFSD_FCBVCB, *PRFSD_FCBVCB;
472
473 //
474 // RFSD_VCB Volume Control Block
475 //
476 // Data that represents a mounted logical volume
477 // It is allocated as the device extension of the volume device object
478 //
479 typedef struct _RFSD_VCB {
480
481 // FCB header required by NT
482 // The VCB is also used as an FCB for file objects
483 // that represents the volume itself
484 FSRTL_COMMON_FCB_HEADER Header;
485 SECTION_OBJECT_POINTERS SectionObject;
486 ERESOURCE MainResource;
487 ERESOURCE PagingIoResource;
488 // end FCB header required by NT
489
490 // Identifier for this structure
491 RFSD_IDENTIFIER Identifier;
492
493 LIST_ENTRY Next;
494
495 // Share Access for the file object
496 SHARE_ACCESS ShareAccess;
497
498 // Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLEANUP
499 // for files on this volume.
500 ULONG OpenFileHandleCount;
501
502 // Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLOSE
503 // for both files on this volume and open instances of the
504 // volume itself.
505 ULONG ReferenceCount;
506 ULONG OpenHandleCount;
507
508 //
509 // Disk change count
510 //
511
512 ULONG ChangeCount;
513
514 // Pointer to the VPB in the target device object
515 PVPB Vpb;
516
517 // The FileObject of Volume used to lock the volume
518 PFILE_OBJECT LockFile;
519
520 // List of FCBs for open files on this volume
521 LIST_ENTRY FcbList;
522
523 // List of IRPs pending on directory change notify requests
524 LIST_ENTRY NotifyList;
525
526 // Pointer to syncronization primitive for this list
527 PNOTIFY_SYNC NotifySync;
528
529 // This volumes device object
530 PDEVICE_OBJECT DeviceObject;
531
532 // The physical device object (the disk)
533 PDEVICE_OBJECT TargetDeviceObject;
534
535 // The physical device object (the disk)
536 PDEVICE_OBJECT RealDevice;
537
538 // Information about the physical device object
539 DISK_GEOMETRY DiskGeometry;
540 PARTITION_INFORMATION PartitionInformation;
541
542 PRFSD_SUPER_BLOCK SuperBlock;
543 PVOID GroupDesc; // (NOTE: unused in ReiserFS, but preserved in order to minimize changes to existing code)
544 // PVOID GroupDescBcb;
545
546 // Number of Group Decsciptions
547 ULONG NumOfGroups;
548 /*
549 // Bitmap Block per group
550 PRTL_BITMAP BlockBitMaps;
551 PRTL_BITMAP InodeBitMaps;
552 */
553 // Block / Cluster size
554 ULONG BlockSize;
555
556 // Sector size in bits (NOTE: unused in ReiserFS)
557 //ULONG SectorBits;
558
559 ULONG dwData[RFSD_BLOCK_TYPES];
560 ULONG dwMeta[RFSD_BLOCK_TYPES];
561
562 // Flags for the volume
563 ULONG Flags;
564
565 // Streaming File Object
566 PFILE_OBJECT StreamObj;
567
568 // Resource Lock for Mcb
569 ERESOURCE McbResource;
570
571 // Dirty Mcbs of modifications for volume stream
572 LARGE_MCB DirtyMcbs;
573
574 // Entry of Mcb Tree (Root Node)
575 PRFSD_MCB McbTree;
576 LIST_ENTRY McbList;
577
578 } RFSD_VCB, *PRFSD_VCB;
579
580 //
581 // Flags for RFSD_VCB
582 //
583 #define VCB_INITIALIZED 0x00000001
584 #define VCB_VOLUME_LOCKED 0x00000002
585 #define VCB_MOUNTED 0x00000004
586 #define VCB_DISMOUNT_PENDING 0x00000008
587 #define VCB_READ_ONLY 0x00000010
588
589 #define VCB_WRITE_PROTECTED 0x10000000
590 #define VCB_FLOPPY_DISK 0x20000000
591 #define VCB_REMOVAL_PREVENTED 0x40000000
592 #define VCB_REMOVABLE_MEDIA 0x80000000
593
594
595 #define IsMounted(Vcb) (IsFlagOn(Vcb->Flags, VCB_MOUNTED))
596
597 //
598 // RFSD_FCB File Control Block
599 //
600 // Data that represents an open file
601 // There is a single instance of the FCB for every open file
602 //
603 typedef struct _RFSD_FCB {
604
605 // FCB header required by NT
606 FSRTL_COMMON_FCB_HEADER Header;
607 SECTION_OBJECT_POINTERS SectionObject;
608 ERESOURCE MainResource;
609 ERESOURCE PagingIoResource;
610 // end FCB header required by NT
611
612 // Identifier for this structure
613 RFSD_IDENTIFIER Identifier;
614
615 // List of FCBs for this volume
616 LIST_ENTRY Next;
617
618 // Share Access for the file object
619 SHARE_ACCESS ShareAccess;
620
621 // List of byte-range locks for this file
622 FILE_LOCK FileLockAnchor;
623
624 // Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLEANUP
625 ULONG OpenHandleCount;
626
627 // Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLOSE
628 ULONG ReferenceCount;
629
630 // Incremented on IRP_MJ_CREATE, decremented on IRP_MJ_CLEANUP
631 // But only for Files with FO_NO_INTERMEDIATE_BUFFERING flag
632 ULONG NonCachedOpenCount;
633
634 // Flags for the FCB
635 ULONG Flags;
636
637 // Pointer to the inode / stat data structure
638 PRFSD_INODE Inode;
639
640 // Hint block for next allocation
641 ULONG BlkHint;
642
643 // Vcb
644
645 PRFSD_VCB Vcb;
646
647 // Mcb Node ...
648 PRFSD_MCB RfsdMcb;
649
650 // Full Path Name
651 UNICODE_STRING LongName;
652
653 #if DBG
654 // The Ansi Filename for debugging
655 OEM_STRING AnsiFileName;
656 #endif
657
658
659 } RFSD_FCB, *PRFSD_FCB;
660
661
662 //
663 // Flags for RFSD_FCB
664 //
665 #define FCB_FROM_POOL 0x00000001
666 #define FCB_PAGE_FILE 0x00000002
667 #define FCB_DELETE_ON_CLOSE 0x00000004
668 #define FCB_DELETE_PENDING 0x00000008
669 #define FCB_FILE_DELETED 0x00000010
670 #define FCB_FILE_MODIFIED 0x00000020
671
672 // Mcb Node
673
674 struct _RFSD_MCB {
675
676 // Identifier for this structure
677 RFSD_IDENTIFIER Identifier;
678
679 // Flags
680 ULONG Flags;
681
682 // Link List Info
683
684 PRFSD_MCB Parent; // Parent
685 PRFSD_MCB Child; // Children
686 PRFSD_MCB Next; // Brothers
687
688 // Mcb Node Info
689
690 // -> Fcb
691 PRFSD_FCB RfsdFcb;
692
693 // Short name
694 UNICODE_STRING ShortName;
695
696 // Inode number (ReiserFS uses 128-bit keys instead of inode numbers)
697 RFSD_KEY_IN_MEMORY Key;
698
699 // Dir entry offset in parent (relative to the start of the directory listing)
700 ULONG DeOffset;
701
702 // File attribute
703 ULONG FileAttr;
704
705 // List Link to Vcb->McbList
706 LIST_ENTRY Link;
707 };
708
709 //
710 // Flags for MCB
711 //
712 #define MCB_FROM_POOL 0x00000001
713 #define MCB_IN_TREE 0x00000002
714 #define MCB_IN_USE 0x00000004
715
716 #define IsMcbUsed(Mcb) IsFlagOn(Mcb->Flags, MCB_IN_USE)
717
718 //
719 // RFSD_CCB Context Control Block
720 //
721 // Data that represents one instance of an open file
722 // There is one instance of the CCB for every instance of an open file
723 //
724 typedef struct _RFSD_CCB {
725
726 // Identifier for this structure
727 RFSD_IDENTIFIER Identifier;
728
729 // Flags
730 ULONG Flags;
731
732 // State that may need to be maintained
733 ULONG CurrentByteOffset;
734 USHORT deh_location;
735 UNICODE_STRING DirectorySearchPattern;
736
737 } RFSD_CCB, *PRFSD_CCB;
738
739 //
740 // Flags for CCB
741 //
742
743 #define CCB_FROM_POOL 0x00000001
744
745 #define CCB_ALLOW_EXTENDED_DASD_IO 0x80000000
746
747 //
748 // RFSD_IRP_CONTEXT
749 //
750 // Used to pass information about a request between the drivers functions
751 //
752 typedef struct _RFSD_IRP_CONTEXT {
753
754 // Identifier for this structure
755 RFSD_IDENTIFIER Identifier;
756
757 // Pointer to the IRP this request describes
758 PIRP Irp;
759
760 // Flags
761 ULONG Flags;
762
763 // The major and minor function code for the request
764 UCHAR MajorFunction;
765 UCHAR MinorFunction;
766
767 // The device object
768 PDEVICE_OBJECT DeviceObject;
769
770 // The real device object
771 PDEVICE_OBJECT RealDevice;
772
773 // The file object
774 PFILE_OBJECT FileObject;
775
776 PRFSD_FCB Fcb;
777 PRFSD_CCB Ccb;
778
779 // If the request is synchronous (we are allowed to block)
780 BOOLEAN IsSynchronous;
781
782 // If the request is top level
783 BOOLEAN IsTopLevel;
784
785 // Used if the request needs to be queued for later processing
786 WORK_QUEUE_ITEM WorkQueueItem;
787
788 // If an exception is currently in progress
789 BOOLEAN ExceptionInProgress;
790
791 // The exception code when an exception is in progress
792 NTSTATUS ExceptionCode;
793
794 // Repinned BCBs List
795 RFSD_REPINNED_BCBS Repinned;
796
797 } RFSD_IRP_CONTEXT, *PRFSD_IRP_CONTEXT;
798
799
800 #define IRP_CONTEXT_FLAG_FROM_POOL (0x00000001)
801 #define IRP_CONTEXT_FLAG_WAIT (0x00000002)
802 #define IRP_CONTEXT_FLAG_WRITE_THROUGH (0x00000004)
803 #define IRP_CONTEXT_FLAG_FLOPPY (0x00000008)
804 #define IRP_CONTEXT_FLAG_RECURSIVE_CALL (0x00000010)
805 #define IRP_CONTEXT_FLAG_DISABLE_POPUPS (0x00000020)
806 #define IRP_CONTEXT_FLAG_DEFERRED (0x00000040)
807 #define IRP_CONTEXT_FLAG_VERIFY_READ (0x00000080)
808 #define IRP_CONTEXT_STACK_IO_CONTEXT (0x00000100)
809 #define IRP_CONTEXT_FLAG_REQUEUED (0x00000200)
810 #define IRP_CONTEXT_FLAG_USER_IO (0x00000400)
811 #define IRP_CONTEXT_FLAG_DELAY_CLOSE (0x00000800)
812
813 //
814 // RFSD_ALLOC_HEADER
815 //
816 // In the checked version of the driver this header is put in the beginning of
817 // every memory allocation
818 //
819 typedef struct _RFSD_ALLOC_HEADER {
820 RFSD_IDENTIFIER Identifier;
821 } RFSD_ALLOC_HEADER, *PRFSD_ALLOC_HEADER;
822
823 typedef struct _FCB_LIST_ENTRY {
824 PRFSD_FCB Fcb;
825 LIST_ENTRY Next;
826 } FCB_LIST_ENTRY, *PFCB_LIST_ENTRY;
827
828
829 // Block Description List
830 typedef struct _RFSD_BDL {
831 ULONGLONG Lba;
832 ULONGLONG Offset;
833 ULONG Length;
834 PIRP Irp;
835 } RFSD_BDL, *PRFSD_BDL;
836
837 #pragma pack()
838
839
840 /* FUNCTIONS DECLARATION *****************************************************/
841
842 //
843 // The following macro is used to determine if an FSD thread can block
844 // for I/O or wait for a resource. It returns TRUE if the thread can
845 // block and FALSE otherwise. This attribute can then be used to call
846 // the FSD & FSP common work routine with the proper wait value.
847 //
848
849 #define CanRfsdWait(IRP) IoIsOperationSynchronous(Irp)
850
851 #ifndef max
852 #define max(a,b) (((a) > (b)) ? (a) : (b))
853 #endif
854
855 #ifndef min
856 #define min(a,b) (((a) < (b)) ? (a) : (b))
857 #endif
858
859 //
860 // RfsdBlock.c
861 //
862
863 // TODO move allocate and load block here
864
865 NTSTATUS
866 RfsdFindItemHeaderInBlock(
867 IN PRFSD_VCB Vcb,
868 IN PRFSD_KEY_IN_MEMORY pKey, // The key to match against
869 IN PUCHAR pBlockBuffer, // A filled disk block, provided by the caller
870 OUT PRFSD_ITEM_HEAD* ppTargetItemHeader, // A pointer to a PRFSD_ITEM_HEAD. The PRFSD_ITEM_HEAD will point to the item head matching Key, or NULL if there was no such item head in the given block.
871 IN RFSD_KEY_COMPARISON (*fpComparisonFunction)(PRFSD_KEY_IN_MEMORY, PRFSD_KEY_IN_MEMORY)
872 );
873
874 NTSTATUS
875 RfsdLoadItem(
876 IN PRFSD_VCB Vcb,
877 IN PRFSD_KEY_IN_MEMORY pItemKey, // The key of the item to find
878 OUT PRFSD_ITEM_HEAD* ppMatchingItemHeader,
879 OUT PUCHAR* ppItemBuffer,
880 OUT PUCHAR* ppBlockBuffer, // Block buffer, which backs the other output data structures. The caller must free this (even in the case of an error)!
881 OUT PULONG pBlockNumber, // The ordinal disk block number at which the item was found
882 IN RFSD_KEY_COMPARISON (*fpComparisonFunction)(PRFSD_KEY_IN_MEMORY, PRFSD_KEY_IN_MEMORY)
883 );
884 //
885 // Block.c
886 //
887
888 NTSTATUS
889 RfsdLockUserBuffer (
890 IN PIRP Irp,
891 IN ULONG Length,
892 IN LOCK_OPERATION Operation);
893 PVOID
894 RfsdGetUserBuffer (IN PIRP Irp);
895
896
897 NTSTATUS
898 RfsdReadWriteBlocks(
899 IN PRFSD_IRP_CONTEXT IrpContext,
900 IN PRFSD_VCB Vcb,
901 IN PRFSD_BDL RfsdBDL,
902 IN ULONG Length,
903 IN ULONG Count,
904 IN BOOLEAN bVerify );
905
906 PUCHAR
907 RfsdAllocateAndLoadBlock(
908 IN PRFSD_VCB Vcb,
909 IN ULONG BlockIndex );
910
911 NTSTATUS
912 RfsdReadSync(
913 IN PRFSD_VCB Vcb,
914 IN ULONGLONG Offset,
915 IN ULONG Length,
916 OUT PVOID Buffer,
917 IN BOOLEAN bVerify );
918
919 NTSTATUS
920 RfsdReadDisk(
921 IN PRFSD_VCB Vcb,
922 IN ULONGLONG Offset,
923 IN ULONG Size,
924 IN PVOID Buffer,
925 IN BOOLEAN bVerify );
926
927 NTSTATUS
928 RfsdDiskIoControl (
929 IN PDEVICE_OBJECT DeviceOjbect,
930 IN ULONG IoctlCode,
931 IN PVOID InputBuffer,
932 IN ULONG InputBufferSize,
933 IN OUT PVOID OutputBuffer,
934 IN OUT PULONG OutputBufferSize );
935
936 VOID
937 RfsdMediaEjectControl (
938 IN PRFSD_IRP_CONTEXT IrpContext,
939 IN PRFSD_VCB Vcb,
940 IN BOOLEAN bPrevent );
941
942 NTSTATUS
943 RfsdDiskShutDown(PRFSD_VCB Vcb);
944
945
946 //
947 // Cleanup.c
948 //
949 NTSTATUS
950 RfsdCleanup (IN PRFSD_IRP_CONTEXT IrpContext);
951
952 //
953 // Close.c
954 //
955 NTSTATUS
956 RfsdClose (IN PRFSD_IRP_CONTEXT IrpContext);
957
958 VOID
959 RfsdQueueCloseRequest (IN PRFSD_IRP_CONTEXT IrpContext);
960
961 #ifdef _PREFAST_
962 IO_WORKITEM_ROUTINE RfsdDeQueueCloseRequest;
963 #endif // _PREFAST_
964
965 VOID NTAPI
966 RfsdDeQueueCloseRequest (IN PVOID Context);
967
968 //
969 // Cmcb.c
970 //
971
972 BOOLEAN NTAPI
973 RfsdAcquireForLazyWrite (
974 IN PVOID Context,
975 IN BOOLEAN Wait );
976 VOID NTAPI
977 RfsdReleaseFromLazyWrite (IN PVOID Context);
978
979 BOOLEAN NTAPI
980 RfsdAcquireForReadAhead (
981 IN PVOID Context,
982 IN BOOLEAN Wait );
983
984 BOOLEAN NTAPI
985 RfsdNoOpAcquire (
986 IN PVOID Fcb,
987 IN BOOLEAN Wait );
988
989 VOID NTAPI
990 RfsdNoOpRelease (IN PVOID Fcb );
991
992 VOID NTAPI
993 RfsdReleaseFromReadAhead (IN PVOID Context);
994
995 //
996 // Create.c
997 //
998
999 PRFSD_FCB
1000 RfsdSearchFcbList(
1001 IN PRFSD_VCB Vcb,
1002 IN ULONG inode);
1003
1004 NTSTATUS
1005 RfsdScanDir (IN PRFSD_VCB Vcb,
1006 IN PRFSD_MCB ParentMcb, // Mcb of the directory to be scanned
1007 IN PUNICODE_STRING FileName, // Short file name (not necisarilly null-terminated!)
1008 IN OUT PULONG Index, // Offset (in bytes) of the dentry relative to the start of the directory listing
1009 IN OUT PRFSD_DENTRY_HEAD rfsd_dir); // Directory entry of the found item
1010
1011 NTSTATUS
1012 RfsdLookupFileName (
1013 IN PRFSD_VCB Vcb,
1014 IN PUNICODE_STRING FullFileName,
1015 IN PRFSD_MCB ParentMcb,
1016 OUT PRFSD_MCB * RfsdMcb,
1017 IN OUT PRFSD_INODE Inode);
1018
1019 NTSTATUS
1020 RfsdCreateFile(
1021 IN PRFSD_IRP_CONTEXT IrpContext,
1022 IN PRFSD_VCB Vcb );
1023
1024 NTSTATUS
1025 RfsdCreateVolume(
1026 IN PRFSD_IRP_CONTEXT IrpContext,
1027 IN PRFSD_VCB Vcb );
1028
1029 NTSTATUS
1030 RfsdCreate (IN PRFSD_IRP_CONTEXT IrpContext);
1031
1032 NTSTATUS
1033 RfsdCreateInode(
1034 IN PRFSD_IRP_CONTEXT IrpContext,
1035 IN PRFSD_VCB Vcb,
1036 IN PRFSD_FCB pParentFcb,
1037 IN ULONG Type,
1038 IN ULONG FileAttr,
1039 IN PUNICODE_STRING FileName);
1040
1041 NTSTATUS
1042 RfsdSupersedeOrOverWriteFile(
1043 IN PRFSD_IRP_CONTEXT IrpContext,
1044 IN PRFSD_VCB Vcb,
1045 IN PRFSD_FCB Fcb,
1046 IN ULONG Disposition);
1047
1048 //
1049 // Debug.c
1050 //
1051
1052 #define DBG_VITAL 0
1053 #define DBG_ERROR 1
1054 #define DBG_USER 2
1055 #define DBG_TRACE 3
1056 #define DBG_INFO 4
1057 #define DBG_FUNC 5
1058
1059 #if DBG
1060 #define RfsdPrint(arg) RfsdPrintf arg
1061 #define RfsdPrintNoIndent(arg) RfsdNIPrintf arg
1062
1063 #define RfsdCompleteRequest(Irp, bPrint, PriorityBoost) \
1064 RfsdDbgPrintComplete(Irp, bPrint); \
1065 IoCompleteRequest(Irp, PriorityBoost)
1066
1067 #else
1068
1069 #define RfsdPrint(arg)
1070 #define RfsdPrintNoIndent(arg)
1071
1072 #define RfsdCompleteRequest(Irp, bPrint, PriorityBoost) \
1073 IoCompleteRequest(Irp, PriorityBoost)
1074
1075 #endif // DBG
1076
1077 VOID
1078 __cdecl
1079 RfsdPrintf(
1080 LONG DebugPrintLevel,
1081 PCHAR DebugMessage,
1082 ...
1083 );
1084
1085 VOID
1086 __cdecl
1087 RfsdNIPrintf(
1088 LONG DebugPrintLevel,
1089 PCHAR DebugMessage,
1090 ...
1091 );
1092
1093 extern ULONG ProcessNameOffset;
1094
1095 #define RfsdGetCurrentProcessName() ( \
1096 (PUCHAR) PsGetCurrentProcess() + ProcessNameOffset \
1097 )
1098
1099 ULONG
1100 RfsdGetProcessNameOffset (VOID);
1101
1102 VOID
1103 RfsdDbgPrintCall (
1104 IN PDEVICE_OBJECT DeviceObject,
1105 IN PIRP Irp );
1106
1107 VOID
1108 RfsdDbgPrintComplete (
1109 IN PIRP Irp,
1110 IN BOOLEAN bPrint
1111 );
1112
1113 PUCHAR
1114 RfsdNtStatusToString (IN NTSTATUS Status );
1115
1116 //
1117 // Devctl.c
1118 //
1119
1120 NTSTATUS
1121 RfsdDeviceControlNormal (IN PRFSD_IRP_CONTEXT IrpContext);
1122
1123 NTSTATUS
1124 RfsdPrepareToUnload (IN PRFSD_IRP_CONTEXT IrpContext);
1125
1126 NTSTATUS
1127 RfsdDeviceControl (IN PRFSD_IRP_CONTEXT IrpContext);
1128
1129 //
1130 // Dirctl.c
1131 //
1132
1133 ULONG
1134 RfsdGetInfoLength(IN FILE_INFORMATION_CLASS FileInformationClass);
1135
1136 ULONG
1137 RfsdProcessDirEntry(
1138 IN PRFSD_VCB Vcb,
1139 IN FILE_INFORMATION_CLASS FileInformationClass,
1140 IN __u32 Key_ParentID,
1141 IN __u32 Key_ObjectID,
1142 IN PVOID Buffer,
1143 IN ULONG UsedLength,
1144 IN ULONG Length,
1145 IN ULONG FileIndex,
1146 IN PUNICODE_STRING pName,
1147 IN BOOLEAN Single,
1148 IN PVOID pPreviousEntry );
1149
1150 NTSTATUS
1151 RfsdQueryDirectory (IN PRFSD_IRP_CONTEXT IrpContext);
1152
1153 NTSTATUS
1154 RfsdNotifyChangeDirectory (
1155 IN PRFSD_IRP_CONTEXT IrpContext
1156 );
1157
1158 VOID
1159 RfsdNotifyReportChange (
1160 IN PRFSD_IRP_CONTEXT IrpContext,
1161 IN PRFSD_VCB Vcb,
1162 IN PRFSD_FCB Fcb,
1163 IN ULONG Filter,
1164 IN ULONG Action
1165 );
1166
1167 NTSTATUS
1168 RfsdDirectoryControl (IN PRFSD_IRP_CONTEXT IrpContext);
1169
1170 BOOLEAN
1171 RfsdIsDirectoryEmpty (
1172 IN PRFSD_VCB Vcb,
1173 IN PRFSD_FCB Fcb
1174 );
1175
1176 //
1177 // Dispatch.c
1178 //
1179
1180 NTSTATUS
1181 RfsdQueueRequest (IN PRFSD_IRP_CONTEXT IrpContext);
1182
1183 #ifdef _PREFAST_
1184 IO_WORKITEM_ROUTINE RfsdDeQueueRequest;
1185 #endif // _PREFAST_
1186
1187 VOID NTAPI
1188 RfsdDeQueueRequest (IN PVOID Context);
1189
1190 NTSTATUS
1191 RfsdDispatchRequest (IN PRFSD_IRP_CONTEXT IrpContext);
1192
1193 #ifdef _PREFAST_
1194 __drv_dispatchType(IRP_MJ_CREATE)
1195 __drv_dispatchType(IRP_MJ_CLOSE)
1196 __drv_dispatchType(IRP_MJ_READ)
1197 __drv_dispatchType(IRP_MJ_WRITE)
1198 __drv_dispatchType(IRP_MJ_FLUSH_BUFFERS)
1199 __drv_dispatchType(IRP_MJ_QUERY_INFORMATION)
1200 __drv_dispatchType(IRP_MJ_SET_INFORMATION)
1201 __drv_dispatchType(IRP_MJ_QUERY_VOLUME_INFORMATION)
1202 __drv_dispatchType(IRP_MJ_SET_VOLUME_INFORMATION)
1203 __drv_dispatchType(IRP_MJ_DIRECTORY_CONTROL)
1204 __drv_dispatchType(IRP_MJ_FILE_SYSTEM_CONTROL)
1205 __drv_dispatchType(IRP_MJ_DEVICE_CONTROL)
1206 __drv_dispatchType(IRP_MJ_LOCK_CONTROL)
1207 __drv_dispatchType(IRP_MJ_CLEANUP)
1208 __drv_dispatchType(IRP_MJ_PNP)
1209 __drv_dispatchType(IRP_MJ_SHUTDOWN)
1210 DRIVER_DISPATCH RfsdBuildRequest;
1211 #endif // _PREFAST_
1212
1213 NTSTATUS NTAPI
1214 RfsdBuildRequest (
1215 IN PDEVICE_OBJECT DeviceObject,
1216 IN PIRP Irp
1217 );
1218
1219 //
1220 // Except.c
1221 //
1222
1223 NTSTATUS
1224 RfsdExceptionFilter (
1225 IN PRFSD_IRP_CONTEXT IrpContext,
1226 IN PEXCEPTION_POINTERS ExceptionPointer
1227 );
1228
1229 NTSTATUS
1230 RfsdExceptionHandler (IN PRFSD_IRP_CONTEXT IrpContext);
1231
1232
1233 //
1234 // Rfsd.c
1235 //
1236
1237 PRFSD_SUPER_BLOCK
1238 RfsdLoadSuper(
1239 IN PRFSD_VCB Vcb,
1240 IN BOOLEAN bVerify
1241 );
1242
1243 BOOLEAN
1244 RfsdSaveSuper(
1245 IN PRFSD_IRP_CONTEXT IrpContext,
1246 IN PRFSD_VCB Vcb
1247 );
1248
1249 BOOLEAN
1250 RfsdLoadGroup(IN PRFSD_VCB Vcb);
1251
1252 BOOLEAN
1253 RfsdSaveGroup(
1254 IN PRFSD_IRP_CONTEXT IrpContext,
1255 IN PRFSD_VCB Vcb,
1256 IN ULONG Group
1257 );
1258
1259 BOOLEAN
1260 RfsdGetInodeLba (IN PRFSD_VCB Vcb,
1261 IN __u32 DirectoryID,
1262 IN __u32 ParentID,
1263 OUT PLONGLONG offset);
1264
1265 BOOLEAN
1266 RfsdLoadInode (IN PRFSD_VCB Vcb,
1267 IN PRFSD_KEY_IN_MEMORY pKey,
1268 IN OUT PRFSD_INODE Inode);
1269
1270 BOOLEAN
1271 RfsdLoadInode2 (IN PRFSD_VCB Vcb,
1272 IN __u32 a,
1273 IN __u32 b,
1274 IN OUT PRFSD_INODE Inode);
1275 BOOLEAN
1276 RfsdSaveInode (
1277 IN PRFSD_IRP_CONTEXT IrpContext,
1278 IN PRFSD_VCB Vcb,
1279 IN ULONG inode,
1280 IN PRFSD_INODE Inode
1281 );
1282
1283 BOOLEAN
1284 RfsdLoadBlock (
1285 IN PRFSD_VCB Vcb,
1286 IN ULONG dwBlk,
1287 IN PVOID Buffer
1288 );
1289
1290 BOOLEAN
1291 RfsdSaveBlock (
1292 IN PRFSD_IRP_CONTEXT IrpContext,
1293 IN PRFSD_VCB Vcb,
1294 IN ULONG dwBlk,
1295 IN PVOID Buf
1296 );
1297
1298 BOOLEAN
1299 RfsdSaveBuffer(
1300 IN PRFSD_IRP_CONTEXT IrpContext,
1301 IN PRFSD_VCB Vcb,
1302 IN LONGLONG Offset,
1303 IN ULONG Size,
1304 IN PVOID Buf
1305 );
1306
1307 NTSTATUS
1308 RfsdGetBlock(
1309 IN PRFSD_IRP_CONTEXT IrpContext,
1310 IN PRFSD_VCB Vcb,
1311 IN ULONG dwContent,
1312 IN ULONG Index,
1313 IN ULONG Layer,
1314 IN BOOLEAN bAlloc,
1315 OUT PULONG pBlock
1316 );
1317
1318 NTSTATUS
1319 RfsdBlockMap(
1320 IN PRFSD_IRP_CONTEXT IrpContext,
1321 IN PRFSD_VCB Vcb,
1322 IN ULONG InodeNo,
1323 IN PRFSD_INODE Inode,
1324 IN ULONG Index,
1325 IN BOOLEAN bAlloc,
1326 OUT PULONG pBlock
1327 );
1328
1329 NTSTATUS
1330 RfsdBuildBDL2(
1331 IN PRFSD_VCB Vcb,
1332 IN PRFSD_KEY_IN_MEMORY pKey,
1333 IN PRFSD_INODE pInode,
1334 OUT PULONG out_Count,
1335 OUT PRFSD_BDL* out_ppBdl );
1336
1337 NTSTATUS
1338 RfsdBuildBDL(
1339 IN PRFSD_IRP_CONTEXT IrpContext,
1340 IN PRFSD_VCB Vcb,
1341 IN PRFSD_KEY_IN_MEMORY InodeNo,
1342 IN PRFSD_INODE Inode,
1343 IN ULONGLONG Offset,
1344 IN ULONG Size,
1345 IN BOOLEAN bAlloc,
1346 OUT PRFSD_BDL * Bdls,
1347 OUT PULONG Count
1348 );
1349
1350 NTSTATUS
1351 RfsdNewBlock(
1352 PRFSD_IRP_CONTEXT IrpContext,
1353 PRFSD_VCB Vcb,
1354 ULONG GroupHint,
1355 ULONG BlockHint,
1356 PULONG dwRet );
1357
1358 NTSTATUS
1359 RfsdFreeBlock(
1360 PRFSD_IRP_CONTEXT IrpContext,
1361 PRFSD_VCB Vcb,
1362 ULONG Block );
1363
1364 NTSTATUS
1365 RfsdExpandBlock(
1366 PRFSD_IRP_CONTEXT IrpContext,
1367 PRFSD_VCB Vcb,
1368 PRFSD_FCB Fcb,
1369 ULONG dwContent,
1370 ULONG Index,
1371 ULONG layer,
1372 BOOLEAN bNew,
1373 ULONG *dwRet );
1374
1375
1376 NTSTATUS
1377 RfsdExpandInode(
1378 PRFSD_IRP_CONTEXT IrpContext,
1379 PRFSD_VCB Vcb,
1380 PRFSD_FCB Fcb,
1381 ULONG *dwRet );
1382
1383 NTSTATUS
1384 RfsdNewInode(
1385 PRFSD_IRP_CONTEXT IrpContext,
1386 PRFSD_VCB Vcb,
1387 ULONG GroupHint,
1388 ULONG mode,
1389 PULONG Inode );
1390
1391 BOOLEAN
1392 RfsdFreeInode(
1393 PRFSD_IRP_CONTEXT IrpContext,
1394 PRFSD_VCB Vcb,
1395 ULONG Inode,
1396 ULONG Type );
1397
1398 NTSTATUS
1399 RfsdAddEntry (
1400 IN PRFSD_IRP_CONTEXT IrpContext,
1401 IN PRFSD_VCB Vcb,
1402 IN PRFSD_FCB Dcb,
1403 IN ULONG FileType,
1404 IN ULONG Inode,
1405 IN PUNICODE_STRING FileName );
1406
1407 NTSTATUS
1408 RfsdRemoveEntry (
1409 IN PRFSD_IRP_CONTEXT IrpContext,
1410 IN PRFSD_VCB Vcb,
1411 IN PRFSD_FCB Dcb,
1412 IN ULONG FileType,
1413 IN ULONG Inode );
1414
1415 NTSTATUS
1416 RfsdSetParentEntry (
1417 IN PRFSD_IRP_CONTEXT IrpContext,
1418 IN PRFSD_VCB Vcb,
1419 IN PRFSD_FCB Dcb,
1420 IN ULONG OldParent,
1421 IN ULONG NewParent );
1422
1423
1424 NTSTATUS
1425 RfsdTruncateBlock(
1426 IN PRFSD_IRP_CONTEXT IrpContext,
1427 IN PRFSD_VCB Vcb,
1428 IN PRFSD_FCB Fcb,
1429 IN ULONG dwContent,
1430 IN ULONG Index,
1431 IN ULONG layer,
1432 OUT BOOLEAN *bFreed );
1433
1434 NTSTATUS
1435 RfsdTruncateInode(
1436 IN PRFSD_IRP_CONTEXT IrpContext,
1437 IN PRFSD_VCB Vcb,
1438 IN PRFSD_FCB Fcb );
1439
1440 BOOLEAN
1441 RfsdAddMcbEntry (
1442 IN PRFSD_VCB Vcb,
1443 IN LONGLONG Lba,
1444 IN LONGLONG Length );
1445
1446 VOID
1447 RfsdRemoveMcbEntry (
1448 IN PRFSD_VCB Vcb,
1449 IN LONGLONG Lba,
1450 IN LONGLONG Length );
1451
1452 BOOLEAN
1453 RfsdLookupMcbEntry (
1454 IN PRFSD_VCB Vcb,
1455 IN LONGLONG Offset,
1456 OUT PLONGLONG Lba OPTIONAL,
1457 OUT PLONGLONG Length OPTIONAL,
1458 OUT PLONGLONG RunStart OPTIONAL,
1459 OUT PLONGLONG RunLength OPTIONAL,
1460 OUT PULONG Index OPTIONAL );
1461
1462 BOOLEAN
1463 SuperblockContainsMagicKey(PRFSD_SUPER_BLOCK sb);
1464
1465 __u32
1466 ConvertKeyTypeUniqueness(__u32 k_uniqueness);
1467
1468 void
1469 FillInMemoryKey(
1470 IN PRFSD_KEY_ON_DISK pKeyOnDisk,
1471 IN RFSD_KEY_VERSION KeyVersion,
1472 IN OUT PRFSD_KEY_IN_MEMORY pKeyInMemory );
1473
1474 RFSD_KEY_VERSION DetermineOnDiskKeyFormat(const PRFSD_KEY_ON_DISK key);
1475
1476 RFSD_KEY_COMPARISON
1477 CompareShortKeys(
1478 IN PRFSD_KEY_IN_MEMORY a,
1479 IN PRFSD_KEY_IN_MEMORY b );
1480
1481 RFSD_KEY_COMPARISON
1482 CompareKeysWithoutOffset(
1483 IN PRFSD_KEY_IN_MEMORY a,
1484 IN PRFSD_KEY_IN_MEMORY b );
1485
1486 RFSD_KEY_COMPARISON
1487 CompareKeys(
1488 IN PRFSD_KEY_IN_MEMORY a,
1489 IN PRFSD_KEY_IN_MEMORY b );
1490
1491 NTSTATUS
1492 NavigateToLeafNode(
1493 IN PRFSD_VCB Vcb,
1494 IN PRFSD_KEY_IN_MEMORY Key,
1495 IN ULONG StartingBlockNumber,
1496 OUT PULONG out_NextBlockNumber );
1497
1498 NTSTATUS
1499 RfsdParseFilesystemTree(
1500 IN PRFSD_VCB Vcb,
1501 IN PRFSD_KEY_IN_MEMORY Key, // Key to search for.
1502 IN ULONG StartingBlockNumber, // Block number of an internal or leaf node, to start the search from
1503 IN RFSD_CALLBACK(fpDirectoryCallback), // A function ptr to trigger on hitting a matching leaf block
1504 IN PVOID Context
1505 );
1506
1507
1508 NTSTATUS
1509 _NavigateToLeafNode(
1510 IN PRFSD_VCB Vcb,
1511 IN PRFSD_KEY_IN_MEMORY Key,
1512 IN ULONG StartingBlockNumber,
1513 OUT PULONG out_NextBlockNumber,
1514 IN BOOLEAN ReturnOnFirstMatch,
1515 IN RFSD_KEY_COMPARISON (*fpComparisonFunction)(PRFSD_KEY_IN_MEMORY, PRFSD_KEY_IN_MEMORY),
1516 RFSD_CALLBACK(fpDirectoryCallback),
1517 IN PVOID pContext
1518 );
1519
1520
1521 //
1522 // Fastio.c
1523 //
1524
1525 #ifdef _PREFAST_
1526 FAST_IO_CHECK_IF_POSSIBLE RfsdFastIoCheckIfPossible;
1527 #endif // _PREFAST_
1528
1529 BOOLEAN NTAPI
1530 RfsdFastIoCheckIfPossible (
1531 IN PFILE_OBJECT FileObject,
1532 IN PLARGE_INTEGER FileOffset,
1533 IN ULONG Length,
1534 IN BOOLEAN Wait,
1535 IN ULONG LockKey,
1536 IN BOOLEAN CheckForReadOperation,
1537 OUT PIO_STATUS_BLOCK IoStatus,
1538 IN PDEVICE_OBJECT DeviceObject );
1539
1540 #ifdef _PREFAST_
1541 FAST_IO_READ RfsdFastIoRead;
1542 #endif // _PREFAST_
1543
1544 BOOLEAN NTAPI
1545 RfsdFastIoRead (IN PFILE_OBJECT FileObject,
1546 IN PLARGE_INTEGER FileOffset,
1547 IN ULONG Length,
1548 IN BOOLEAN Wait,
1549 IN ULONG LockKey,
1550 OUT PVOID Buffer,
1551 OUT PIO_STATUS_BLOCK IoStatus,
1552 IN PDEVICE_OBJECT DeviceObject);
1553
1554 #ifdef _PREFAST_
1555 FAST_IO_WRITE RfsdFastIoWrite;
1556 #endif // _PREFAST_
1557
1558 BOOLEAN NTAPI
1559 RfsdFastIoWrite (
1560 IN PFILE_OBJECT FileObject,
1561 IN PLARGE_INTEGER FileOffset,
1562 IN ULONG Length,
1563 IN BOOLEAN Wait,
1564 IN ULONG LockKey,
1565 OUT PVOID Buffer,
1566 OUT PIO_STATUS_BLOCK IoStatus,
1567 IN PDEVICE_OBJECT DeviceObject);
1568
1569 #ifdef _PREFAST_
1570 FAST_IO_QUERY_BASIC_INFO RfsdFastIoQueryBasicInfo;
1571 #endif // _PREFAST_
1572
1573 BOOLEAN NTAPI
1574 RfsdFastIoQueryBasicInfo (
1575 IN PFILE_OBJECT FileObject,
1576 IN BOOLEAN Wait,
1577 OUT PFILE_BASIC_INFORMATION Buffer,
1578 OUT PIO_STATUS_BLOCK IoStatus,
1579 IN PDEVICE_OBJECT DeviceObject);
1580
1581 #ifdef _PREFAST_
1582 FAST_IO_QUERY_STANDARD_INFO RfsdFastIoQueryStandardInfo;
1583 #endif // _PREFAST_
1584
1585 BOOLEAN NTAPI
1586 RfsdFastIoQueryStandardInfo (
1587 IN PFILE_OBJECT FileObject,
1588 IN BOOLEAN Wait,
1589 OUT PFILE_STANDARD_INFORMATION Buffer,
1590 OUT PIO_STATUS_BLOCK IoStatus,
1591 IN PDEVICE_OBJECT DeviceObject);
1592
1593 #ifdef _PREFAST_
1594 FAST_IO_LOCK RfsdFastIoLock;
1595 #endif // _PREFAST_
1596
1597 BOOLEAN NTAPI
1598 RfsdFastIoLock (
1599 IN PFILE_OBJECT FileObject,
1600 IN PLARGE_INTEGER FileOffset,
1601 IN PLARGE_INTEGER Length,
1602 IN PEPROCESS Process,
1603 IN ULONG Key,
1604 IN BOOLEAN FailImmediately,
1605 IN BOOLEAN ExclusiveLock,
1606 OUT PIO_STATUS_BLOCK IoStatus,
1607 IN PDEVICE_OBJECT DeviceObject
1608 );
1609
1610 #ifdef _PREFAST_
1611 FAST_IO_UNLOCK_SINGLE RfsdFastIoUnlockSingle;
1612 #endif // _PREFAST_
1613
1614 BOOLEAN NTAPI
1615 RfsdFastIoUnlockSingle (
1616 IN PFILE_OBJECT FileObject,
1617 IN PLARGE_INTEGER FileOffset,
1618 IN PLARGE_INTEGER Length,
1619 IN PEPROCESS Process,
1620 IN ULONG Key,
1621 OUT PIO_STATUS_BLOCK IoStatus,
1622 IN PDEVICE_OBJECT DeviceObject
1623 );
1624
1625 #ifdef _PREFAST_
1626 FAST_IO_UNLOCK_ALL RfsdFastIoUnlockAll;
1627 #endif // _PREFAST_
1628
1629 BOOLEAN NTAPI
1630 RfsdFastIoUnlockAll (
1631 IN PFILE_OBJECT FileObject,
1632 IN PEPROCESS Process,
1633 OUT PIO_STATUS_BLOCK IoStatus,
1634 IN PDEVICE_OBJECT DeviceObject
1635 );
1636
1637 #ifdef _PREFAST_
1638 FAST_IO_UNLOCK_ALL_BY_KEY RfsdFastIoUnlockAllByKey;
1639 #endif // _PREFAST_
1640
1641 BOOLEAN NTAPI
1642 RfsdFastIoUnlockAllByKey (
1643 IN PFILE_OBJECT FileObject,
1644 #ifdef __REACTOS__
1645 IN PVOID Process,
1646 #else
1647 IN PEPROCESS Process,
1648 #endif
1649 IN ULONG Key,
1650 OUT PIO_STATUS_BLOCK IoStatus,
1651 IN PDEVICE_OBJECT DeviceObject
1652 );
1653
1654 #ifdef _PREFAST_
1655 FAST_IO_QUERY_NETWORK_OPEN_INFO RfsdFastIoQueryNetworkOpenInfo;
1656 #endif // _PREFAST_
1657
1658 BOOLEAN NTAPI
1659 RfsdFastIoQueryNetworkOpenInfo (
1660 IN PFILE_OBJECT FileObject,
1661 IN BOOLEAN Wait,
1662 OUT PFILE_NETWORK_OPEN_INFORMATION Buffer,
1663 OUT PIO_STATUS_BLOCK IoStatus,
1664 IN PDEVICE_OBJECT DeviceObject );
1665
1666
1667 //
1668 // FileInfo.c
1669 //
1670
1671
1672 NTSTATUS
1673 RfsdQueryInformation (IN PRFSD_IRP_CONTEXT IrpContext);
1674
1675 NTSTATUS
1676 RfsdSetInformation (IN PRFSD_IRP_CONTEXT IrpContext);
1677
1678 NTSTATUS
1679 RfsdExpandFile (
1680 PRFSD_IRP_CONTEXT IrpContext,
1681 PRFSD_VCB Vcb,
1682 PRFSD_FCB Fcb,
1683 PLARGE_INTEGER AllocationSize );
1684
1685 NTSTATUS
1686 RfsdTruncateFile (
1687 PRFSD_IRP_CONTEXT IrpContext,
1688 PRFSD_VCB Vcb,
1689 PRFSD_FCB Fcb,
1690 PLARGE_INTEGER AllocationSize );
1691
1692 NTSTATUS
1693 RfsdSetDispositionInfo(
1694 PRFSD_IRP_CONTEXT IrpContext,
1695 PRFSD_VCB Vcb,
1696 PRFSD_FCB Fcb,
1697 BOOLEAN bDelete);
1698
1699 NTSTATUS
1700 RfsdSetRenameInfo(
1701 PRFSD_IRP_CONTEXT IrpContext,
1702 PRFSD_VCB Vcb,
1703 PRFSD_FCB Fcb );
1704
1705 NTSTATUS
1706 RfsdDeleteFile(
1707 PRFSD_IRP_CONTEXT IrpContext,
1708 PRFSD_VCB Vcb,
1709 PRFSD_FCB Fcb );
1710
1711
1712 //
1713 // Flush.c
1714 //
1715
1716 NTSTATUS
1717 RfsdFlushFiles (IN PRFSD_VCB Vcb, BOOLEAN bShutDown);
1718
1719 NTSTATUS
1720 RfsdFlushVolume (IN PRFSD_VCB Vcb, BOOLEAN bShutDown);
1721
1722 NTSTATUS
1723 RfsdFlushFile (IN PRFSD_FCB Fcb);
1724
1725 NTSTATUS
1726 RfsdFlush (IN PRFSD_IRP_CONTEXT IrpContext);
1727
1728
1729 //
1730 // Fsctl.c
1731 //
1732
1733
1734 VOID
1735 RfsdSetVpbFlag (IN PVPB Vpb,
1736 IN USHORT Flag );
1737
1738 VOID
1739 RfsdClearVpbFlag (IN PVPB Vpb,
1740 IN USHORT Flag );
1741
1742 BOOLEAN
1743 RfsdCheckDismount (
1744 IN PRFSD_IRP_CONTEXT IrpContext,
1745 IN PRFSD_VCB Vcb,
1746 IN BOOLEAN bForce );
1747
1748 __drv_mustHoldCriticalRegion
1749 NTSTATUS
1750 RfsdPurgeVolume (IN PRFSD_VCB Vcb,
1751 IN BOOLEAN FlushBeforePurge);
1752
1753 __drv_mustHoldCriticalRegion
1754 NTSTATUS
1755 RfsdPurgeFile (IN PRFSD_FCB Fcb,
1756 IN BOOLEAN FlushBeforePurge);
1757
1758 BOOLEAN
1759 RfsdIsHandleCountZero(IN PRFSD_VCB Vcb);
1760
1761 NTSTATUS
1762 RfsdLockVcb (IN PRFSD_VCB Vcb,
1763 IN PFILE_OBJECT FileObject);
1764
1765 NTSTATUS
1766 RfsdLockVolume (IN PRFSD_IRP_CONTEXT IrpContext);
1767
1768 NTSTATUS
1769 RfsdUnlockVcb (IN PRFSD_VCB Vcb,
1770 IN PFILE_OBJECT FileObject);
1771
1772 NTSTATUS
1773 RfsdUnlockVolume (IN PRFSD_IRP_CONTEXT IrpContext);
1774
1775 NTSTATUS
1776 RfsdAllowExtendedDasdIo(IN PRFSD_IRP_CONTEXT IrpContext);
1777
1778 NTSTATUS
1779 RfsdUserFsRequest (IN PRFSD_IRP_CONTEXT IrpContext);
1780
1781 NTSTATUS
1782 RfsdMountVolume (IN PRFSD_IRP_CONTEXT IrpContext);
1783
1784 NTSTATUS
1785 RfsdVerifyVolume (IN PRFSD_IRP_CONTEXT IrpContext);
1786
1787 __drv_mustHoldCriticalRegion
1788 NTSTATUS
1789 RfsdIsVolumeMounted (IN PRFSD_IRP_CONTEXT IrpContext);
1790
1791 __drv_mustHoldCriticalRegion
1792 NTSTATUS
1793 RfsdDismountVolume (IN PRFSD_IRP_CONTEXT IrpContext);
1794
1795 NTSTATUS
1796 RfsdFileSystemControl (IN PRFSD_IRP_CONTEXT IrpContext);
1797
1798
1799 //
1800 // Init.c
1801 //
1802
1803 BOOLEAN
1804 RfsdQueryParameters (IN PUNICODE_STRING RegistryPath);
1805
1806 #ifdef _PREFAST_
1807 DRIVER_INITIALIZE DriverEntry;
1808 #endif // _PREFAST_
1809
1810 #ifdef _PREFAST_
1811 DRIVER_UNLOAD DriverUnload;
1812 #endif // _PREFAST_
1813
1814 VOID NTAPI
1815 DriverUnload (IN PDRIVER_OBJECT DriverObject);
1816
1817
1818 //
1819 // Lock.c
1820 //
1821
1822 NTSTATUS
1823 RfsdLockControl (IN PRFSD_IRP_CONTEXT IrpContext);
1824
1825 //
1826 // Memory.c
1827 //
1828
1829 PRFSD_IRP_CONTEXT
1830 RfsdAllocateIrpContext (IN PDEVICE_OBJECT DeviceObject,
1831 IN PIRP Irp );
1832
1833 VOID
1834 RfsdFreeIrpContext (IN PRFSD_IRP_CONTEXT IrpContext);
1835
1836
1837 PRFSD_FCB
1838 RfsdAllocateFcb (IN PRFSD_VCB Vcb,
1839 IN PRFSD_MCB RfsdMcb,
1840 IN PRFSD_INODE Inode );
1841
1842 VOID
1843 RfsdFreeFcb (IN PRFSD_FCB Fcb);
1844
1845 PRFSD_CCB
1846 RfsdAllocateCcb (VOID);
1847
1848 VOID
1849 RfsdFreeMcb (IN PRFSD_MCB Mcb);
1850
1851 PRFSD_FCB
1852 RfsdCreateFcbFromMcb(PRFSD_VCB Vcb, PRFSD_MCB Mcb);
1853
1854 VOID
1855 RfsdFreeCcb (IN PRFSD_CCB Ccb);
1856
1857 PRFSD_MCB
1858 RfsdAllocateMcb ( PRFSD_VCB,
1859 PUNICODE_STRING FileName,
1860 ULONG FileAttr);
1861
1862 PRFSD_MCB
1863 RfsdSearchMcbTree( PRFSD_VCB Vcb,
1864 PRFSD_MCB RfsdMcb,
1865 PRFSD_KEY_IN_MEMORY Key);
1866
1867 PRFSD_MCB
1868 RfsdSearchMcb( PRFSD_VCB Vcb, PRFSD_MCB Parent,
1869 PUNICODE_STRING FileName);
1870
1871 BOOLEAN
1872 RfsdGetFullFileName( PRFSD_MCB Mcb,
1873 PUNICODE_STRING FileName);
1874
1875 VOID
1876 RfsdRefreshMcb(PRFSD_VCB Vcb, PRFSD_MCB Mcb);
1877
1878 VOID
1879 RfsdAddMcbNode( PRFSD_VCB Vcb,
1880 PRFSD_MCB Parent,
1881 PRFSD_MCB Child );
1882
1883 BOOLEAN
1884 RfsdDeleteMcbNode(
1885 PRFSD_VCB Vcb,
1886 PRFSD_MCB McbTree,
1887 PRFSD_MCB RfsdMcb);
1888
1889 VOID
1890 RfsdFreeMcbTree(PRFSD_MCB McbTree);
1891
1892 BOOLEAN
1893 RfsdCheckSetBlock( PRFSD_IRP_CONTEXT IrpContext,
1894 PRFSD_VCB Vcb, ULONG Block);
1895
1896 BOOLEAN
1897 RfsdCheckBitmapConsistency( PRFSD_IRP_CONTEXT IrpContext,
1898 PRFSD_VCB Vcb);
1899
1900 VOID
1901 RfsdInsertVcb(PRFSD_VCB Vcb);
1902
1903 VOID
1904 RfsdRemoveVcb(PRFSD_VCB Vcb);
1905
1906 NTSTATUS
1907 RfsdInitializeVcb(
1908 PRFSD_IRP_CONTEXT IrpContext,
1909 PRFSD_VCB Vcb,
1910 PRFSD_SUPER_BLOCK RfsdSb,
1911 PDEVICE_OBJECT TargetDevice,
1912 PDEVICE_OBJECT VolumeDevice,
1913 PVPB Vpb );
1914
1915 VOID
1916 RfsdFreeVcb (IN PRFSD_VCB Vcb );
1917
1918
1919 VOID
1920 RfsdRepinBcb (
1921 IN PRFSD_IRP_CONTEXT IrpContext,
1922 IN PBCB Bcb );
1923
1924 VOID
1925 RfsdUnpinRepinnedBcbs (
1926 IN PRFSD_IRP_CONTEXT IrpContext);
1927
1928
1929 NTSTATUS
1930 RfsdCompleteIrpContext (
1931 IN PRFSD_IRP_CONTEXT IrpContext,
1932 IN NTSTATUS Status );
1933
1934 VOID
1935 RfsdSyncUninitializeCacheMap (
1936 IN PFILE_OBJECT FileObject );
1937
1938 //
1939 // Misc.c
1940 //
1941
1942 /** Returns the length of a string (not including a terminating null), or MaximumLength if no terminator is found within MaximumLength characters. */
1943 static inline USHORT RfsdStringLength(PUCHAR buffer, USHORT MaximumLength)
1944 {
1945 USHORT i = 0;
1946 while ((i < MaximumLength) && (buffer[i] != '\0')) { i++; }
1947 return i;
1948 }
1949
1950 ULONG
1951 RfsdLog2(ULONG Value);
1952
1953 LARGE_INTEGER
1954 RfsdSysTime (IN ULONG i_time);
1955
1956 ULONG
1957 RfsdInodeTime (IN LARGE_INTEGER SysTime);
1958
1959 ULONG
1960 RfsdOEMToUnicodeSize(
1961 IN PANSI_STRING Oem
1962 );
1963
1964 NTSTATUS
1965 RfsdOEMToUnicode(
1966 IN OUT PUNICODE_STRING Oem,
1967 IN POEM_STRING Unicode
1968 );
1969
1970 ULONG
1971 RfsdUnicodeToOEMSize(
1972 IN PUNICODE_STRING Unicode
1973 );
1974
1975 NTSTATUS
1976 RfsdUnicodeToOEM (
1977 IN OUT POEM_STRING Oem,
1978 IN PUNICODE_STRING Unicode
1979 );
1980
1981 //
1982 // nls/nls_rtl.c
1983 //
1984
1985 int
1986 RfsdLoadAllNls();
1987
1988 VOID
1989 RfsdUnloadAllNls();
1990
1991 //
1992 // Pnp.c
1993 //
1994
1995 __drv_mustHoldCriticalRegion
1996 NTSTATUS
1997 RfsdPnp(IN PRFSD_IRP_CONTEXT IrpContext);
1998
1999 __drv_mustHoldCriticalRegion
2000 NTSTATUS
2001 RfsdPnpQueryRemove(
2002 PRFSD_IRP_CONTEXT IrpContext,
2003 PRFSD_VCB Vcb );
2004
2005 __drv_mustHoldCriticalRegion
2006 NTSTATUS
2007 RfsdPnpRemove(
2008 PRFSD_IRP_CONTEXT IrpContext,
2009 PRFSD_VCB Vcb );
2010
2011 __drv_mustHoldCriticalRegion
2012 NTSTATUS
2013 RfsdPnpCancelRemove(
2014 PRFSD_IRP_CONTEXT IrpContext,
2015 PRFSD_VCB Vcb );
2016
2017 __drv_mustHoldCriticalRegion
2018 NTSTATUS
2019 RfsdPnpSurpriseRemove(
2020 PRFSD_IRP_CONTEXT IrpContext,
2021 PRFSD_VCB Vcb );
2022
2023
2024 //
2025 // Read.c
2026 //
2027
2028 BOOLEAN
2029 RfsdCopyRead(
2030 IN PFILE_OBJECT FileObject,
2031 IN PLARGE_INTEGER FileOffset,
2032 IN ULONG Length,
2033 IN BOOLEAN Wait,
2034 OUT PVOID Buffer,
2035 OUT PIO_STATUS_BLOCK IoStatus );
2036
2037
2038 NTSTATUS
2039 RfsdReadInode (
2040 IN PRFSD_IRP_CONTEXT IrpContext,
2041 IN PRFSD_VCB Vcb,
2042 IN PRFSD_KEY_IN_MEMORY Key,
2043 IN PRFSD_INODE Inode,
2044 IN ULONGLONG Offset,
2045 IN PVOID Buffer,
2046 IN ULONG Size,
2047 OUT PULONG dwReturn
2048 );
2049
2050 NTSTATUS
2051 RfsdRead (IN PRFSD_IRP_CONTEXT IrpContext);
2052
2053 //
2054 // Shutdown.c
2055 //
2056
2057 NTSTATUS
2058 RfsdShutDown (IN PRFSD_IRP_CONTEXT IrpContext);
2059
2060 //
2061 // Volinfo.c
2062 //
2063
2064 NTSTATUS
2065 RfsdQueryVolumeInformation (IN PRFSD_IRP_CONTEXT IrpContext);
2066
2067 NTSTATUS
2068 RfsdSetVolumeInformation (IN PRFSD_IRP_CONTEXT IrpContext);
2069
2070
2071 //
2072 // Write.c
2073 //
2074
2075 NTSTATUS
2076 RfsdWriteInode (
2077 IN PRFSD_IRP_CONTEXT IrpContext,
2078 IN PRFSD_VCB Vcb,
2079 IN ULONG InodeNo,
2080 IN PRFSD_INODE Inode,
2081 IN ULONGLONG Offset,
2082 IN PVOID Buffer,
2083 IN ULONG Size,
2084 IN BOOLEAN bWriteToDisk,
2085 OUT PULONG dwReturn
2086 );
2087
2088 VOID
2089 RfsdStartFloppyFlushDpc (
2090 PRFSD_VCB Vcb,
2091 PRFSD_FCB Fcb,
2092 PFILE_OBJECT FileObject );
2093
2094 BOOLEAN
2095 RfsdZeroHoles (
2096 IN PRFSD_IRP_CONTEXT IrpContext,
2097 IN PRFSD_VCB Vcb,
2098 IN PFILE_OBJECT FileObject,
2099 IN LONGLONG Offset,
2100 IN LONGLONG Count );
2101
2102 NTSTATUS
2103 RfsdWrite (IN PRFSD_IRP_CONTEXT IrpContext);
2104
2105 #endif /* _RFSD_HEADER_ */