[NTFS]
[reactos.git] / drivers / filesystems / ntfs / ntfs.h
1 #ifndef NTFS_H
2 #define NTFS_H
3
4 #include <ntifs.h>
5 #include <pseh/pseh2.h>
6
7 #ifdef __GNUC__
8 #define INIT_SECTION __attribute__((section ("INIT")))
9 #else
10 #define INIT_SECTION /* Done via alloc_text for MSC */
11 #endif
12
13 #define CACHEPAGESIZE(pDeviceExt) \
14 ((pDeviceExt)->NtfsInfo.UCHARsPerCluster > PAGE_SIZE ? \
15 (pDeviceExt)->NtfsInfo.UCHARsPerCluster : PAGE_SIZE)
16
17 #define TAG_NTFS 'SFTN'
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 ULONG Flags;
120 ULONG OpenHandleCount;
121
122 } DEVICE_EXTENSION, *PDEVICE_EXTENSION, NTFS_VCB, *PNTFS_VCB;
123
124 #define VCB_VOLUME_LOCKED 0x0001
125
126 typedef struct
127 {
128 NTFSIDENTIFIER Identifier;
129 LIST_ENTRY NextCCB;
130 PFILE_OBJECT PtrFileObject;
131 LARGE_INTEGER CurrentByteOffset;
132 /* for DirectoryControl */
133 ULONG Entry;
134 /* for DirectoryControl */
135 PWCHAR DirectorySearchPattern;
136 ULONG LastCluster;
137 ULONG LastOffset;
138 } NTFS_CCB, *PNTFS_CCB;
139
140 #define TAG_CCB 'BCCI'
141 #define TAG_FCB 'BCFI'
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 } NTFS_GLOBAL_DATA, *PNTFS_GLOBAL_DATA;
155
156
157 typedef enum
158 {
159 AttributeStandardInformation = 0x10,
160 AttributeAttributeList = 0x20,
161 AttributeFileName = 0x30,
162 AttributeObjectId = 0x40,
163 AttributeSecurityDescriptor = 0x50,
164 AttributeVolumeName = 0x60,
165 AttributeVolumeInformation = 0x70,
166 AttributeData = 0x80,
167 AttributeIndexRoot = 0x90,
168 AttributeIndexAllocation = 0xA0,
169 AttributeBitmap = 0xB0,
170 AttributeReparsePoint = 0xC0,
171 AttributeEAInformation = 0xD0,
172 AttributeEA = 0xE0,
173 AttributePropertySet = 0xF0,
174 AttributeLoggedUtilityStream = 0x100,
175 AttributeEnd = 0xFFFFFFFF
176 } ATTRIBUTE_TYPE, *PATTRIBUTE_TYPE;
177
178 // FILE_RECORD_END seems to follow AttributeEnd in every file record starting with $Quota.
179 // No clue what data is being represented here.
180 #define FILE_RECORD_END 0x11477982
181
182 #define NTFS_FILE_MFT 0
183 #define NTFS_FILE_MFTMIRR 1
184 #define NTFS_FILE_LOGFILE 2
185 #define NTFS_FILE_VOLUME 3
186 #define NTFS_FILE_ATTRDEF 4
187 #define NTFS_FILE_ROOT 5
188 #define NTFS_FILE_BITMAP 6
189 #define NTFS_FILE_BOOT 7
190 #define NTFS_FILE_BADCLUS 8
191 #define NTFS_FILE_QUOTA 9
192 #define NTFS_FILE_UPCASE 10
193 #define NTFS_FILE_EXTEND 11
194
195 #define NTFS_MFT_MASK 0x0000FFFFFFFFFFFFULL
196
197 #define COLLATION_BINARY 0x00
198 #define COLLATION_FILE_NAME 0x01
199 #define COLLATION_UNICODE_STRING 0x02
200 #define COLLATION_NTOFS_ULONG 0x10
201 #define COLLATION_NTOFS_SID 0x11
202 #define COLLATION_NTOFS_SECURITY_HASH 0x12
203 #define COLLATION_NTOFS_ULONGS 0x13
204
205 #define INDEX_ROOT_SMALL 0x0
206 #define INDEX_ROOT_LARGE 0x1
207
208 #define NTFS_INDEX_ENTRY_NODE 1
209 #define NTFS_INDEX_ENTRY_END 2
210
211 #define NTFS_FILE_NAME_POSIX 0
212 #define NTFS_FILE_NAME_WIN32 1
213 #define NTFS_FILE_NAME_DOS 2
214 #define NTFS_FILE_NAME_WIN32_AND_DOS 3
215
216 #define NTFS_FILE_TYPE_READ_ONLY 0x1
217 #define NTFS_FILE_TYPE_HIDDEN 0x2
218 #define NTFS_FILE_TYPE_SYSTEM 0x4
219 #define NTFS_FILE_TYPE_ARCHIVE 0x20
220 #define NTFS_FILE_TYPE_REPARSE 0x400
221 #define NTFS_FILE_TYPE_COMPRESSED 0x800
222 #define NTFS_FILE_TYPE_DIRECTORY 0x10000000
223
224 typedef struct
225 {
226 ULONG Type; /* Magic number 'FILE' */
227 USHORT UsaOffset; /* Offset to the update sequence */
228 USHORT UsaCount; /* Size in words of Update Sequence Number & Array (S) */
229 ULONGLONG Lsn; /* $LogFile Sequence Number (LSN) */
230 } NTFS_RECORD_HEADER, *PNTFS_RECORD_HEADER;
231
232 /* NTFS_RECORD_HEADER.Type */
233 #define NRH_FILE_TYPE 0x454C4946 /* 'FILE' */
234 #define NRH_INDX_TYPE 0x58444E49 /* 'INDX' */
235
236
237 typedef struct _FILE_RECORD_HEADER
238 {
239 NTFS_RECORD_HEADER Ntfs;
240 USHORT SequenceNumber; /* Sequence number */
241 USHORT LinkCount; /* Hard link count */
242 USHORT AttributeOffset; /* Offset to the first Attribute */
243 USHORT Flags; /* Flags */
244 ULONG BytesInUse; /* Real size of the FILE record */
245 ULONG BytesAllocated; /* Allocated size of the FILE record */
246 ULONGLONG BaseFileRecord; /* File reference to the base FILE record */
247 USHORT NextAttributeNumber; /* Next Attribute Id */
248 USHORT Padding; /* Align to 4 UCHAR boundary (XP) */
249 ULONG MFTRecordNumber; /* Number of this MFT Record (XP) */
250 } FILE_RECORD_HEADER, *PFILE_RECORD_HEADER;
251
252 /* Flags in FILE_RECORD_HEADER */
253
254 #define FRH_IN_USE 0x0001 /* Record is in use */
255 #define FRH_DIRECTORY 0x0002 /* Record is a directory */
256 #define FRH_UNKNOWN1 0x0004 /* Don't know */
257 #define FRH_UNKNOWN2 0x0008 /* Don't know */
258
259 typedef struct
260 {
261 ULONG Type;
262 ULONG Length;
263 UCHAR IsNonResident;
264 UCHAR NameLength;
265 USHORT NameOffset;
266 USHORT Flags;
267 USHORT Instance;
268 union
269 {
270 // Resident attributes
271 struct
272 {
273 ULONG ValueLength;
274 USHORT ValueOffset;
275 UCHAR Flags;
276 UCHAR Reserved;
277 } Resident;
278 // Non-resident attributes
279 struct
280 {
281 ULONGLONG LowestVCN;
282 ULONGLONG HighestVCN;
283 USHORT MappingPairsOffset;
284 USHORT CompressionUnit;
285 UCHAR Reserved[4];
286 LONGLONG AllocatedSize;
287 LONGLONG DataSize;
288 LONGLONG InitializedSize;
289 LONGLONG CompressedSize;
290 } NonResident;
291 };
292 } NTFS_ATTR_RECORD, *PNTFS_ATTR_RECORD;
293
294 typedef struct
295 {
296 ULONGLONG CreationTime;
297 ULONGLONG ChangeTime;
298 ULONGLONG LastWriteTime;
299 ULONGLONG LastAccessTime;
300 ULONG FileAttribute;
301 ULONG AlignmentOrReserved[3];
302 #if 0
303 ULONG QuotaId;
304 ULONG SecurityId;
305 ULONGLONG QuotaCharge;
306 USN Usn;
307 #endif
308 } STANDARD_INFORMATION, *PSTANDARD_INFORMATION;
309
310
311 typedef struct
312 {
313 ATTRIBUTE_TYPE AttributeType;
314 USHORT Length;
315 UCHAR NameLength;
316 UCHAR NameOffset;
317 ULONGLONG StartVcn; // LowVcn
318 ULONGLONG FileReferenceNumber;
319 USHORT AttributeNumber;
320 USHORT AlignmentOrReserved[3];
321 } ATTRIBUTE_LIST, *PATTRIBUTE_LIST;
322
323
324 typedef struct
325 {
326 ULONGLONG DirectoryFileReferenceNumber;
327 ULONGLONG CreationTime;
328 ULONGLONG ChangeTime;
329 ULONGLONG LastWriteTime;
330 ULONGLONG LastAccessTime;
331 ULONGLONG AllocatedSize;
332 ULONGLONG DataSize;
333 ULONG FileAttributes;
334 union
335 {
336 struct
337 {
338 USHORT PackedEaSize;
339 USHORT AlignmentOrReserved;
340 } EaInfo;
341 ULONG ReparseTag;
342 } Extended;
343 UCHAR NameLength;
344 UCHAR NameType;
345 WCHAR Name[1];
346 } FILENAME_ATTRIBUTE, *PFILENAME_ATTRIBUTE;
347
348 typedef struct
349 {
350 ULONG FirstEntryOffset;
351 ULONG TotalSizeOfEntries;
352 ULONG AllocatedSize;
353 UCHAR Flags;
354 UCHAR Padding[3];
355 } INDEX_HEADER_ATTRIBUTE, *PINDEX_HEADER_ATTRIBUTE;
356
357 typedef struct
358 {
359 ULONG AttributeType;
360 ULONG CollationRule;
361 ULONG SizeOfEntry;
362 UCHAR ClustersPerIndexRecord;
363 UCHAR Padding[3];
364 INDEX_HEADER_ATTRIBUTE Header;
365 } INDEX_ROOT_ATTRIBUTE, *PINDEX_ROOT_ATTRIBUTE;
366
367 typedef struct
368 {
369 NTFS_RECORD_HEADER Ntfs;
370 ULONGLONG VCN;
371 INDEX_HEADER_ATTRIBUTE Header;
372 } INDEX_BUFFER, *PINDEX_BUFFER;
373
374 typedef struct
375 {
376 union
377 {
378 struct
379 {
380 ULONGLONG IndexedFile;
381 } Directory;
382 struct
383 {
384 USHORT DataOffset;
385 USHORT DataLength;
386 ULONG Reserved;
387 } ViewIndex;
388 } Data;
389 USHORT Length;
390 USHORT KeyLength;
391 USHORT Flags;
392 USHORT Reserved;
393 FILENAME_ATTRIBUTE FileName;
394 } INDEX_ENTRY_ATTRIBUTE, *PINDEX_ENTRY_ATTRIBUTE;
395
396 typedef struct
397 {
398 ULONGLONG Unknown1;
399 UCHAR MajorVersion;
400 UCHAR MinorVersion;
401 USHORT Flags;
402 ULONG Unknown2;
403 } VOLINFO_ATTRIBUTE, *PVOLINFO_ATTRIBUTE;
404
405 typedef struct {
406 ULONG ReparseTag;
407 USHORT DataLength;
408 USHORT Reserved;
409 UCHAR Data[1];
410 } REPARSE_POINT_ATTRIBUTE, *PREPARSE_POINT_ATTRIBUTE;
411
412 #define IRPCONTEXT_CANWAIT 0x1
413 #define IRPCONTEXT_COMPLETE 0x2
414 #define IRPCONTEXT_QUEUE 0x4
415
416 typedef struct
417 {
418 NTFSIDENTIFIER Identifier;
419 ULONG Flags;
420 PIO_STACK_LOCATION Stack;
421 UCHAR MajorFunction;
422 UCHAR MinorFunction;
423 WORK_QUEUE_ITEM WorkQueueItem;
424 PIRP Irp;
425 BOOLEAN IsTopLevel;
426 PDEVICE_OBJECT DeviceObject;
427 PFILE_OBJECT FileObject;
428 NTSTATUS SavedExceptionCode;
429 CCHAR PriorityBoost;
430 } NTFS_IRP_CONTEXT, *PNTFS_IRP_CONTEXT;
431
432 typedef struct _NTFS_ATTR_CONTEXT
433 {
434 PUCHAR CacheRun;
435 ULONGLONG CacheRunOffset;
436 LONGLONG CacheRunStartLCN;
437 ULONGLONG CacheRunLength;
438 LONGLONG CacheRunLastLCN;
439 ULONGLONG CacheRunCurrentOffset;
440 ULONGLONG FileMFTIndex;
441 NTFS_ATTR_RECORD Record;
442 } NTFS_ATTR_CONTEXT, *PNTFS_ATTR_CONTEXT;
443
444 #define FCB_CACHE_INITIALIZED 0x0001
445 #define FCB_IS_VOLUME_STREAM 0x0002
446 #define FCB_IS_VOLUME 0x0004
447 #define MAX_PATH 260
448
449 typedef struct _FCB
450 {
451 NTFSIDENTIFIER Identifier;
452
453 FSRTL_COMMON_FCB_HEADER RFCB;
454 SECTION_OBJECT_POINTERS SectionObjectPointers;
455
456 PFILE_OBJECT FileObject;
457 PNTFS_VCB Vcb;
458
459 WCHAR Stream[MAX_PATH];
460 WCHAR *ObjectName; /* point on filename (250 chars max) in PathName */
461 WCHAR PathName[MAX_PATH]; /* path+filename 260 max */
462
463 ERESOURCE PagingIoResource;
464 ERESOURCE MainResource;
465
466 LIST_ENTRY FcbListEntry;
467 struct _FCB* ParentFcb;
468
469 ULONG DirIndex;
470
471 LONG RefCount;
472 ULONG Flags;
473 ULONG OpenHandleCount;
474
475 ULONGLONG MFTIndex;
476 USHORT LinkCount;
477
478 FILENAME_ATTRIBUTE Entry;
479
480 } NTFS_FCB, *PNTFS_FCB;
481
482 typedef struct _FIND_ATTR_CONTXT
483 {
484 PDEVICE_EXTENSION Vcb;
485 BOOLEAN OnlyResident;
486 PNTFS_ATTR_RECORD FirstAttr;
487 PNTFS_ATTR_RECORD CurrAttr;
488 PNTFS_ATTR_RECORD LastAttr;
489 PNTFS_ATTR_RECORD NonResidentStart;
490 PNTFS_ATTR_RECORD NonResidentEnd;
491 ULONG Offset;
492 } FIND_ATTR_CONTXT, *PFIND_ATTR_CONTXT;
493
494 typedef struct
495 {
496 USHORT USN;
497 USHORT Array[];
498 } FIXUP_ARRAY, *PFIXUP_ARRAY;
499
500 extern PNTFS_GLOBAL_DATA NtfsGlobalData;
501
502 FORCEINLINE
503 NTSTATUS
504 NtfsMarkIrpContextForQueue(PNTFS_IRP_CONTEXT IrpContext)
505 {
506 PULONG Flags = &IrpContext->Flags;
507
508 *Flags &= ~IRPCONTEXT_COMPLETE;
509 *Flags |= IRPCONTEXT_QUEUE;
510
511 return STATUS_PENDING;
512 }
513
514 /* attrib.c */
515
516 //VOID
517 //NtfsDumpAttribute(PATTRIBUTE Attribute);
518
519 NTSTATUS
520 AddRun(PNTFS_ATTR_CONTEXT AttrContext,
521 ULONGLONG NextAssignedCluster,
522 ULONG RunLength);
523
524 PUCHAR
525 DecodeRun(PUCHAR DataRun,
526 LONGLONG *DataRunOffset,
527 ULONGLONG *DataRunLength);
528
529 VOID
530 NtfsDumpDataRuns(PVOID StartOfRun,
531 ULONGLONG CurrentLCN);
532
533 VOID
534 NtfsDumpFileAttributes(PDEVICE_EXTENSION Vcb,
535 PFILE_RECORD_HEADER FileRecord);
536
537 PSTANDARD_INFORMATION
538 GetStandardInformationFromRecord(PDEVICE_EXTENSION Vcb,
539 PFILE_RECORD_HEADER FileRecord);
540
541 PFILENAME_ATTRIBUTE
542 GetFileNameFromRecord(PDEVICE_EXTENSION Vcb,
543 PFILE_RECORD_HEADER FileRecord,
544 UCHAR NameType);
545
546 UCHAR
547 GetPackedByteCount(LONGLONG NumberToPack,
548 BOOLEAN IsSigned);
549
550 NTSTATUS
551 GetLastClusterInDataRun(PDEVICE_EXTENSION Vcb,
552 PNTFS_ATTR_RECORD Attribute,
553 PULONGLONG LastCluster);
554
555 PFILENAME_ATTRIBUTE
556 GetBestFileNameFromRecord(PDEVICE_EXTENSION Vcb,
557 PFILE_RECORD_HEADER FileRecord);
558
559 NTSTATUS
560 FindFirstAttribute(PFIND_ATTR_CONTXT Context,
561 PDEVICE_EXTENSION Vcb,
562 PFILE_RECORD_HEADER FileRecord,
563 BOOLEAN OnlyResident,
564 PNTFS_ATTR_RECORD * Attribute);
565
566 NTSTATUS
567 FindNextAttribute(PFIND_ATTR_CONTXT Context,
568 PNTFS_ATTR_RECORD * Attribute);
569
570 VOID
571 FindCloseAttribute(PFIND_ATTR_CONTXT Context);
572
573 /* blockdev.c */
574
575 NTSTATUS
576 NtfsReadDisk(IN PDEVICE_OBJECT DeviceObject,
577 IN LONGLONG StartingOffset,
578 IN ULONG Length,
579 IN ULONG SectorSize,
580 IN OUT PUCHAR Buffer,
581 IN BOOLEAN Override);
582
583 NTSTATUS
584 NtfsWriteDisk(IN PDEVICE_OBJECT DeviceObject,
585 IN LONGLONG StartingOffset,
586 IN ULONG Length,
587 IN ULONG SectorSize,
588 IN const PUCHAR Buffer);
589
590 NTSTATUS
591 NtfsReadSectors(IN PDEVICE_OBJECT DeviceObject,
592 IN ULONG DiskSector,
593 IN ULONG SectorCount,
594 IN ULONG SectorSize,
595 IN OUT PUCHAR Buffer,
596 IN BOOLEAN Override);
597
598 NTSTATUS
599 NtfsDeviceIoControl(IN PDEVICE_OBJECT DeviceObject,
600 IN ULONG ControlCode,
601 IN PVOID InputBuffer,
602 IN ULONG InputBufferSize,
603 IN OUT PVOID OutputBuffer,
604 IN OUT PULONG OutputBufferSize,
605 IN BOOLEAN Override);
606
607
608 /* close.c */
609
610 NTSTATUS
611 NtfsCleanup(PNTFS_IRP_CONTEXT IrpContext);
612
613
614 /* close.c */
615
616 NTSTATUS
617 NtfsCloseFile(PDEVICE_EXTENSION DeviceExt,
618 PFILE_OBJECT FileObject);
619
620 NTSTATUS
621 NtfsClose(PNTFS_IRP_CONTEXT IrpContext);
622
623
624 /* create.c */
625
626 NTSTATUS
627 NtfsCreate(PNTFS_IRP_CONTEXT IrpContext);
628
629
630 /* devctl.c */
631
632 NTSTATUS
633 NtfsDeviceControl(PNTFS_IRP_CONTEXT IrpContext);
634
635
636 /* dirctl.c */
637
638 ULONGLONG
639 NtfsGetFileSize(PDEVICE_EXTENSION DeviceExt,
640 PFILE_RECORD_HEADER FileRecord,
641 PCWSTR Stream,
642 ULONG StreamLength,
643 PULONGLONG AllocatedSize);
644
645 NTSTATUS
646 NtfsDirectoryControl(PNTFS_IRP_CONTEXT IrpContext);
647
648
649 /* dispatch.c */
650
651 DRIVER_DISPATCH NtfsFsdDispatch;
652 NTSTATUS NTAPI
653 NtfsFsdDispatch(PDEVICE_OBJECT DeviceObject,
654 PIRP Irp);
655
656
657 /* fastio.c */
658
659 BOOLEAN NTAPI
660 NtfsAcqLazyWrite(PVOID Context,
661 BOOLEAN Wait);
662
663 VOID NTAPI
664 NtfsRelLazyWrite(PVOID Context);
665
666 BOOLEAN NTAPI
667 NtfsAcqReadAhead(PVOID Context,
668 BOOLEAN Wait);
669
670 VOID NTAPI
671 NtfsRelReadAhead(PVOID Context);
672
673 FAST_IO_CHECK_IF_POSSIBLE NtfsFastIoCheckIfPossible;
674 FAST_IO_READ NtfsFastIoRead;
675 FAST_IO_WRITE NtfsFastIoWrite;
676
677
678 /* fcb.c */
679
680 PNTFS_FCB
681 NtfsCreateFCB(PCWSTR FileName,
682 PCWSTR Stream,
683 PNTFS_VCB Vcb);
684
685 VOID
686 NtfsDestroyFCB(PNTFS_FCB Fcb);
687
688 BOOLEAN
689 NtfsFCBIsDirectory(PNTFS_FCB Fcb);
690
691 BOOLEAN
692 NtfsFCBIsReparsePoint(PNTFS_FCB Fcb);
693
694 BOOLEAN
695 NtfsFCBIsCompressed(PNTFS_FCB Fcb);
696
697 BOOLEAN
698 NtfsFCBIsRoot(PNTFS_FCB Fcb);
699
700 VOID
701 NtfsGrabFCB(PNTFS_VCB Vcb,
702 PNTFS_FCB Fcb);
703
704 VOID
705 NtfsReleaseFCB(PNTFS_VCB Vcb,
706 PNTFS_FCB Fcb);
707
708 VOID
709 NtfsAddFCBToTable(PNTFS_VCB Vcb,
710 PNTFS_FCB Fcb);
711
712 PNTFS_FCB
713 NtfsGrabFCBFromTable(PNTFS_VCB Vcb,
714 PCWSTR FileName);
715
716 NTSTATUS
717 NtfsFCBInitializeCache(PNTFS_VCB Vcb,
718 PNTFS_FCB Fcb);
719
720 PNTFS_FCB
721 NtfsMakeRootFCB(PNTFS_VCB Vcb);
722
723 PNTFS_FCB
724 NtfsOpenRootFCB(PNTFS_VCB Vcb);
725
726 NTSTATUS
727 NtfsAttachFCBToFileObject(PNTFS_VCB Vcb,
728 PNTFS_FCB Fcb,
729 PFILE_OBJECT FileObject);
730
731 NTSTATUS
732 NtfsGetFCBForFile(PNTFS_VCB Vcb,
733 PNTFS_FCB *pParentFCB,
734 PNTFS_FCB *pFCB,
735 const PWSTR pFileName);
736
737 NTSTATUS
738 NtfsReadFCBAttribute(PNTFS_VCB Vcb,
739 PNTFS_FCB pFCB,
740 ULONG Type,
741 PCWSTR Name,
742 ULONG NameLength,
743 PVOID * Data);
744
745 NTSTATUS
746 NtfsMakeFCBFromDirEntry(PNTFS_VCB Vcb,
747 PNTFS_FCB DirectoryFCB,
748 PUNICODE_STRING Name,
749 PCWSTR Stream,
750 PFILE_RECORD_HEADER Record,
751 ULONGLONG MFTIndex,
752 PNTFS_FCB * fileFCB);
753
754
755 /* finfo.c */
756
757 NTSTATUS
758 NtfsQueryInformation(PNTFS_IRP_CONTEXT IrpContext);
759
760
761 /* fsctl.c */
762
763 NTSTATUS
764 NtfsFileSystemControl(PNTFS_IRP_CONTEXT IrpContext);
765
766
767 /* mft.c */
768 PNTFS_ATTR_CONTEXT
769 PrepareAttributeContext(PNTFS_ATTR_RECORD AttrRecord);
770
771 VOID
772 ReleaseAttributeContext(PNTFS_ATTR_CONTEXT Context);
773
774 ULONG
775 ReadAttribute(PDEVICE_EXTENSION Vcb,
776 PNTFS_ATTR_CONTEXT Context,
777 ULONGLONG Offset,
778 PCHAR Buffer,
779 ULONG Length);
780
781 NTSTATUS
782 WriteAttribute(PDEVICE_EXTENSION Vcb,
783 PNTFS_ATTR_CONTEXT Context,
784 ULONGLONG Offset,
785 const PUCHAR Buffer,
786 ULONG Length,
787 PULONG LengthWritten);
788
789 ULONGLONG
790 AttributeDataLength(PNTFS_ATTR_RECORD AttrRecord);
791
792 NTSTATUS
793 SetAttributeDataLength(PFILE_OBJECT FileObject,
794 PNTFS_FCB Fcb,
795 PNTFS_ATTR_CONTEXT AttrContext,
796 ULONG AttrOffset,
797 PFILE_RECORD_HEADER FileRecord,
798 PLARGE_INTEGER DataSize);
799
800 ULONGLONG
801 AttributeAllocatedLength(PNTFS_ATTR_RECORD AttrRecord);
802
803 BOOLEAN
804 CompareFileName(PUNICODE_STRING FileName,
805 PINDEX_ENTRY_ATTRIBUTE IndexEntry,
806 BOOLEAN DirSearch);
807
808 NTSTATUS
809 ReadFileRecord(PDEVICE_EXTENSION Vcb,
810 ULONGLONG index,
811 PFILE_RECORD_HEADER file);
812
813 NTSTATUS
814 UpdateIndexEntryFileNameSize(PDEVICE_EXTENSION Vcb,
815 PFILE_RECORD_HEADER MftRecord,
816 PCHAR IndexRecord,
817 ULONG IndexBlockSize,
818 PINDEX_ENTRY_ATTRIBUTE FirstEntry,
819 PINDEX_ENTRY_ATTRIBUTE LastEntry,
820 PUNICODE_STRING FileName,
821 PULONG StartEntry,
822 PULONG CurrentEntry,
823 BOOLEAN DirSearch,
824 ULONGLONG NewDataSize,
825 ULONGLONG NewAllocatedSize);
826
827 NTSTATUS
828 UpdateFileNameRecord(PDEVICE_EXTENSION Vcb,
829 ULONGLONG ParentMFTIndex,
830 PUNICODE_STRING FileName,
831 BOOLEAN DirSearch,
832 ULONGLONG NewDataSize,
833 ULONGLONG NewAllocationSize);
834
835 NTSTATUS
836 UpdateFileRecord(PDEVICE_EXTENSION Vcb,
837 ULONGLONG index,
838 PFILE_RECORD_HEADER file);
839
840 NTSTATUS
841 FindAttribute(PDEVICE_EXTENSION Vcb,
842 PFILE_RECORD_HEADER MftRecord,
843 ULONG Type,
844 PCWSTR Name,
845 ULONG NameLength,
846 PNTFS_ATTR_CONTEXT * AttrCtx,
847 PULONG Offset);
848
849 VOID
850 ReadVCN(PDEVICE_EXTENSION Vcb,
851 PFILE_RECORD_HEADER file,
852 ATTRIBUTE_TYPE type,
853 ULONGLONG vcn,
854 ULONG count,
855 PVOID buffer);
856
857 NTSTATUS
858 FixupUpdateSequenceArray(PDEVICE_EXTENSION Vcb,
859 PNTFS_RECORD_HEADER Record);
860
861 NTSTATUS
862 AddFixupArray(PDEVICE_EXTENSION Vcb,
863 PNTFS_RECORD_HEADER Record);
864
865 NTSTATUS
866 ReadLCN(PDEVICE_EXTENSION Vcb,
867 ULONGLONG lcn,
868 ULONG count,
869 PVOID buffer);
870
871 VOID
872 EnumerAttribute(PFILE_RECORD_HEADER file,
873 PDEVICE_EXTENSION Vcb,
874 PDEVICE_OBJECT DeviceObject);
875
876 NTSTATUS
877 NtfsLookupFile(PDEVICE_EXTENSION Vcb,
878 PUNICODE_STRING PathName,
879 PFILE_RECORD_HEADER *FileRecord,
880 PULONGLONG MFTIndex);
881
882 NTSTATUS
883 NtfsLookupFileAt(PDEVICE_EXTENSION Vcb,
884 PUNICODE_STRING PathName,
885 PFILE_RECORD_HEADER *FileRecord,
886 PULONGLONG MFTIndex,
887 ULONGLONG CurrentMFTIndex);
888
889 NTSTATUS
890 NtfsFindFileAt(PDEVICE_EXTENSION Vcb,
891 PUNICODE_STRING SearchPattern,
892 PULONG FirstEntry,
893 PFILE_RECORD_HEADER *FileRecord,
894 PULONGLONG MFTIndex,
895 ULONGLONG CurrentMFTIndex);
896
897 /* misc.c */
898
899 BOOLEAN
900 NtfsIsIrpTopLevel(PIRP Irp);
901
902 PNTFS_IRP_CONTEXT
903 NtfsAllocateIrpContext(PDEVICE_OBJECT DeviceObject,
904 PIRP Irp);
905
906 PVOID
907 NtfsGetUserBuffer(PIRP Irp,
908 BOOLEAN Paging);
909
910 NTSTATUS
911 NtfsLockUserBuffer(IN PIRP Irp,
912 IN ULONG Length,
913 IN LOCK_OPERATION Operation);
914
915 #if 0
916 BOOLEAN
917 wstrcmpjoki(PWSTR s1, PWSTR s2);
918
919 VOID
920 CdfsSwapString(PWCHAR Out,
921 PUCHAR In,
922 ULONG Count);
923 #endif
924
925 VOID
926 NtfsFileFlagsToAttributes(ULONG NtfsAttributes,
927 PULONG FileAttributes);
928
929
930 /* rw.c */
931
932 NTSTATUS
933 NtfsRead(PNTFS_IRP_CONTEXT IrpContext);
934
935 NTSTATUS
936 NtfsWrite(PNTFS_IRP_CONTEXT IrpContext);
937
938
939 /* volinfo.c */
940
941 NTSTATUS
942 NtfsAllocateClusters(PDEVICE_EXTENSION DeviceExt,
943 ULONG FirstDesiredCluster,
944 ULONG DesiredClusters,
945 PULONG FirstAssignedCluster,
946 PULONG AssignedClusters);
947
948 ULONGLONG
949 NtfsGetFreeClusters(PDEVICE_EXTENSION DeviceExt);
950
951 NTSTATUS
952 NtfsQueryVolumeInformation(PNTFS_IRP_CONTEXT IrpContext);
953
954 NTSTATUS
955 NtfsSetVolumeInformation(PNTFS_IRP_CONTEXT IrpContext);
956
957
958 /* ntfs.c */
959
960 DRIVER_INITIALIZE DriverEntry;
961
962 VOID
963 NTAPI
964 NtfsInitializeFunctionPointers(PDRIVER_OBJECT DriverObject);
965
966 #endif /* NTFS_H */