ce8a7df2de6a784ddd27c5ef518f55e1129ccb5a
[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_VCB Vcb,
521 PNTFS_ATTR_CONTEXT AttrContext,
522 ULONG AttrOffset,
523 PFILE_RECORD_HEADER FileRecord,
524 ULONGLONG NextAssignedCluster,
525 ULONG RunLength);
526
527 NTSTATUS
528 ConvertDataRunsToLargeMCB(PUCHAR DataRun,
529 PLARGE_MCB DataRunsMCB,
530 PULONGLONG pNextVBN);
531
532 NTSTATUS
533 ConvertLargeMCBToDataRuns(PLARGE_MCB DataRunsMCB,
534 PUCHAR RunBuffer,
535 ULONG MaxBufferSize,
536 PULONG UsedBufferSize);
537
538 PUCHAR
539 DecodeRun(PUCHAR DataRun,
540 LONGLONG *DataRunOffset,
541 ULONGLONG *DataRunLength);
542
543 VOID
544 NtfsDumpDataRuns(PVOID StartOfRun,
545 ULONGLONG CurrentLCN);
546
547 VOID
548 NtfsDumpFileAttributes(PDEVICE_EXTENSION Vcb,
549 PFILE_RECORD_HEADER FileRecord);
550
551 PSTANDARD_INFORMATION
552 GetStandardInformationFromRecord(PDEVICE_EXTENSION Vcb,
553 PFILE_RECORD_HEADER FileRecord);
554
555 PFILENAME_ATTRIBUTE
556 GetFileNameFromRecord(PDEVICE_EXTENSION Vcb,
557 PFILE_RECORD_HEADER FileRecord,
558 UCHAR NameType);
559
560 UCHAR
561 GetPackedByteCount(LONGLONG NumberToPack,
562 BOOLEAN IsSigned);
563
564 NTSTATUS
565 GetLastClusterInDataRun(PDEVICE_EXTENSION Vcb,
566 PNTFS_ATTR_RECORD Attribute,
567 PULONGLONG LastCluster);
568
569 PFILENAME_ATTRIBUTE
570 GetBestFileNameFromRecord(PDEVICE_EXTENSION Vcb,
571 PFILE_RECORD_HEADER FileRecord);
572
573 NTSTATUS
574 FindFirstAttribute(PFIND_ATTR_CONTXT Context,
575 PDEVICE_EXTENSION Vcb,
576 PFILE_RECORD_HEADER FileRecord,
577 BOOLEAN OnlyResident,
578 PNTFS_ATTR_RECORD * Attribute);
579
580 NTSTATUS
581 FindNextAttribute(PFIND_ATTR_CONTXT Context,
582 PNTFS_ATTR_RECORD * Attribute);
583
584 VOID
585 FindCloseAttribute(PFIND_ATTR_CONTXT Context);
586
587 NTSTATUS
588 FreeClusters(PNTFS_VCB Vcb,
589 PNTFS_ATTR_CONTEXT AttrContext,
590 ULONG AttrOffset,
591 PFILE_RECORD_HEADER FileRecord,
592 ULONG ClustersToFree);
593
594 /* blockdev.c */
595
596 NTSTATUS
597 NtfsReadDisk(IN PDEVICE_OBJECT DeviceObject,
598 IN LONGLONG StartingOffset,
599 IN ULONG Length,
600 IN ULONG SectorSize,
601 IN OUT PUCHAR Buffer,
602 IN BOOLEAN Override);
603
604 NTSTATUS
605 NtfsWriteDisk(IN PDEVICE_OBJECT DeviceObject,
606 IN LONGLONG StartingOffset,
607 IN ULONG Length,
608 IN ULONG SectorSize,
609 IN const PUCHAR Buffer);
610
611 NTSTATUS
612 NtfsReadSectors(IN PDEVICE_OBJECT DeviceObject,
613 IN ULONG DiskSector,
614 IN ULONG SectorCount,
615 IN ULONG SectorSize,
616 IN OUT PUCHAR Buffer,
617 IN BOOLEAN Override);
618
619 NTSTATUS
620 NtfsDeviceIoControl(IN PDEVICE_OBJECT DeviceObject,
621 IN ULONG ControlCode,
622 IN PVOID InputBuffer,
623 IN ULONG InputBufferSize,
624 IN OUT PVOID OutputBuffer,
625 IN OUT PULONG OutputBufferSize,
626 IN BOOLEAN Override);
627
628
629 /* close.c */
630
631 NTSTATUS
632 NtfsCleanup(PNTFS_IRP_CONTEXT IrpContext);
633
634
635 /* close.c */
636
637 NTSTATUS
638 NtfsCloseFile(PDEVICE_EXTENSION DeviceExt,
639 PFILE_OBJECT FileObject);
640
641 NTSTATUS
642 NtfsClose(PNTFS_IRP_CONTEXT IrpContext);
643
644
645 /* create.c */
646
647 NTSTATUS
648 NtfsCreate(PNTFS_IRP_CONTEXT IrpContext);
649
650
651 /* devctl.c */
652
653 NTSTATUS
654 NtfsDeviceControl(PNTFS_IRP_CONTEXT IrpContext);
655
656
657 /* dirctl.c */
658
659 ULONGLONG
660 NtfsGetFileSize(PDEVICE_EXTENSION DeviceExt,
661 PFILE_RECORD_HEADER FileRecord,
662 PCWSTR Stream,
663 ULONG StreamLength,
664 PULONGLONG AllocatedSize);
665
666 NTSTATUS
667 NtfsDirectoryControl(PNTFS_IRP_CONTEXT IrpContext);
668
669
670 /* dispatch.c */
671
672 DRIVER_DISPATCH NtfsFsdDispatch;
673 NTSTATUS NTAPI
674 NtfsFsdDispatch(PDEVICE_OBJECT DeviceObject,
675 PIRP Irp);
676
677
678 /* fastio.c */
679
680 BOOLEAN NTAPI
681 NtfsAcqLazyWrite(PVOID Context,
682 BOOLEAN Wait);
683
684 VOID NTAPI
685 NtfsRelLazyWrite(PVOID Context);
686
687 BOOLEAN NTAPI
688 NtfsAcqReadAhead(PVOID Context,
689 BOOLEAN Wait);
690
691 VOID NTAPI
692 NtfsRelReadAhead(PVOID Context);
693
694 FAST_IO_CHECK_IF_POSSIBLE NtfsFastIoCheckIfPossible;
695 FAST_IO_READ NtfsFastIoRead;
696 FAST_IO_WRITE NtfsFastIoWrite;
697
698
699 /* fcb.c */
700
701 PNTFS_FCB
702 NtfsCreateFCB(PCWSTR FileName,
703 PCWSTR Stream,
704 PNTFS_VCB Vcb);
705
706 VOID
707 NtfsDestroyFCB(PNTFS_FCB Fcb);
708
709 BOOLEAN
710 NtfsFCBIsDirectory(PNTFS_FCB Fcb);
711
712 BOOLEAN
713 NtfsFCBIsReparsePoint(PNTFS_FCB Fcb);
714
715 BOOLEAN
716 NtfsFCBIsCompressed(PNTFS_FCB Fcb);
717
718 BOOLEAN
719 NtfsFCBIsRoot(PNTFS_FCB Fcb);
720
721 VOID
722 NtfsGrabFCB(PNTFS_VCB Vcb,
723 PNTFS_FCB Fcb);
724
725 VOID
726 NtfsReleaseFCB(PNTFS_VCB Vcb,
727 PNTFS_FCB Fcb);
728
729 VOID
730 NtfsAddFCBToTable(PNTFS_VCB Vcb,
731 PNTFS_FCB Fcb);
732
733 PNTFS_FCB
734 NtfsGrabFCBFromTable(PNTFS_VCB Vcb,
735 PCWSTR FileName);
736
737 NTSTATUS
738 NtfsFCBInitializeCache(PNTFS_VCB Vcb,
739 PNTFS_FCB Fcb);
740
741 PNTFS_FCB
742 NtfsMakeRootFCB(PNTFS_VCB Vcb);
743
744 PNTFS_FCB
745 NtfsOpenRootFCB(PNTFS_VCB Vcb);
746
747 NTSTATUS
748 NtfsAttachFCBToFileObject(PNTFS_VCB Vcb,
749 PNTFS_FCB Fcb,
750 PFILE_OBJECT FileObject);
751
752 NTSTATUS
753 NtfsGetFCBForFile(PNTFS_VCB Vcb,
754 PNTFS_FCB *pParentFCB,
755 PNTFS_FCB *pFCB,
756 const PWSTR pFileName);
757
758 NTSTATUS
759 NtfsReadFCBAttribute(PNTFS_VCB Vcb,
760 PNTFS_FCB pFCB,
761 ULONG Type,
762 PCWSTR Name,
763 ULONG NameLength,
764 PVOID * Data);
765
766 NTSTATUS
767 NtfsMakeFCBFromDirEntry(PNTFS_VCB Vcb,
768 PNTFS_FCB DirectoryFCB,
769 PUNICODE_STRING Name,
770 PCWSTR Stream,
771 PFILE_RECORD_HEADER Record,
772 ULONGLONG MFTIndex,
773 PNTFS_FCB * fileFCB);
774
775
776 /* finfo.c */
777
778 NTSTATUS
779 NtfsQueryInformation(PNTFS_IRP_CONTEXT IrpContext);
780
781
782 /* fsctl.c */
783
784 NTSTATUS
785 NtfsFileSystemControl(PNTFS_IRP_CONTEXT IrpContext);
786
787
788 /* mft.c */
789 PNTFS_ATTR_CONTEXT
790 PrepareAttributeContext(PNTFS_ATTR_RECORD AttrRecord);
791
792 VOID
793 ReleaseAttributeContext(PNTFS_ATTR_CONTEXT Context);
794
795 ULONG
796 ReadAttribute(PDEVICE_EXTENSION Vcb,
797 PNTFS_ATTR_CONTEXT Context,
798 ULONGLONG Offset,
799 PCHAR Buffer,
800 ULONG Length);
801
802 NTSTATUS
803 WriteAttribute(PDEVICE_EXTENSION Vcb,
804 PNTFS_ATTR_CONTEXT Context,
805 ULONGLONG Offset,
806 const PUCHAR Buffer,
807 ULONG Length,
808 PULONG LengthWritten);
809
810 ULONGLONG
811 AttributeDataLength(PNTFS_ATTR_RECORD AttrRecord);
812
813 NTSTATUS
814 SetAttributeDataLength(PFILE_OBJECT FileObject,
815 PNTFS_FCB Fcb,
816 PNTFS_ATTR_CONTEXT AttrContext,
817 ULONG AttrOffset,
818 PFILE_RECORD_HEADER FileRecord,
819 PLARGE_INTEGER DataSize);
820
821 ULONGLONG
822 AttributeAllocatedLength(PNTFS_ATTR_RECORD AttrRecord);
823
824 BOOLEAN
825 CompareFileName(PUNICODE_STRING FileName,
826 PINDEX_ENTRY_ATTRIBUTE IndexEntry,
827 BOOLEAN DirSearch);
828
829 NTSTATUS
830 ReadFileRecord(PDEVICE_EXTENSION Vcb,
831 ULONGLONG index,
832 PFILE_RECORD_HEADER file);
833
834 NTSTATUS
835 UpdateIndexEntryFileNameSize(PDEVICE_EXTENSION Vcb,
836 PFILE_RECORD_HEADER MftRecord,
837 PCHAR IndexRecord,
838 ULONG IndexBlockSize,
839 PINDEX_ENTRY_ATTRIBUTE FirstEntry,
840 PINDEX_ENTRY_ATTRIBUTE LastEntry,
841 PUNICODE_STRING FileName,
842 PULONG StartEntry,
843 PULONG CurrentEntry,
844 BOOLEAN DirSearch,
845 ULONGLONG NewDataSize,
846 ULONGLONG NewAllocatedSize);
847
848 NTSTATUS
849 UpdateFileNameRecord(PDEVICE_EXTENSION Vcb,
850 ULONGLONG ParentMFTIndex,
851 PUNICODE_STRING FileName,
852 BOOLEAN DirSearch,
853 ULONGLONG NewDataSize,
854 ULONGLONG NewAllocationSize);
855
856 NTSTATUS
857 UpdateFileRecord(PDEVICE_EXTENSION Vcb,
858 ULONGLONG index,
859 PFILE_RECORD_HEADER file);
860
861 NTSTATUS
862 FindAttribute(PDEVICE_EXTENSION Vcb,
863 PFILE_RECORD_HEADER MftRecord,
864 ULONG Type,
865 PCWSTR Name,
866 ULONG NameLength,
867 PNTFS_ATTR_CONTEXT * AttrCtx,
868 PULONG Offset);
869
870 VOID
871 ReadVCN(PDEVICE_EXTENSION Vcb,
872 PFILE_RECORD_HEADER file,
873 ATTRIBUTE_TYPE type,
874 ULONGLONG vcn,
875 ULONG count,
876 PVOID buffer);
877
878 NTSTATUS
879 FixupUpdateSequenceArray(PDEVICE_EXTENSION Vcb,
880 PNTFS_RECORD_HEADER Record);
881
882 NTSTATUS
883 AddFixupArray(PDEVICE_EXTENSION Vcb,
884 PNTFS_RECORD_HEADER Record);
885
886 NTSTATUS
887 ReadLCN(PDEVICE_EXTENSION Vcb,
888 ULONGLONG lcn,
889 ULONG count,
890 PVOID buffer);
891
892 VOID
893 EnumerAttribute(PFILE_RECORD_HEADER file,
894 PDEVICE_EXTENSION Vcb,
895 PDEVICE_OBJECT DeviceObject);
896
897 NTSTATUS
898 NtfsLookupFile(PDEVICE_EXTENSION Vcb,
899 PUNICODE_STRING PathName,
900 PFILE_RECORD_HEADER *FileRecord,
901 PULONGLONG MFTIndex);
902
903 NTSTATUS
904 NtfsLookupFileAt(PDEVICE_EXTENSION Vcb,
905 PUNICODE_STRING PathName,
906 PFILE_RECORD_HEADER *FileRecord,
907 PULONGLONG MFTIndex,
908 ULONGLONG CurrentMFTIndex);
909
910 VOID
911 NtfsDumpFileRecord(PDEVICE_EXTENSION Vcb,
912 PFILE_RECORD_HEADER FileRecord);
913
914 NTSTATUS
915 NtfsFindFileAt(PDEVICE_EXTENSION Vcb,
916 PUNICODE_STRING SearchPattern,
917 PULONG FirstEntry,
918 PFILE_RECORD_HEADER *FileRecord,
919 PULONGLONG MFTIndex,
920 ULONGLONG CurrentMFTIndex);
921
922 /* misc.c */
923
924 BOOLEAN
925 NtfsIsIrpTopLevel(PIRP Irp);
926
927 PNTFS_IRP_CONTEXT
928 NtfsAllocateIrpContext(PDEVICE_OBJECT DeviceObject,
929 PIRP Irp);
930
931 PVOID
932 NtfsGetUserBuffer(PIRP Irp,
933 BOOLEAN Paging);
934
935 NTSTATUS
936 NtfsLockUserBuffer(IN PIRP Irp,
937 IN ULONG Length,
938 IN LOCK_OPERATION Operation);
939
940 #if 0
941 BOOLEAN
942 wstrcmpjoki(PWSTR s1, PWSTR s2);
943
944 VOID
945 CdfsSwapString(PWCHAR Out,
946 PUCHAR In,
947 ULONG Count);
948 #endif
949
950 VOID
951 NtfsFileFlagsToAttributes(ULONG NtfsAttributes,
952 PULONG FileAttributes);
953
954
955 /* rw.c */
956
957 NTSTATUS
958 NtfsRead(PNTFS_IRP_CONTEXT IrpContext);
959
960 NTSTATUS
961 NtfsWrite(PNTFS_IRP_CONTEXT IrpContext);
962
963
964 /* volinfo.c */
965
966 NTSTATUS
967 NtfsAllocateClusters(PDEVICE_EXTENSION DeviceExt,
968 ULONG FirstDesiredCluster,
969 ULONG DesiredClusters,
970 PULONG FirstAssignedCluster,
971 PULONG AssignedClusters);
972
973 ULONGLONG
974 NtfsGetFreeClusters(PDEVICE_EXTENSION DeviceExt);
975
976 NTSTATUS
977 NtfsQueryVolumeInformation(PNTFS_IRP_CONTEXT IrpContext);
978
979 NTSTATUS
980 NtfsSetVolumeInformation(PNTFS_IRP_CONTEXT IrpContext);
981
982
983 /* ntfs.c */
984
985 DRIVER_INITIALIZE DriverEntry;
986
987 VOID
988 NTAPI
989 NtfsInitializeFunctionPointers(PDRIVER_OBJECT DriverObject);
990
991 #endif /* NTFS_H */