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