462980d45dfd63815ba29222b47a44987c29383f
[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 LARGE_MCB DataRunsMCB;
441 ULONGLONG FileMFTIndex;
442 NTFS_ATTR_RECORD Record;
443 } NTFS_ATTR_CONTEXT, *PNTFS_ATTR_CONTEXT;
444
445 #define FCB_CACHE_INITIALIZED 0x0001
446 #define FCB_IS_VOLUME_STREAM 0x0002
447 #define FCB_IS_VOLUME 0x0004
448 #define MAX_PATH 260
449
450 typedef struct _FCB
451 {
452 NTFSIDENTIFIER Identifier;
453
454 FSRTL_COMMON_FCB_HEADER RFCB;
455 SECTION_OBJECT_POINTERS SectionObjectPointers;
456
457 PFILE_OBJECT FileObject;
458 PNTFS_VCB Vcb;
459
460 WCHAR Stream[MAX_PATH];
461 WCHAR *ObjectName; /* point on filename (250 chars max) in PathName */
462 WCHAR PathName[MAX_PATH]; /* path+filename 260 max */
463
464 ERESOURCE PagingIoResource;
465 ERESOURCE MainResource;
466
467 LIST_ENTRY FcbListEntry;
468 struct _FCB* ParentFcb;
469
470 ULONG DirIndex;
471
472 LONG RefCount;
473 ULONG Flags;
474 ULONG OpenHandleCount;
475
476 ULONGLONG MFTIndex;
477 USHORT LinkCount;
478
479 FILENAME_ATTRIBUTE Entry;
480
481 } NTFS_FCB, *PNTFS_FCB;
482
483 typedef struct _FIND_ATTR_CONTXT
484 {
485 PDEVICE_EXTENSION Vcb;
486 BOOLEAN OnlyResident;
487 PNTFS_ATTR_RECORD FirstAttr;
488 PNTFS_ATTR_RECORD CurrAttr;
489 PNTFS_ATTR_RECORD LastAttr;
490 PNTFS_ATTR_RECORD NonResidentStart;
491 PNTFS_ATTR_RECORD NonResidentEnd;
492 ULONG Offset;
493 } FIND_ATTR_CONTXT, *PFIND_ATTR_CONTXT;
494
495 typedef struct
496 {
497 USHORT USN;
498 USHORT Array[];
499 } FIXUP_ARRAY, *PFIXUP_ARRAY;
500
501 extern PNTFS_GLOBAL_DATA NtfsGlobalData;
502
503 FORCEINLINE
504 NTSTATUS
505 NtfsMarkIrpContextForQueue(PNTFS_IRP_CONTEXT IrpContext)
506 {
507 PULONG Flags = &IrpContext->Flags;
508
509 *Flags &= ~IRPCONTEXT_COMPLETE;
510 *Flags |= IRPCONTEXT_QUEUE;
511
512 return STATUS_PENDING;
513 }
514
515 /* attrib.c */
516
517 //VOID
518 //NtfsDumpAttribute(PATTRIBUTE Attribute);
519
520 NTSTATUS
521 AddData(PFILE_RECORD_HEADER FileRecord,
522 PNTFS_ATTR_RECORD AttributeAddress);
523
524 NTSTATUS
525 AddRun(PNTFS_VCB Vcb,
526 PNTFS_ATTR_CONTEXT AttrContext,
527 ULONG AttrOffset,
528 PFILE_RECORD_HEADER FileRecord,
529 ULONGLONG NextAssignedCluster,
530 ULONG RunLength);
531
532 NTSTATUS
533 AddFileName(PFILE_RECORD_HEADER FileRecord,
534 PNTFS_ATTR_RECORD AttributeAddress,
535 PDEVICE_EXTENSION DeviceExt,
536 PFILE_OBJECT FileObject);
537
538 NTSTATUS
539 AddStandardInformation(PFILE_RECORD_HEADER FileRecord,
540 PNTFS_ATTR_RECORD AttributeAddress);
541
542 NTSTATUS
543 ConvertDataRunsToLargeMCB(PUCHAR DataRun,
544 PLARGE_MCB DataRunsMCB,
545 PULONGLONG pNextVBN);
546
547 NTSTATUS
548 ConvertLargeMCBToDataRuns(PLARGE_MCB DataRunsMCB,
549 PUCHAR RunBuffer,
550 ULONG MaxBufferSize,
551 PULONG UsedBufferSize);
552
553 PUCHAR
554 DecodeRun(PUCHAR DataRun,
555 LONGLONG *DataRunOffset,
556 ULONGLONG *DataRunLength);
557
558 VOID
559 NtfsDumpDataRuns(PVOID StartOfRun,
560 ULONGLONG CurrentLCN);
561
562 VOID
563 NtfsDumpFileAttributes(PDEVICE_EXTENSION Vcb,
564 PFILE_RECORD_HEADER FileRecord);
565
566 PSTANDARD_INFORMATION
567 GetStandardInformationFromRecord(PDEVICE_EXTENSION Vcb,
568 PFILE_RECORD_HEADER FileRecord);
569
570 PFILENAME_ATTRIBUTE
571 GetFileNameFromRecord(PDEVICE_EXTENSION Vcb,
572 PFILE_RECORD_HEADER FileRecord,
573 UCHAR NameType);
574
575 UCHAR
576 GetPackedByteCount(LONGLONG NumberToPack,
577 BOOLEAN IsSigned);
578
579 NTSTATUS
580 GetLastClusterInDataRun(PDEVICE_EXTENSION Vcb,
581 PNTFS_ATTR_RECORD Attribute,
582 PULONGLONG LastCluster);
583
584 PFILENAME_ATTRIBUTE
585 GetBestFileNameFromRecord(PDEVICE_EXTENSION Vcb,
586 PFILE_RECORD_HEADER FileRecord);
587
588 NTSTATUS
589 FindFirstAttribute(PFIND_ATTR_CONTXT Context,
590 PDEVICE_EXTENSION Vcb,
591 PFILE_RECORD_HEADER FileRecord,
592 BOOLEAN OnlyResident,
593 PNTFS_ATTR_RECORD * Attribute);
594
595 NTSTATUS
596 FindNextAttribute(PFIND_ATTR_CONTXT Context,
597 PNTFS_ATTR_RECORD * Attribute);
598
599 VOID
600 FindCloseAttribute(PFIND_ATTR_CONTXT Context);
601
602 NTSTATUS
603 FreeClusters(PNTFS_VCB Vcb,
604 PNTFS_ATTR_CONTEXT AttrContext,
605 ULONG AttrOffset,
606 PFILE_RECORD_HEADER FileRecord,
607 ULONG ClustersToFree);
608
609 /* blockdev.c */
610
611 NTSTATUS
612 NtfsReadDisk(IN PDEVICE_OBJECT DeviceObject,
613 IN LONGLONG StartingOffset,
614 IN ULONG Length,
615 IN ULONG SectorSize,
616 IN OUT PUCHAR Buffer,
617 IN BOOLEAN Override);
618
619 NTSTATUS
620 NtfsWriteDisk(IN PDEVICE_OBJECT DeviceObject,
621 IN LONGLONG StartingOffset,
622 IN ULONG Length,
623 IN ULONG SectorSize,
624 IN const PUCHAR Buffer);
625
626 NTSTATUS
627 NtfsReadSectors(IN PDEVICE_OBJECT DeviceObject,
628 IN ULONG DiskSector,
629 IN ULONG SectorCount,
630 IN ULONG SectorSize,
631 IN OUT PUCHAR Buffer,
632 IN BOOLEAN Override);
633
634 NTSTATUS
635 NtfsDeviceIoControl(IN PDEVICE_OBJECT DeviceObject,
636 IN ULONG ControlCode,
637 IN PVOID InputBuffer,
638 IN ULONG InputBufferSize,
639 IN OUT PVOID OutputBuffer,
640 IN OUT PULONG OutputBufferSize,
641 IN BOOLEAN Override);
642
643
644 /* close.c */
645
646 NTSTATUS
647 NtfsCleanup(PNTFS_IRP_CONTEXT IrpContext);
648
649
650 /* close.c */
651
652 NTSTATUS
653 NtfsCloseFile(PDEVICE_EXTENSION DeviceExt,
654 PFILE_OBJECT FileObject);
655
656 NTSTATUS
657 NtfsClose(PNTFS_IRP_CONTEXT IrpContext);
658
659
660 /* create.c */
661
662 NTSTATUS
663 NtfsCreate(PNTFS_IRP_CONTEXT IrpContext);
664
665 NTSTATUS
666 NtfsCreateFileRecord(PDEVICE_EXTENSION DeviceExt,
667 PFILE_OBJECT FileObject);
668
669 /* devctl.c */
670
671 NTSTATUS
672 NtfsDeviceControl(PNTFS_IRP_CONTEXT IrpContext);
673
674
675 /* dirctl.c */
676
677 ULONGLONG
678 NtfsGetFileSize(PDEVICE_EXTENSION DeviceExt,
679 PFILE_RECORD_HEADER FileRecord,
680 PCWSTR Stream,
681 ULONG StreamLength,
682 PULONGLONG AllocatedSize);
683
684 NTSTATUS
685 NtfsDirectoryControl(PNTFS_IRP_CONTEXT IrpContext);
686
687
688 /* dispatch.c */
689
690 DRIVER_DISPATCH NtfsFsdDispatch;
691 NTSTATUS NTAPI
692 NtfsFsdDispatch(PDEVICE_OBJECT DeviceObject,
693 PIRP Irp);
694
695
696 /* fastio.c */
697
698 BOOLEAN NTAPI
699 NtfsAcqLazyWrite(PVOID Context,
700 BOOLEAN Wait);
701
702 VOID NTAPI
703 NtfsRelLazyWrite(PVOID Context);
704
705 BOOLEAN NTAPI
706 NtfsAcqReadAhead(PVOID Context,
707 BOOLEAN Wait);
708
709 VOID NTAPI
710 NtfsRelReadAhead(PVOID Context);
711
712 FAST_IO_CHECK_IF_POSSIBLE NtfsFastIoCheckIfPossible;
713 FAST_IO_READ NtfsFastIoRead;
714 FAST_IO_WRITE NtfsFastIoWrite;
715
716
717 /* fcb.c */
718
719 PNTFS_FCB
720 NtfsCreateFCB(PCWSTR FileName,
721 PCWSTR Stream,
722 PNTFS_VCB Vcb);
723
724 VOID
725 NtfsDestroyFCB(PNTFS_FCB Fcb);
726
727 BOOLEAN
728 NtfsFCBIsDirectory(PNTFS_FCB Fcb);
729
730 BOOLEAN
731 NtfsFCBIsReparsePoint(PNTFS_FCB Fcb);
732
733 BOOLEAN
734 NtfsFCBIsCompressed(PNTFS_FCB Fcb);
735
736 BOOLEAN
737 NtfsFCBIsRoot(PNTFS_FCB Fcb);
738
739 VOID
740 NtfsGrabFCB(PNTFS_VCB Vcb,
741 PNTFS_FCB Fcb);
742
743 VOID
744 NtfsReleaseFCB(PNTFS_VCB Vcb,
745 PNTFS_FCB Fcb);
746
747 VOID
748 NtfsAddFCBToTable(PNTFS_VCB Vcb,
749 PNTFS_FCB Fcb);
750
751 PNTFS_FCB
752 NtfsGrabFCBFromTable(PNTFS_VCB Vcb,
753 PCWSTR FileName);
754
755 NTSTATUS
756 NtfsFCBInitializeCache(PNTFS_VCB Vcb,
757 PNTFS_FCB Fcb);
758
759 PNTFS_FCB
760 NtfsMakeRootFCB(PNTFS_VCB Vcb);
761
762 PNTFS_FCB
763 NtfsOpenRootFCB(PNTFS_VCB Vcb);
764
765 NTSTATUS
766 NtfsAttachFCBToFileObject(PNTFS_VCB Vcb,
767 PNTFS_FCB Fcb,
768 PFILE_OBJECT FileObject);
769
770 NTSTATUS
771 NtfsGetFCBForFile(PNTFS_VCB Vcb,
772 PNTFS_FCB *pParentFCB,
773 PNTFS_FCB *pFCB,
774 const PWSTR pFileName);
775
776 NTSTATUS
777 NtfsReadFCBAttribute(PNTFS_VCB Vcb,
778 PNTFS_FCB pFCB,
779 ULONG Type,
780 PCWSTR Name,
781 ULONG NameLength,
782 PVOID * Data);
783
784 NTSTATUS
785 NtfsMakeFCBFromDirEntry(PNTFS_VCB Vcb,
786 PNTFS_FCB DirectoryFCB,
787 PUNICODE_STRING Name,
788 PCWSTR Stream,
789 PFILE_RECORD_HEADER Record,
790 ULONGLONG MFTIndex,
791 PNTFS_FCB * fileFCB);
792
793
794 /* finfo.c */
795
796 NTSTATUS
797 NtfsQueryInformation(PNTFS_IRP_CONTEXT IrpContext);
798
799
800 /* fsctl.c */
801
802 NTSTATUS
803 NtfsFileSystemControl(PNTFS_IRP_CONTEXT IrpContext);
804
805
806 /* mft.c */
807 NTSTATUS
808 AddNewMftEntry(PFILE_RECORD_HEADER FileRecord,
809 PDEVICE_EXTENSION DeviceExt);
810
811 PNTFS_ATTR_CONTEXT
812 PrepareAttributeContext(PNTFS_ATTR_RECORD AttrRecord);
813
814 VOID
815 ReleaseAttributeContext(PNTFS_ATTR_CONTEXT Context);
816
817 ULONG
818 ReadAttribute(PDEVICE_EXTENSION Vcb,
819 PNTFS_ATTR_CONTEXT Context,
820 ULONGLONG Offset,
821 PCHAR Buffer,
822 ULONG Length);
823
824 NTSTATUS
825 WriteAttribute(PDEVICE_EXTENSION Vcb,
826 PNTFS_ATTR_CONTEXT Context,
827 ULONGLONG Offset,
828 const PUCHAR Buffer,
829 ULONG Length,
830 PULONG LengthWritten);
831
832 ULONGLONG
833 AttributeDataLength(PNTFS_ATTR_RECORD AttrRecord);
834
835 NTSTATUS
836 SetAttributeDataLength(PFILE_OBJECT FileObject,
837 PNTFS_FCB Fcb,
838 PNTFS_ATTR_CONTEXT AttrContext,
839 ULONG AttrOffset,
840 PFILE_RECORD_HEADER FileRecord,
841 PLARGE_INTEGER DataSize);
842
843 VOID
844 SetFileRecordEnd(PFILE_RECORD_HEADER FileRecord,
845 PNTFS_ATTR_RECORD AttrEnd,
846 ULONG EndMarker);
847
848 ULONGLONG
849 AttributeAllocatedLength(PNTFS_ATTR_RECORD AttrRecord);
850
851 BOOLEAN
852 CompareFileName(PUNICODE_STRING FileName,
853 PINDEX_ENTRY_ATTRIBUTE IndexEntry,
854 BOOLEAN DirSearch);
855
856 NTSTATUS
857 ReadFileRecord(PDEVICE_EXTENSION Vcb,
858 ULONGLONG index,
859 PFILE_RECORD_HEADER file);
860
861 NTSTATUS
862 UpdateIndexEntryFileNameSize(PDEVICE_EXTENSION Vcb,
863 PFILE_RECORD_HEADER MftRecord,
864 PCHAR IndexRecord,
865 ULONG IndexBlockSize,
866 PINDEX_ENTRY_ATTRIBUTE FirstEntry,
867 PINDEX_ENTRY_ATTRIBUTE LastEntry,
868 PUNICODE_STRING FileName,
869 PULONG StartEntry,
870 PULONG CurrentEntry,
871 BOOLEAN DirSearch,
872 ULONGLONG NewDataSize,
873 ULONGLONG NewAllocatedSize);
874
875 NTSTATUS
876 UpdateFileNameRecord(PDEVICE_EXTENSION Vcb,
877 ULONGLONG ParentMFTIndex,
878 PUNICODE_STRING FileName,
879 BOOLEAN DirSearch,
880 ULONGLONG NewDataSize,
881 ULONGLONG NewAllocationSize);
882
883 NTSTATUS
884 UpdateFileRecord(PDEVICE_EXTENSION Vcb,
885 ULONGLONG MftIndex,
886 PFILE_RECORD_HEADER FileRecord);
887
888 NTSTATUS
889 FindAttribute(PDEVICE_EXTENSION Vcb,
890 PFILE_RECORD_HEADER MftRecord,
891 ULONG Type,
892 PCWSTR Name,
893 ULONG NameLength,
894 PNTFS_ATTR_CONTEXT * AttrCtx,
895 PULONG Offset);
896
897 VOID
898 ReadVCN(PDEVICE_EXTENSION Vcb,
899 PFILE_RECORD_HEADER file,
900 ATTRIBUTE_TYPE type,
901 ULONGLONG vcn,
902 ULONG count,
903 PVOID buffer);
904
905 NTSTATUS
906 FixupUpdateSequenceArray(PDEVICE_EXTENSION Vcb,
907 PNTFS_RECORD_HEADER Record);
908
909 NTSTATUS
910 AddFixupArray(PDEVICE_EXTENSION Vcb,
911 PNTFS_RECORD_HEADER Record);
912
913 NTSTATUS
914 ReadLCN(PDEVICE_EXTENSION Vcb,
915 ULONGLONG lcn,
916 ULONG count,
917 PVOID buffer);
918
919 VOID
920 EnumerAttribute(PFILE_RECORD_HEADER file,
921 PDEVICE_EXTENSION Vcb,
922 PDEVICE_OBJECT DeviceObject);
923
924 NTSTATUS
925 NtfsLookupFile(PDEVICE_EXTENSION Vcb,
926 PUNICODE_STRING PathName,
927 PFILE_RECORD_HEADER *FileRecord,
928 PULONGLONG MFTIndex);
929
930 NTSTATUS
931 NtfsLookupFileAt(PDEVICE_EXTENSION Vcb,
932 PUNICODE_STRING PathName,
933 PFILE_RECORD_HEADER *FileRecord,
934 PULONGLONG MFTIndex,
935 ULONGLONG CurrentMFTIndex);
936
937 VOID
938 NtfsDumpFileRecord(PDEVICE_EXTENSION Vcb,
939 PFILE_RECORD_HEADER FileRecord);
940
941 NTSTATUS
942 NtfsFindFileAt(PDEVICE_EXTENSION Vcb,
943 PUNICODE_STRING SearchPattern,
944 PULONG FirstEntry,
945 PFILE_RECORD_HEADER *FileRecord,
946 PULONGLONG MFTIndex,
947 ULONGLONG CurrentMFTIndex);
948
949 NTSTATUS
950 NtfsFindMftRecord(PDEVICE_EXTENSION Vcb,
951 ULONGLONG MFTIndex,
952 PUNICODE_STRING FileName,
953 PULONG FirstEntry,
954 BOOLEAN DirSearch,
955 ULONGLONG *OutMFTIndex);
956
957 /* misc.c */
958
959 BOOLEAN
960 NtfsIsIrpTopLevel(PIRP Irp);
961
962 PNTFS_IRP_CONTEXT
963 NtfsAllocateIrpContext(PDEVICE_OBJECT DeviceObject,
964 PIRP Irp);
965
966 PVOID
967 NtfsGetUserBuffer(PIRP Irp,
968 BOOLEAN Paging);
969
970 NTSTATUS
971 NtfsLockUserBuffer(IN PIRP Irp,
972 IN ULONG Length,
973 IN LOCK_OPERATION Operation);
974
975 #if 0
976 BOOLEAN
977 wstrcmpjoki(PWSTR s1, PWSTR s2);
978
979 VOID
980 CdfsSwapString(PWCHAR Out,
981 PUCHAR In,
982 ULONG Count);
983 #endif
984
985 VOID
986 NtfsFileFlagsToAttributes(ULONG NtfsAttributes,
987 PULONG FileAttributes);
988
989
990 /* rw.c */
991
992 NTSTATUS
993 NtfsRead(PNTFS_IRP_CONTEXT IrpContext);
994
995 NTSTATUS
996 NtfsWrite(PNTFS_IRP_CONTEXT IrpContext);
997
998
999 /* volinfo.c */
1000
1001 NTSTATUS
1002 NtfsAllocateClusters(PDEVICE_EXTENSION DeviceExt,
1003 ULONG FirstDesiredCluster,
1004 ULONG DesiredClusters,
1005 PULONG FirstAssignedCluster,
1006 PULONG AssignedClusters);
1007
1008 ULONGLONG
1009 NtfsGetFreeClusters(PDEVICE_EXTENSION DeviceExt);
1010
1011 NTSTATUS
1012 NtfsQueryVolumeInformation(PNTFS_IRP_CONTEXT IrpContext);
1013
1014 NTSTATUS
1015 NtfsSetVolumeInformation(PNTFS_IRP_CONTEXT IrpContext);
1016
1017
1018 /* ntfs.c */
1019
1020 DRIVER_INITIALIZE DriverEntry;
1021
1022 VOID
1023 NTAPI
1024 NtfsInitializeFunctionPointers(PDRIVER_OBJECT DriverObject);
1025
1026 #endif /* NTFS_H */