xref: /reactos/drivers/filesystems/ntfs/ntfs.h (revision 240dc77e)
1 #ifndef NTFS_H
2 #define NTFS_H
3 
4 #include <ntifs.h>
5 #include <pseh/pseh2.h>
6 #include <section_attribs.h>
7 
8 #define CACHEPAGESIZE(pDeviceExt) \
9 	((pDeviceExt)->NtfsInfo.UCHARsPerCluster > PAGE_SIZE ? \
10 	 (pDeviceExt)->NtfsInfo.UCHARsPerCluster : PAGE_SIZE)
11 
12 #define TAG_NTFS '0ftN'
13 #define TAG_CCB 'CftN'
14 #define TAG_FCB 'FftN'
15 #define TAG_IRP_CTXT 'iftN'
16 #define TAG_ATT_CTXT 'aftN'
17 #define TAG_FILE_REC 'rftN'
18 
19 #define ROUND_UP(N, S) ((((N) + (S) - 1) / (S)) * (S))
20 #define ROUND_DOWN(N, S) ((N) - ((N) % (S)))
21 
22 #define DEVICE_NAME L"\\Ntfs"
23 
24 #include <pshpack1.h>
25 typedef struct _BIOS_PARAMETERS_BLOCK
26 {
27     USHORT    BytesPerSector;			// 0x0B
28     UCHAR     SectorsPerCluster;		// 0x0D
29     UCHAR     Unused0[7];				// 0x0E, checked when volume is mounted
30     UCHAR     MediaId;				// 0x15
31     UCHAR     Unused1[2];				// 0x16
32     USHORT    SectorsPerTrack;		// 0x18
33     USHORT    Heads;					// 0x1A
34     UCHAR     Unused2[4];				// 0x1C
35     UCHAR     Unused3[4];				// 0x20, checked when volume is mounted
36 } BIOS_PARAMETERS_BLOCK, *PBIOS_PARAMETERS_BLOCK;
37 
38 typedef struct _EXTENDED_BIOS_PARAMETERS_BLOCK
39 {
40     USHORT    Unknown[2];				// 0x24, always 80 00 80 00
41     ULONGLONG SectorCount;			// 0x28
42     ULONGLONG MftLocation;			// 0x30
43     ULONGLONG MftMirrLocation;		// 0x38
44     CHAR      ClustersPerMftRecord;	// 0x40
45     UCHAR     Unused4[3];				// 0x41
46     CHAR      ClustersPerIndexRecord; // 0x44
47     UCHAR     Unused5[3];				// 0x45
48     ULONGLONG SerialNumber;			// 0x48
49     UCHAR     Checksum[4];			// 0x50
50 } EXTENDED_BIOS_PARAMETERS_BLOCK, *PEXTENDED_BIOS_PARAMETERS_BLOCK;
51 
52 typedef struct _BOOT_SECTOR
53 {
54     UCHAR     Jump[3];				// 0x00
55     UCHAR     OEMID[8];				// 0x03
56     BIOS_PARAMETERS_BLOCK BPB;
57     EXTENDED_BIOS_PARAMETERS_BLOCK EBPB;
58     UCHAR     BootStrap[426];			// 0x54
59     USHORT    EndSector;				// 0x1FE
60 } BOOT_SECTOR, *PBOOT_SECTOR;
61 #include <poppack.h>
62 
63 //typedef struct _BootSector BootSector;
64 
65 typedef struct _NTFS_INFO
66 {
67     ULONG BytesPerSector;
68     ULONG SectorsPerCluster;
69     ULONG BytesPerCluster;
70     ULONGLONG SectorCount;
71     ULONGLONG ClusterCount;
72     ULARGE_INTEGER MftStart;
73     ULARGE_INTEGER MftMirrStart;
74     ULONG BytesPerFileRecord;
75     ULONG BytesPerIndexRecord;
76 
77     ULONGLONG SerialNumber;
78     USHORT VolumeLabelLength;
79     WCHAR VolumeLabel[MAXIMUM_VOLUME_LABEL_LENGTH];
80     UCHAR MajorVersion;
81     UCHAR MinorVersion;
82     USHORT Flags;
83 
84     ULONG MftZoneReservation;
85 } NTFS_INFO, *PNTFS_INFO;
86 
87 #define NTFS_TYPE_CCB         '20SF'
88 #define NTFS_TYPE_FCB         '30SF'
89 #define NTFS_TYPE_VCB         '50SF'
90 #define NTFS_TYPE_IRP_CONTEXT '60SF'
91 #define NTFS_TYPE_GLOBAL_DATA '70SF'
92 
93 typedef struct
94 {
95     ULONG Type;
96     ULONG Size;
97 } NTFSIDENTIFIER, *PNTFSIDENTIFIER;
98 
99 typedef struct
100 {
101     NTFSIDENTIFIER Identifier;
102 
103     ERESOURCE DirResource;
104 //    ERESOURCE FatResource;
105 
106     KSPIN_LOCK FcbListLock;
107     LIST_ENTRY FcbListHead;
108 
109     PVPB Vpb;
110     PDEVICE_OBJECT StorageDevice;
111     PFILE_OBJECT StreamFileObject;
112 
113     struct _NTFS_ATTR_CONTEXT* MFTContext;
114     struct _FILE_RECORD_HEADER* MasterFileTable;
115     struct _FCB *VolumeFcb;
116 
117     NTFS_INFO NtfsInfo;
118 
119     NPAGED_LOOKASIDE_LIST FileRecLookasideList;
120 
121     ULONG MftDataOffset;
122     ULONG Flags;
123     ULONG OpenHandleCount;
124 
125 } DEVICE_EXTENSION, *PDEVICE_EXTENSION, NTFS_VCB, *PNTFS_VCB;
126 
127 #define VCB_VOLUME_LOCKED       0x0001
128 
129 typedef struct
130 {
131     NTFSIDENTIFIER Identifier;
132     LIST_ENTRY     NextCCB;
133     PFILE_OBJECT   PtrFileObject;
134     LARGE_INTEGER  CurrentByteOffset;
135     /* for DirectoryControl */
136     ULONG Entry;
137     /* for DirectoryControl */
138     PWCHAR DirectorySearchPattern;
139     ULONG LastCluster;
140     ULONG LastOffset;
141 } NTFS_CCB, *PNTFS_CCB;
142 
143 typedef struct
144 {
145     NTFSIDENTIFIER Identifier;
146     ERESOURCE Resource;
147     PDRIVER_OBJECT DriverObject;
148     PDEVICE_OBJECT DeviceObject;
149     CACHE_MANAGER_CALLBACKS CacheMgrCallbacks;
150     ULONG Flags;
151     FAST_IO_DISPATCH FastIoDispatch;
152     NPAGED_LOOKASIDE_LIST IrpContextLookasideList;
153     NPAGED_LOOKASIDE_LIST FcbLookasideList;
154     NPAGED_LOOKASIDE_LIST AttrCtxtLookasideList;
155     BOOLEAN EnableWriteSupport;
156 } NTFS_GLOBAL_DATA, *PNTFS_GLOBAL_DATA;
157 
158 
159 typedef enum
160 {
161     AttributeStandardInformation = 0x10,
162     AttributeAttributeList = 0x20,
163     AttributeFileName = 0x30,
164     AttributeObjectId = 0x40,
165     AttributeSecurityDescriptor = 0x50,
166     AttributeVolumeName = 0x60,
167     AttributeVolumeInformation = 0x70,
168     AttributeData = 0x80,
169     AttributeIndexRoot = 0x90,
170     AttributeIndexAllocation = 0xA0,
171     AttributeBitmap = 0xB0,
172     AttributeReparsePoint = 0xC0,
173     AttributeEAInformation = 0xD0,
174     AttributeEA = 0xE0,
175     AttributePropertySet = 0xF0,
176     AttributeLoggedUtilityStream = 0x100,
177     AttributeEnd = 0xFFFFFFFF
178 } ATTRIBUTE_TYPE, *PATTRIBUTE_TYPE;
179 
180 // FILE_RECORD_END seems to follow AttributeEnd in every file record starting with $Quota.
181 // No clue what data is being represented here.
182 #define FILE_RECORD_END              0x11477982
183 
184 #define NTFS_FILE_MFT                0
185 #define NTFS_FILE_MFTMIRR            1
186 #define NTFS_FILE_LOGFILE            2
187 #define NTFS_FILE_VOLUME            3
188 #define NTFS_FILE_ATTRDEF            4
189 #define NTFS_FILE_ROOT                5
190 #define NTFS_FILE_BITMAP            6
191 #define NTFS_FILE_BOOT                7
192 #define NTFS_FILE_BADCLUS            8
193 #define NTFS_FILE_QUOTA                9
194 #define NTFS_FILE_UPCASE            10
195 #define NTFS_FILE_EXTEND            11
196 #define NTFS_FILE_FIRST_USER_FILE   16
197 
198 #define NTFS_MFT_MASK 0x0000FFFFFFFFFFFFULL
199 
200 #define COLLATION_BINARY              0x00
201 #define COLLATION_FILE_NAME           0x01
202 #define COLLATION_UNICODE_STRING      0x02
203 #define COLLATION_NTOFS_ULONG         0x10
204 #define COLLATION_NTOFS_SID           0x11
205 #define COLLATION_NTOFS_SECURITY_HASH 0x12
206 #define COLLATION_NTOFS_ULONGS        0x13
207 
208 #define INDEX_ROOT_SMALL 0x0
209 #define INDEX_ROOT_LARGE 0x1
210 
211 #define INDEX_NODE_SMALL 0x0
212 #define INDEX_NODE_LARGE 0x1
213 
214 #define NTFS_INDEX_ENTRY_NODE            1
215 #define NTFS_INDEX_ENTRY_END            2
216 
217 #define NTFS_FILE_NAME_POSIX            0
218 #define NTFS_FILE_NAME_WIN32            1
219 #define NTFS_FILE_NAME_DOS            2
220 #define NTFS_FILE_NAME_WIN32_AND_DOS        3
221 
222 #define NTFS_FILE_TYPE_READ_ONLY  0x1
223 #define NTFS_FILE_TYPE_HIDDEN     0x2
224 #define NTFS_FILE_TYPE_SYSTEM     0x4
225 #define NTFS_FILE_TYPE_ARCHIVE    0x20
226 #define NTFS_FILE_TYPE_TEMPORARY  0x100
227 #define NTFS_FILE_TYPE_SPARSE     0x200
228 #define NTFS_FILE_TYPE_REPARSE    0x400
229 #define NTFS_FILE_TYPE_COMPRESSED 0x800
230 #define NTFS_FILE_TYPE_OFFLINE    0x1000
231 #define NTFS_FILE_TYPE_ENCRYPTED  0x4000
232 #define NTFS_FILE_TYPE_DIRECTORY  0x10000000
233 
234 /* Indexed Flag in Resident attributes - still somewhat speculative */
235 #define RA_INDEXED    0x01
236 
237 typedef struct
238 {
239     ULONG Type;             /* Magic number 'FILE' */
240     USHORT UsaOffset;       /* Offset to the update sequence */
241     USHORT UsaCount;        /* Size in words of Update Sequence Number & Array (S) */
242     ULONGLONG Lsn;          /* $LogFile Sequence Number (LSN) */
243 } NTFS_RECORD_HEADER, *PNTFS_RECORD_HEADER;
244 
245 /* NTFS_RECORD_HEADER.Type */
246 #define NRH_FILE_TYPE  0x454C4946  /* 'FILE' */
247 #define NRH_INDX_TYPE  0x58444E49  /* 'INDX' */
248 
249 
250 typedef struct _FILE_RECORD_HEADER
251 {
252     NTFS_RECORD_HEADER Ntfs;
253     USHORT SequenceNumber;        /* Sequence number */
254     USHORT LinkCount;             /* Hard link count */
255     USHORT AttributeOffset;       /* Offset to the first Attribute */
256     USHORT Flags;                 /* Flags */
257     ULONG BytesInUse;             /* Real size of the FILE record */
258     ULONG BytesAllocated;         /* Allocated size of the FILE record */
259     ULONGLONG BaseFileRecord;     /* File reference to the base FILE record */
260     USHORT NextAttributeNumber;   /* Next Attribute Id */
261     USHORT Padding;               /* Align to 4 UCHAR boundary (XP) */
262     ULONG MFTRecordNumber;        /* Number of this MFT Record (XP) */
263 } FILE_RECORD_HEADER, *PFILE_RECORD_HEADER;
264 
265 /* Flags in FILE_RECORD_HEADER */
266 
267 #define FRH_IN_USE    0x0001    /* Record is in use */
268 #define FRH_DIRECTORY 0x0002    /* Record is a directory */
269 #define FRH_UNKNOWN1  0x0004    /* Don't know */
270 #define FRH_UNKNOWN2  0x0008    /* Don't know */
271 
272 typedef struct
273 {
274     ULONG        Type;
275     ULONG        Length;
276     UCHAR        IsNonResident;
277     UCHAR        NameLength;
278     USHORT        NameOffset;
279     USHORT        Flags;
280     USHORT        Instance;
281     union
282     {
283         // Resident attributes
284         struct
285         {
286             ULONG        ValueLength;
287             USHORT        ValueOffset;
288             UCHAR        Flags;
289             UCHAR        Reserved;
290         } Resident;
291         // Non-resident attributes
292         struct
293         {
294             ULONGLONG        LowestVCN;
295             ULONGLONG        HighestVCN;
296             USHORT        MappingPairsOffset;
297             USHORT        CompressionUnit;
298             UCHAR        Reserved[4];
299             LONGLONG        AllocatedSize;
300             LONGLONG        DataSize;
301             LONGLONG        InitializedSize;
302             LONGLONG        CompressedSize;
303         } NonResident;
304     };
305 } NTFS_ATTR_RECORD, *PNTFS_ATTR_RECORD;
306 
307 typedef struct
308 {
309     ULONG Type;
310     USHORT Length;
311     UCHAR NameLength;
312     UCHAR NameOffset;
313     ULONGLONG StartingVCN;
314     ULONGLONG MFTIndex;
315     USHORT Instance;
316 } NTFS_ATTRIBUTE_LIST_ITEM, *PNTFS_ATTRIBUTE_LIST_ITEM;
317 
318 // The beginning and length of an attribute record are always aligned to an 8-byte boundary,
319 // relative to the beginning of the file record.
320 #define ATTR_RECORD_ALIGNMENT 8
321 
322 // Data runs are aligned to a 4-byte boundary, relative to the start of the attribute record
323 #define DATA_RUN_ALIGNMENT  4
324 
325 // Value offset is aligned to a 4-byte boundary, relative to the start of the attribute record
326 #define VALUE_OFFSET_ALIGNMENT  4
327 
328 typedef struct
329 {
330     ULONGLONG CreationTime;
331     ULONGLONG ChangeTime;
332     ULONGLONG LastWriteTime;
333     ULONGLONG LastAccessTime;
334     ULONG FileAttribute;
335     ULONG AlignmentOrReserved[3];
336 #if 0
337     ULONG QuotaId;
338     ULONG SecurityId;
339     ULONGLONG QuotaCharge;
340     USN Usn;
341 #endif
342 } STANDARD_INFORMATION, *PSTANDARD_INFORMATION;
343 
344 
345 typedef struct
346 {
347     ATTRIBUTE_TYPE AttributeType;
348     USHORT Length;
349     UCHAR NameLength;
350     UCHAR NameOffset;
351     ULONGLONG StartVcn; // LowVcn
352     ULONGLONG FileReferenceNumber;
353     USHORT AttributeNumber;
354     USHORT AlignmentOrReserved[3];
355 } ATTRIBUTE_LIST, *PATTRIBUTE_LIST;
356 
357 
358 typedef struct
359 {
360     ULONGLONG DirectoryFileReferenceNumber;
361     ULONGLONG CreationTime;
362     ULONGLONG ChangeTime;
363     ULONGLONG LastWriteTime;
364     ULONGLONG LastAccessTime;
365     ULONGLONG AllocatedSize;
366     ULONGLONG DataSize;
367     ULONG FileAttributes;
368     union
369     {
370         struct
371         {
372             USHORT PackedEaSize;
373             USHORT AlignmentOrReserved;
374         } EaInfo;
375         ULONG ReparseTag;
376     } Extended;
377     UCHAR NameLength;
378     UCHAR NameType;
379     WCHAR Name[1];
380 } FILENAME_ATTRIBUTE, *PFILENAME_ATTRIBUTE;
381 
382 typedef struct
383 {
384     ULONG FirstEntryOffset;
385     ULONG TotalSizeOfEntries;
386     ULONG AllocatedSize;
387     UCHAR Flags;
388     UCHAR Padding[3];
389 } INDEX_HEADER_ATTRIBUTE, *PINDEX_HEADER_ATTRIBUTE;
390 
391 typedef struct
392 {
393     ULONG AttributeType;
394     ULONG CollationRule;
395     ULONG SizeOfEntry;
396     UCHAR ClustersPerIndexRecord;
397     UCHAR Padding[3];
398     INDEX_HEADER_ATTRIBUTE Header;
399 } INDEX_ROOT_ATTRIBUTE, *PINDEX_ROOT_ATTRIBUTE;
400 
401 typedef struct
402 {
403     NTFS_RECORD_HEADER Ntfs;
404     ULONGLONG VCN;
405     INDEX_HEADER_ATTRIBUTE Header;
406 } INDEX_BUFFER, *PINDEX_BUFFER;
407 
408 typedef struct
409 {
410     union
411     {
412         struct
413         {
414             ULONGLONG    IndexedFile;
415         } Directory;
416         struct
417         {
418             USHORT    DataOffset;
419             USHORT    DataLength;
420             ULONG    Reserved;
421         } ViewIndex;
422     } Data;
423     USHORT            Length;
424     USHORT            KeyLength;
425     USHORT            Flags;
426     USHORT            Reserved;
427     FILENAME_ATTRIBUTE    FileName;
428 } INDEX_ENTRY_ATTRIBUTE, *PINDEX_ENTRY_ATTRIBUTE;
429 
430 struct _B_TREE_FILENAME_NODE;
431 typedef struct _B_TREE_FILENAME_NODE B_TREE_FILENAME_NODE;
432 
433 // Keys are arranged in nodes as an ordered, linked list
434 typedef struct _B_TREE_KEY
435 {
436     struct _B_TREE_KEY *NextKey;
437     B_TREE_FILENAME_NODE *LesserChild;  // Child-Node. All the keys in this node will be sorted before IndexEntry
438     PINDEX_ENTRY_ATTRIBUTE IndexEntry;  // must be last member for FIELD_OFFSET
439 }B_TREE_KEY, *PB_TREE_KEY;
440 
441 // Every Node is just an ordered list of keys.
442 // Sub-nodes can be found attached to a key (if they exist).
443 // A key's sub-node precedes that key in the ordered list.
444 typedef struct _B_TREE_FILENAME_NODE
445 {
446     ULONG KeyCount;
447     BOOLEAN HasValidVCN;
448     BOOLEAN DiskNeedsUpdating;
449     ULONGLONG VCN;
450     PB_TREE_KEY FirstKey;
451 } B_TREE_FILENAME_NODE, *PB_TREE_FILENAME_NODE;
452 
453 typedef struct
454 {
455     PB_TREE_FILENAME_NODE RootNode;
456 } B_TREE, *PB_TREE;
457 
458 typedef struct
459 {
460     ULONGLONG Unknown1;
461     UCHAR MajorVersion;
462     UCHAR MinorVersion;
463     USHORT Flags;
464     ULONG Unknown2;
465 } VOLINFO_ATTRIBUTE, *PVOLINFO_ATTRIBUTE;
466 
467 typedef struct {
468     ULONG ReparseTag;
469     USHORT DataLength;
470     USHORT Reserved;
471     UCHAR Data[1];
472 } REPARSE_POINT_ATTRIBUTE, *PREPARSE_POINT_ATTRIBUTE;
473 
474 #define IRPCONTEXT_CANWAIT 0x1
475 #define IRPCONTEXT_COMPLETE 0x2
476 #define IRPCONTEXT_QUEUE 0x4
477 
478 typedef struct
479 {
480     NTFSIDENTIFIER Identifier;
481     ULONG Flags;
482     PIO_STACK_LOCATION Stack;
483     UCHAR MajorFunction;
484     UCHAR MinorFunction;
485     WORK_QUEUE_ITEM WorkQueueItem;
486     PIRP Irp;
487     BOOLEAN IsTopLevel;
488     PDEVICE_OBJECT DeviceObject;
489     PFILE_OBJECT FileObject;
490     NTSTATUS SavedExceptionCode;
491     CCHAR PriorityBoost;
492 } NTFS_IRP_CONTEXT, *PNTFS_IRP_CONTEXT;
493 
494 typedef struct _NTFS_ATTR_CONTEXT
495 {
496     PUCHAR            CacheRun;
497     ULONGLONG            CacheRunOffset;
498     LONGLONG            CacheRunStartLCN;
499     ULONGLONG            CacheRunLength;
500     LONGLONG            CacheRunLastLCN;
501     ULONGLONG            CacheRunCurrentOffset;
502     LARGE_MCB           DataRunsMCB;
503     ULONGLONG           FileMFTIndex;
504     ULONGLONG           FileOwnerMFTIndex; /* If attribute list attribute, reference the original file */
505     PNTFS_ATTR_RECORD    pRecord;
506 } NTFS_ATTR_CONTEXT, *PNTFS_ATTR_CONTEXT;
507 
508 #define FCB_CACHE_INITIALIZED   0x0001
509 #define FCB_IS_VOLUME_STREAM    0x0002
510 #define FCB_IS_VOLUME           0x0004
511 #define MAX_PATH                260
512 
513 typedef struct _FCB
514 {
515     NTFSIDENTIFIER Identifier;
516 
517     FSRTL_COMMON_FCB_HEADER RFCB;
518     SECTION_OBJECT_POINTERS SectionObjectPointers;
519 
520     PFILE_OBJECT FileObject;
521     PNTFS_VCB Vcb;
522 
523     WCHAR Stream[MAX_PATH];
524     WCHAR *ObjectName;		/* point on filename (250 chars max) in PathName */
525     WCHAR PathName[MAX_PATH];	/* path+filename 260 max */
526 
527     ERESOURCE PagingIoResource;
528     ERESOURCE MainResource;
529 
530     LIST_ENTRY FcbListEntry;
531     struct _FCB* ParentFcb;
532 
533     ULONG DirIndex;
534 
535     LONG RefCount;
536     ULONG Flags;
537     ULONG OpenHandleCount;
538 
539     ULONGLONG MFTIndex;
540     USHORT LinkCount;
541 
542     FILENAME_ATTRIBUTE Entry;
543 
544 } NTFS_FCB, *PNTFS_FCB;
545 
546 typedef struct _FIND_ATTR_CONTXT
547 {
548     PDEVICE_EXTENSION Vcb;
549     BOOLEAN OnlyResident;
550     PNTFS_ATTR_RECORD FirstAttr;
551     PNTFS_ATTR_RECORD CurrAttr;
552     PNTFS_ATTR_RECORD LastAttr;
553     PNTFS_ATTRIBUTE_LIST_ITEM NonResidentStart;
554     PNTFS_ATTRIBUTE_LIST_ITEM NonResidentEnd;
555     PNTFS_ATTRIBUTE_LIST_ITEM NonResidentCur;
556     ULONG Offset;
557 } FIND_ATTR_CONTXT, *PFIND_ATTR_CONTXT;
558 
559 typedef struct
560 {
561     USHORT USN;
562     USHORT Array[];
563 } FIXUP_ARRAY, *PFIXUP_ARRAY;
564 
565 extern PNTFS_GLOBAL_DATA NtfsGlobalData;
566 
567 FORCEINLINE
568 NTSTATUS
NtfsMarkIrpContextForQueue(PNTFS_IRP_CONTEXT IrpContext)569 NtfsMarkIrpContextForQueue(PNTFS_IRP_CONTEXT IrpContext)
570 {
571     PULONG Flags = &IrpContext->Flags;
572 
573     *Flags &= ~IRPCONTEXT_COMPLETE;
574     *Flags |= IRPCONTEXT_QUEUE;
575 
576     return STATUS_PENDING;
577 }
578 
579 /* attrib.c */
580 
581 //VOID
582 //NtfsDumpAttribute(PATTRIBUTE Attribute);
583 
584 NTSTATUS
585 AddBitmap(PNTFS_VCB Vcb,
586           PFILE_RECORD_HEADER FileRecord,
587           PNTFS_ATTR_RECORD AttributeAddress,
588           PCWSTR Name,
589           USHORT NameLength);
590 
591 NTSTATUS
592 AddData(PFILE_RECORD_HEADER FileRecord,
593         PNTFS_ATTR_RECORD AttributeAddress);
594 
595 NTSTATUS
596 AddRun(PNTFS_VCB Vcb,
597        PNTFS_ATTR_CONTEXT AttrContext,
598        ULONG AttrOffset,
599        PFILE_RECORD_HEADER FileRecord,
600        ULONGLONG NextAssignedCluster,
601        ULONG RunLength);
602 
603 NTSTATUS
604 AddIndexAllocation(PNTFS_VCB Vcb,
605                    PFILE_RECORD_HEADER FileRecord,
606                    PNTFS_ATTR_RECORD AttributeAddress,
607                    PCWSTR Name,
608                    USHORT NameLength);
609 
610 NTSTATUS
611 AddIndexRoot(PNTFS_VCB Vcb,
612              PFILE_RECORD_HEADER FileRecord,
613              PNTFS_ATTR_RECORD AttributeAddress,
614              PINDEX_ROOT_ATTRIBUTE NewIndexRoot,
615              ULONG RootLength,
616              PCWSTR Name,
617              USHORT NameLength);
618 
619 NTSTATUS
620 AddFileName(PFILE_RECORD_HEADER FileRecord,
621             PNTFS_ATTR_RECORD AttributeAddress,
622             PDEVICE_EXTENSION DeviceExt,
623             PFILE_OBJECT FileObject,
624             BOOLEAN CaseSensitive,
625             PULONGLONG ParentMftIndex);
626 
627 NTSTATUS
628 AddStandardInformation(PFILE_RECORD_HEADER FileRecord,
629                        PNTFS_ATTR_RECORD AttributeAddress);
630 
631 NTSTATUS
632 ConvertDataRunsToLargeMCB(PUCHAR DataRun,
633                           PLARGE_MCB DataRunsMCB,
634                           PULONGLONG pNextVBN);
635 
636 NTSTATUS
637 ConvertLargeMCBToDataRuns(PLARGE_MCB DataRunsMCB,
638                           PUCHAR RunBuffer,
639                           ULONG MaxBufferSize,
640                           PULONG UsedBufferSize);
641 
642 PUCHAR
643 DecodeRun(PUCHAR DataRun,
644           LONGLONG *DataRunOffset,
645           ULONGLONG *DataRunLength);
646 
647 ULONG GetFileNameAttributeLength(PFILENAME_ATTRIBUTE FileNameAttribute);
648 
649 VOID
650 NtfsDumpDataRuns(PVOID StartOfRun,
651                  ULONGLONG CurrentLCN);
652 
653 VOID
654 NtfsDumpFileAttributes(PDEVICE_EXTENSION Vcb,
655                        PFILE_RECORD_HEADER FileRecord);
656 
657 PSTANDARD_INFORMATION
658 GetStandardInformationFromRecord(PDEVICE_EXTENSION Vcb,
659                                  PFILE_RECORD_HEADER FileRecord);
660 
661 PFILENAME_ATTRIBUTE
662 GetFileNameFromRecord(PDEVICE_EXTENSION Vcb,
663                       PFILE_RECORD_HEADER FileRecord,
664                       UCHAR NameType);
665 
666 UCHAR
667 GetPackedByteCount(LONGLONG NumberToPack,
668                    BOOLEAN IsSigned);
669 
670 NTSTATUS
671 GetLastClusterInDataRun(PDEVICE_EXTENSION Vcb,
672                         PNTFS_ATTR_RECORD Attribute,
673                         PULONGLONG LastCluster);
674 
675 PFILENAME_ATTRIBUTE
676 GetBestFileNameFromRecord(PDEVICE_EXTENSION Vcb,
677                           PFILE_RECORD_HEADER FileRecord);
678 
679 NTSTATUS
680 FindFirstAttributeListItem(PFIND_ATTR_CONTXT Context,
681                            PNTFS_ATTRIBUTE_LIST_ITEM *Item);
682 
683 NTSTATUS
684 FindNextAttributeListItem(PFIND_ATTR_CONTXT Context,
685                           PNTFS_ATTRIBUTE_LIST_ITEM *Item);
686 
687 NTSTATUS
688 FindFirstAttribute(PFIND_ATTR_CONTXT Context,
689                    PDEVICE_EXTENSION Vcb,
690                    PFILE_RECORD_HEADER FileRecord,
691                    BOOLEAN OnlyResident,
692                    PNTFS_ATTR_RECORD * Attribute);
693 
694 NTSTATUS
695 FindNextAttribute(PFIND_ATTR_CONTXT Context,
696                   PNTFS_ATTR_RECORD * Attribute);
697 
698 VOID
699 FindCloseAttribute(PFIND_ATTR_CONTXT Context);
700 
701 NTSTATUS
702 FreeClusters(PNTFS_VCB Vcb,
703              PNTFS_ATTR_CONTEXT AttrContext,
704              ULONG AttrOffset,
705              PFILE_RECORD_HEADER FileRecord,
706              ULONG ClustersToFree);
707 
708 /* blockdev.c */
709 
710 NTSTATUS
711 NtfsReadDisk(IN PDEVICE_OBJECT DeviceObject,
712              IN LONGLONG StartingOffset,
713              IN ULONG Length,
714              IN ULONG SectorSize,
715              IN OUT PUCHAR Buffer,
716              IN BOOLEAN Override);
717 
718 NTSTATUS
719 NtfsWriteDisk(IN PDEVICE_OBJECT DeviceObject,
720               IN LONGLONG StartingOffset,
721               IN ULONG Length,
722               IN ULONG SectorSize,
723               IN const PUCHAR Buffer);
724 
725 NTSTATUS
726 NtfsReadSectors(IN PDEVICE_OBJECT DeviceObject,
727                 IN ULONG DiskSector,
728                 IN ULONG SectorCount,
729                 IN ULONG SectorSize,
730                 IN OUT PUCHAR Buffer,
731                 IN BOOLEAN Override);
732 
733 NTSTATUS
734 NtfsDeviceIoControl(IN PDEVICE_OBJECT DeviceObject,
735                     IN ULONG ControlCode,
736                     IN PVOID InputBuffer,
737                     IN ULONG InputBufferSize,
738                     IN OUT PVOID OutputBuffer,
739                     IN OUT PULONG OutputBufferSize,
740                     IN BOOLEAN Override);
741 
742 
743 /* btree.c */
744 
745 LONG
746 CompareTreeKeys(PB_TREE_KEY Key1,
747                 PB_TREE_KEY Key2,
748                 BOOLEAN CaseSensitive);
749 
750 NTSTATUS
751 CreateBTreeFromIndex(PDEVICE_EXTENSION Vcb,
752                      PFILE_RECORD_HEADER FileRecordWithIndex,
753                      /*PCWSTR IndexName,*/
754                      PNTFS_ATTR_CONTEXT IndexRootContext,
755                      PINDEX_ROOT_ATTRIBUTE IndexRoot,
756                      PB_TREE *NewTree);
757 
758 NTSTATUS
759 CreateIndexRootFromBTree(PDEVICE_EXTENSION DeviceExt,
760                          PB_TREE Tree,
761                          ULONG MaxIndexSize,
762                          PINDEX_ROOT_ATTRIBUTE *IndexRoot,
763                          ULONG *Length);
764 
765 NTSTATUS
766 DemoteBTreeRoot(PB_TREE Tree);
767 
768 VOID
769 DestroyBTree(PB_TREE Tree);
770 
771 VOID
772 DestroyBTreeNode(PB_TREE_FILENAME_NODE Node);
773 
774 VOID
775 DumpBTree(PB_TREE Tree);
776 
777 VOID
778 DumpBTreeKey(PB_TREE Tree,
779              PB_TREE_KEY Key,
780              ULONG Number,
781              ULONG Depth);
782 
783 VOID
784 DumpBTreeNode(PB_TREE Tree,
785               PB_TREE_FILENAME_NODE Node,
786               ULONG Number,
787               ULONG Depth);
788 
789 NTSTATUS
790 CreateEmptyBTree(PB_TREE *NewTree);
791 
792 ULONGLONG
793 GetAllocationOffsetFromVCN(PDEVICE_EXTENSION DeviceExt,
794                            ULONG IndexBufferSize,
795                            ULONGLONG Vcn);
796 
797 ULONGLONG
798 GetIndexEntryVCN(PINDEX_ENTRY_ATTRIBUTE IndexEntry);
799 
800 ULONG
801 GetSizeOfIndexEntries(PB_TREE_FILENAME_NODE Node);
802 
803 NTSTATUS
804 NtfsInsertKey(PB_TREE Tree,
805               ULONGLONG FileReference,
806               PFILENAME_ATTRIBUTE FileNameAttribute,
807               PB_TREE_FILENAME_NODE Node,
808               BOOLEAN CaseSensitive,
809               ULONG MaxIndexRootSize,
810               ULONG IndexRecordSize,
811               PB_TREE_KEY *MedianKey,
812               PB_TREE_FILENAME_NODE *NewRightHandSibling);
813 
814 NTSTATUS
815 SplitBTreeNode(PB_TREE Tree,
816                PB_TREE_FILENAME_NODE Node,
817                PB_TREE_KEY *MedianKey,
818                PB_TREE_FILENAME_NODE *NewRightHandSibling,
819                BOOLEAN CaseSensitive);
820 
821 NTSTATUS
822 UpdateIndexAllocation(PDEVICE_EXTENSION DeviceExt,
823                       PB_TREE Tree,
824                       ULONG IndexBufferSize,
825                       PFILE_RECORD_HEADER FileRecord);
826 
827 NTSTATUS
828 UpdateIndexNode(PDEVICE_EXTENSION DeviceExt,
829                 PFILE_RECORD_HEADER FileRecord,
830                 PB_TREE_FILENAME_NODE Node,
831                 ULONG IndexBufferSize,
832                 PNTFS_ATTR_CONTEXT IndexAllocationContext,
833                 ULONG IndexAllocationOffset);
834 
835 /* close.c */
836 
837 NTSTATUS
838 NtfsCleanup(PNTFS_IRP_CONTEXT IrpContext);
839 
840 
841 /* close.c */
842 
843 NTSTATUS
844 NtfsCloseFile(PDEVICE_EXTENSION DeviceExt,
845               PFILE_OBJECT FileObject);
846 
847 NTSTATUS
848 NtfsClose(PNTFS_IRP_CONTEXT IrpContext);
849 
850 
851 /* create.c */
852 
853 NTSTATUS
854 NtfsCreate(PNTFS_IRP_CONTEXT IrpContext);
855 
856 NTSTATUS
857 NtfsCreateDirectory(PDEVICE_EXTENSION DeviceExt,
858                     PFILE_OBJECT FileObject,
859                     BOOLEAN CaseSensitive,
860                     BOOLEAN CanWait);
861 
862 PFILE_RECORD_HEADER
863 NtfsCreateEmptyFileRecord(PDEVICE_EXTENSION DeviceExt);
864 
865 NTSTATUS
866 NtfsCreateFileRecord(PDEVICE_EXTENSION DeviceExt,
867                      PFILE_OBJECT FileObject,
868                      BOOLEAN CaseSensitive,
869                      BOOLEAN CanWait);
870 
871 /* devctl.c */
872 
873 NTSTATUS
874 NtfsDeviceControl(PNTFS_IRP_CONTEXT IrpContext);
875 
876 
877 /* dirctl.c */
878 
879 ULONGLONG
880 NtfsGetFileSize(PDEVICE_EXTENSION DeviceExt,
881                 PFILE_RECORD_HEADER FileRecord,
882                 PCWSTR Stream,
883                 ULONG StreamLength,
884                 PULONGLONG AllocatedSize);
885 
886 NTSTATUS
887 NtfsDirectoryControl(PNTFS_IRP_CONTEXT IrpContext);
888 
889 
890 /* dispatch.c */
891 
892 DRIVER_DISPATCH NtfsFsdDispatch;
893 NTSTATUS NTAPI
894 NtfsFsdDispatch(PDEVICE_OBJECT DeviceObject,
895                 PIRP Irp);
896 
897 
898 /* fastio.c */
899 
900 BOOLEAN NTAPI
901 NtfsAcqLazyWrite(PVOID Context,
902                  BOOLEAN Wait);
903 
904 VOID NTAPI
905 NtfsRelLazyWrite(PVOID Context);
906 
907 BOOLEAN NTAPI
908 NtfsAcqReadAhead(PVOID Context,
909                  BOOLEAN Wait);
910 
911 VOID NTAPI
912 NtfsRelReadAhead(PVOID Context);
913 
914 FAST_IO_CHECK_IF_POSSIBLE NtfsFastIoCheckIfPossible;
915 FAST_IO_READ NtfsFastIoRead;
916 FAST_IO_WRITE NtfsFastIoWrite;
917 
918 
919 /* fcb.c */
920 
921 PNTFS_FCB
922 NtfsCreateFCB(PCWSTR FileName,
923               PCWSTR Stream,
924               PNTFS_VCB Vcb);
925 
926 VOID
927 NtfsDestroyFCB(PNTFS_FCB Fcb);
928 
929 BOOLEAN
930 NtfsFCBIsDirectory(PNTFS_FCB Fcb);
931 
932 BOOLEAN
933 NtfsFCBIsReparsePoint(PNTFS_FCB Fcb);
934 
935 BOOLEAN
936 NtfsFCBIsCompressed(PNTFS_FCB Fcb);
937 
938 BOOLEAN
939 NtfsFCBIsEncrypted(PNTFS_FCB Fcb);
940 
941 BOOLEAN
942 NtfsFCBIsRoot(PNTFS_FCB Fcb);
943 
944 VOID
945 NtfsGrabFCB(PNTFS_VCB Vcb,
946             PNTFS_FCB Fcb);
947 
948 VOID
949 NtfsReleaseFCB(PNTFS_VCB Vcb,
950                PNTFS_FCB Fcb);
951 
952 VOID
953 NtfsAddFCBToTable(PNTFS_VCB Vcb,
954                   PNTFS_FCB Fcb);
955 
956 PNTFS_FCB
957 NtfsGrabFCBFromTable(PNTFS_VCB Vcb,
958                      PCWSTR FileName);
959 
960 NTSTATUS
961 NtfsFCBInitializeCache(PNTFS_VCB Vcb,
962                        PNTFS_FCB Fcb);
963 
964 PNTFS_FCB
965 NtfsMakeRootFCB(PNTFS_VCB Vcb);
966 
967 PNTFS_FCB
968 NtfsOpenRootFCB(PNTFS_VCB Vcb);
969 
970 NTSTATUS
971 NtfsAttachFCBToFileObject(PNTFS_VCB Vcb,
972                           PNTFS_FCB Fcb,
973                           PFILE_OBJECT FileObject);
974 
975 NTSTATUS
976 NtfsGetFCBForFile(PNTFS_VCB Vcb,
977                   PNTFS_FCB *pParentFCB,
978                   PNTFS_FCB *pFCB,
979                   PCWSTR pFileName,
980                   BOOLEAN CaseSensitive);
981 
982 NTSTATUS
983 NtfsReadFCBAttribute(PNTFS_VCB Vcb,
984                      PNTFS_FCB pFCB,
985                      ULONG Type,
986                      PCWSTR Name,
987                      ULONG NameLength,
988                      PVOID * Data);
989 
990 NTSTATUS
991 NtfsMakeFCBFromDirEntry(PNTFS_VCB Vcb,
992                         PNTFS_FCB DirectoryFCB,
993                         PUNICODE_STRING Name,
994                         PCWSTR Stream,
995                         PFILE_RECORD_HEADER Record,
996                         ULONGLONG MFTIndex,
997                         PNTFS_FCB * fileFCB);
998 
999 
1000 /* finfo.c */
1001 
1002 NTSTATUS
1003 NtfsQueryInformation(PNTFS_IRP_CONTEXT IrpContext);
1004 
1005 NTSTATUS
1006 NtfsSetEndOfFile(PNTFS_FCB Fcb,
1007                  PFILE_OBJECT FileObject,
1008                  PDEVICE_EXTENSION DeviceExt,
1009                  ULONG IrpFlags,
1010                  BOOLEAN CaseSensitive,
1011                  PLARGE_INTEGER NewFileSize);
1012 
1013 NTSTATUS
1014 NtfsSetInformation(PNTFS_IRP_CONTEXT IrpContext);
1015 
1016 /* fsctl.c */
1017 
1018 NTSTATUS
1019 NtfsFileSystemControl(PNTFS_IRP_CONTEXT IrpContext);
1020 
1021 
1022 /* mft.c */
1023 NTSTATUS
1024 NtfsAddFilenameToDirectory(PDEVICE_EXTENSION DeviceExt,
1025                            ULONGLONG DirectoryMftIndex,
1026                            ULONGLONG FileReferenceNumber,
1027                            PFILENAME_ATTRIBUTE FilenameAttribute,
1028                            BOOLEAN CaseSensitive);
1029 
1030 NTSTATUS
1031 AddNewMftEntry(PFILE_RECORD_HEADER FileRecord,
1032                PDEVICE_EXTENSION DeviceExt,
1033                PULONGLONG DestinationIndex,
1034                BOOLEAN CanWait);
1035 
1036 VOID
1037 NtfsDumpData(ULONG_PTR Buffer, ULONG Length);
1038 
1039 PNTFS_ATTR_CONTEXT
1040 PrepareAttributeContext(PNTFS_ATTR_RECORD AttrRecord);
1041 
1042 VOID
1043 ReleaseAttributeContext(PNTFS_ATTR_CONTEXT Context);
1044 
1045 ULONG
1046 ReadAttribute(PDEVICE_EXTENSION Vcb,
1047               PNTFS_ATTR_CONTEXT Context,
1048               ULONGLONG Offset,
1049               PCHAR Buffer,
1050               ULONG Length);
1051 
1052 NTSTATUS
1053 WriteAttribute(PDEVICE_EXTENSION Vcb,
1054                PNTFS_ATTR_CONTEXT Context,
1055                ULONGLONG Offset,
1056                const PUCHAR Buffer,
1057                ULONG Length,
1058                PULONG LengthWritten,
1059                PFILE_RECORD_HEADER FileRecord);
1060 
1061 ULONGLONG
1062 AttributeDataLength(PNTFS_ATTR_RECORD AttrRecord);
1063 
1064 NTSTATUS
1065 InternalSetResidentAttributeLength(PDEVICE_EXTENSION DeviceExt,
1066                                    PNTFS_ATTR_CONTEXT AttrContext,
1067                                    PFILE_RECORD_HEADER FileRecord,
1068                                    ULONG AttrOffset,
1069                                    ULONG DataSize);
1070 
1071 PNTFS_ATTR_RECORD
1072 MoveAttributes(PDEVICE_EXTENSION DeviceExt,
1073                PNTFS_ATTR_RECORD FirstAttributeToMove,
1074                ULONG FirstAttributeOffset,
1075                ULONG_PTR MoveTo);
1076 
1077 NTSTATUS
1078 SetAttributeDataLength(PFILE_OBJECT FileObject,
1079                        PNTFS_FCB Fcb,
1080                        PNTFS_ATTR_CONTEXT AttrContext,
1081                        ULONG AttrOffset,
1082                        PFILE_RECORD_HEADER FileRecord,
1083                        PLARGE_INTEGER DataSize);
1084 
1085 VOID
1086 SetFileRecordEnd(PFILE_RECORD_HEADER FileRecord,
1087                  PNTFS_ATTR_RECORD AttrEnd,
1088                  ULONG EndMarker);
1089 
1090 NTSTATUS
1091 SetNonResidentAttributeDataLength(PDEVICE_EXTENSION Vcb,
1092                                   PNTFS_ATTR_CONTEXT AttrContext,
1093                                   ULONG AttrOffset,
1094                                   PFILE_RECORD_HEADER FileRecord,
1095                                   PLARGE_INTEGER DataSize);
1096 
1097 NTSTATUS
1098 SetResidentAttributeDataLength(PDEVICE_EXTENSION Vcb,
1099                                PNTFS_ATTR_CONTEXT AttrContext,
1100                                ULONG AttrOffset,
1101                                PFILE_RECORD_HEADER FileRecord,
1102                                PLARGE_INTEGER DataSize);
1103 
1104 ULONGLONG
1105 AttributeAllocatedLength(PNTFS_ATTR_RECORD AttrRecord);
1106 
1107 BOOLEAN
1108 CompareFileName(PUNICODE_STRING FileName,
1109                 PINDEX_ENTRY_ATTRIBUTE IndexEntry,
1110                 BOOLEAN DirSearch,
1111                 BOOLEAN CaseSensitive);
1112 
1113 NTSTATUS
1114 UpdateMftMirror(PNTFS_VCB Vcb);
1115 
1116 NTSTATUS
1117 ReadFileRecord(PDEVICE_EXTENSION Vcb,
1118                ULONGLONG index,
1119                PFILE_RECORD_HEADER file);
1120 
1121 NTSTATUS
1122 UpdateIndexEntryFileNameSize(PDEVICE_EXTENSION Vcb,
1123                              PFILE_RECORD_HEADER MftRecord,
1124                              PCHAR IndexRecord,
1125                              ULONG IndexBlockSize,
1126                              PINDEX_ENTRY_ATTRIBUTE FirstEntry,
1127                              PINDEX_ENTRY_ATTRIBUTE LastEntry,
1128                              PUNICODE_STRING FileName,
1129                              PULONG StartEntry,
1130                              PULONG CurrentEntry,
1131                              BOOLEAN DirSearch,
1132                              ULONGLONG NewDataSize,
1133                              ULONGLONG NewAllocatedSize,
1134                              BOOLEAN CaseSensitive);
1135 
1136 NTSTATUS
1137 UpdateFileNameRecord(PDEVICE_EXTENSION Vcb,
1138                      ULONGLONG ParentMFTIndex,
1139                      PUNICODE_STRING FileName,
1140                      BOOLEAN DirSearch,
1141                      ULONGLONG NewDataSize,
1142                      ULONGLONG NewAllocationSize,
1143                      BOOLEAN CaseSensitive);
1144 
1145 NTSTATUS
1146 UpdateFileRecord(PDEVICE_EXTENSION Vcb,
1147                  ULONGLONG MftIndex,
1148                  PFILE_RECORD_HEADER FileRecord);
1149 
1150 NTSTATUS
1151 FindAttribute(PDEVICE_EXTENSION Vcb,
1152               PFILE_RECORD_HEADER MftRecord,
1153               ULONG Type,
1154               PCWSTR Name,
1155               ULONG NameLength,
1156               PNTFS_ATTR_CONTEXT * AttrCtx,
1157               PULONG Offset);
1158 
1159 VOID
1160 ReadVCN(PDEVICE_EXTENSION Vcb,
1161         PFILE_RECORD_HEADER file,
1162         ATTRIBUTE_TYPE type,
1163         ULONGLONG vcn,
1164         ULONG count,
1165         PVOID buffer);
1166 
1167 NTSTATUS
1168 FixupUpdateSequenceArray(PDEVICE_EXTENSION Vcb,
1169                          PNTFS_RECORD_HEADER Record);
1170 
1171 NTSTATUS
1172 AddFixupArray(PDEVICE_EXTENSION Vcb,
1173               PNTFS_RECORD_HEADER Record);
1174 
1175 NTSTATUS
1176 ReadLCN(PDEVICE_EXTENSION Vcb,
1177         ULONGLONG lcn,
1178         ULONG count,
1179         PVOID buffer);
1180 
1181 VOID
1182 EnumerAttribute(PFILE_RECORD_HEADER file,
1183                 PDEVICE_EXTENSION Vcb,
1184                 PDEVICE_OBJECT DeviceObject);
1185 
1186 NTSTATUS
1187 NtfsLookupFile(PDEVICE_EXTENSION Vcb,
1188                PUNICODE_STRING PathName,
1189                BOOLEAN CaseSensitive,
1190                PFILE_RECORD_HEADER *FileRecord,
1191                PULONGLONG MFTIndex);
1192 
1193 NTSTATUS
1194 NtfsLookupFileAt(PDEVICE_EXTENSION Vcb,
1195                  PUNICODE_STRING PathName,
1196                  BOOLEAN CaseSensitive,
1197                  PFILE_RECORD_HEADER *FileRecord,
1198                  PULONGLONG MFTIndex,
1199                  ULONGLONG CurrentMFTIndex);
1200 
1201 VOID
1202 NtfsDumpFileRecord(PDEVICE_EXTENSION Vcb,
1203                    PFILE_RECORD_HEADER FileRecord);
1204 
1205 NTSTATUS
1206 NtfsFindFileAt(PDEVICE_EXTENSION Vcb,
1207                PUNICODE_STRING SearchPattern,
1208                PULONG FirstEntry,
1209                PFILE_RECORD_HEADER *FileRecord,
1210                PULONGLONG MFTIndex,
1211                ULONGLONG CurrentMFTIndex,
1212                BOOLEAN CaseSensitive);
1213 
1214 NTSTATUS
1215 NtfsFindMftRecord(PDEVICE_EXTENSION Vcb,
1216                   ULONGLONG MFTIndex,
1217                   PUNICODE_STRING FileName,
1218                   PULONG FirstEntry,
1219                   BOOLEAN DirSearch,
1220                   BOOLEAN CaseSensitive,
1221                   ULONGLONG *OutMFTIndex);
1222 
1223 /* misc.c */
1224 
1225 BOOLEAN
1226 NtfsIsIrpTopLevel(PIRP Irp);
1227 
1228 PNTFS_IRP_CONTEXT
1229 NtfsAllocateIrpContext(PDEVICE_OBJECT DeviceObject,
1230                        PIRP Irp);
1231 
1232 PVOID
1233 NtfsGetUserBuffer(PIRP Irp,
1234                   BOOLEAN Paging);
1235 
1236 NTSTATUS
1237 NtfsLockUserBuffer(IN PIRP Irp,
1238                    IN ULONG Length,
1239                    IN LOCK_OPERATION Operation);
1240 
1241 #if 0
1242 BOOLEAN
1243 wstrcmpjoki(PWSTR s1, PWSTR s2);
1244 
1245 VOID
1246 CdfsSwapString(PWCHAR Out,
1247 	       PUCHAR In,
1248 	       ULONG Count);
1249 #endif
1250 
1251 VOID
1252 NtfsFileFlagsToAttributes(ULONG NtfsAttributes,
1253                           PULONG FileAttributes);
1254 
1255 
1256 /* rw.c */
1257 
1258 NTSTATUS
1259 NtfsRead(PNTFS_IRP_CONTEXT IrpContext);
1260 
1261 NTSTATUS
1262 NtfsWrite(PNTFS_IRP_CONTEXT IrpContext);
1263 
1264 
1265 /* volinfo.c */
1266 
1267 NTSTATUS
1268 NtfsAllocateClusters(PDEVICE_EXTENSION DeviceExt,
1269                      ULONG FirstDesiredCluster,
1270                      ULONG DesiredClusters,
1271                      PULONG FirstAssignedCluster,
1272                      PULONG AssignedClusters);
1273 
1274 ULONGLONG
1275 NtfsGetFreeClusters(PDEVICE_EXTENSION DeviceExt);
1276 
1277 NTSTATUS
1278 NtfsQueryVolumeInformation(PNTFS_IRP_CONTEXT IrpContext);
1279 
1280 NTSTATUS
1281 NtfsSetVolumeInformation(PNTFS_IRP_CONTEXT IrpContext);
1282 
1283 
1284 /* ntfs.c */
1285 
1286 CODE_SEG("INIT")
1287 DRIVER_INITIALIZE DriverEntry;
1288 
1289 CODE_SEG("INIT")
1290 VOID
1291 NTAPI
1292 NtfsInitializeFunctionPointers(PDRIVER_OBJECT DriverObject);
1293 
1294 #endif /* NTFS_H */
1295