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