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