ReactOS 0.4.15-dev-8235-gcd88a97
ntfs.h File Reference
#include <pshpack1.h>
#include <poppack.h>
Include dependency graph for ntfs.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  NTFS_BOOTSECTOR
 
struct  NTFS_RECORD
 
struct  NTFS_MFT_RECORD
 
struct  NTFS_ATTR_RECORD
 
struct  NTFS_INDEX_HEADER
 
struct  NTFS_INDEX_ROOT
 
struct  NTFS_FILE_NAME_ATTR
 
struct  NTFS_ATTR_LIST_ATTR
 
struct  NTFS_INDEX_ENTRY
 
struct  NTFS_ATTR_CONTEXT
 
struct  NTFS_FILE_HANDLE
 

Macros

#define NTFS_FILE_MFT   0
 
#define NTFS_FILE_MFTMIRR   1
 
#define NTFS_FILE_LOGFILE   2
 
#define NTFS_FILE_VOLUME   3
 
#define NTFS_FILE_ATTRDEF   4
 
#define NTFS_FILE_ROOT   5
 
#define NTFS_FILE_BITMAP   6
 
#define NTFS_FILE_BOOT   7
 
#define NTFS_FILE_BADCLUS   8
 
#define NTFS_FILE_QUOTA   9
 
#define NTFS_FILE_UPCASE   10
 
#define NTFS_FILE_EXTEND   11
 
#define NTFS_ATTR_TYPE_STANDARD_INFORMATION   0x10
 
#define NTFS_ATTR_TYPE_ATTRIBUTE_LIST   0x20
 
#define NTFS_ATTR_TYPE_FILENAME   0x30
 
#define NTFS_ATTR_TYPE_OBJECT_ID   0x40
 
#define NTFS_ATTR_TYPE_SECURITY_DESCRIPTOR   0x50
 
#define NTFS_ATTR_TYPE_VOLUME_NAME   0x60
 
#define NTFS_ATTR_TYPE_VOLUME_INFORMATION   0x70
 
#define NTFS_ATTR_TYPE_DATA   0x80
 
#define NTFS_ATTR_TYPE_INDEX_ROOT   0x90
 
#define NTFS_ATTR_TYPE_INDEX_ALLOCATION   0xa0
 
#define NTFS_ATTR_TYPE_BITMAP   0xb0
 
#define NTFS_ATTR_TYPE_REPARSE_POINT   0xc0
 
#define NTFS_ATTR_TYPE_EA_INFORMATION   0xd0
 
#define NTFS_ATTR_TYPE_EA   0xe0
 
#define NTFS_ATTR_TYPE_END   0xffffffff
 
#define NTFS_ATTR_NORMAL   0
 
#define NTFS_ATTR_COMPRESSED   1
 
#define NTFS_ATTR_RESIDENT   2
 
#define NTFS_ATTR_ENCRYPTED   0x4000
 
#define NTFS_SMALL_INDEX   0
 
#define NTFS_LARGE_INDEX   1
 
#define NTFS_INDEX_ENTRY_NODE   1
 
#define NTFS_INDEX_ENTRY_END   2
 
#define NTFS_FILE_NAME_POSIX   0
 
#define NTFS_FILE_NAME_WIN32   1
 
#define NTFS_FILE_NAME_DOS   2
 
#define NTFS_FILE_NAME_WIN32_AND_DOS   3
 
#define NTFS_MFT_MASK   0x0000FFFFFFFFFFFFULL
 

Typedefs

typedef struct NTFS_BOOTSECTORPNTFS_BOOTSECTOR
 
typedef struct NTFS_RECORDPNTFS_RECORD
 
typedef struct NTFS_MFT_RECORDPNTFS_MFT_RECORD
 
typedef struct NTFS_ATTR_RECORDPNTFS_ATTR_RECORD
 
typedef struct NTFS_INDEX_HEADERPNTFS_INDEX_HEADER
 
typedef struct NTFS_INDEX_ROOTPNTFS_INDEX_ROOT
 
typedef struct NTFS_FILE_NAME_ATTRPNTFS_FILE_NAME_ATTR
 
typedef struct NTFS_ATTR_LIST_ATTRPNTFS_ATTR_LIST_ATTR
 
typedef struct NTFS_INDEX_ENTRYPNTFS_INDEX_ENTRY
 
typedef struct NTFS_ATTR_CONTEXTPNTFS_ATTR_CONTEXT
 
typedef struct _NTFS_VOLUME_INFOPNTFS_VOLUME_INFO
 
typedef struct NTFS_FILE_HANDLEPNTFS_FILE_HANDLE
 

Functions

const DEVVTBLNtfsMount (ULONG DeviceId)
 

Macro Definition Documentation

◆ NTFS_ATTR_COMPRESSED

#define NTFS_ATTR_COMPRESSED   1

Definition at line 53 of file ntfs.h.

◆ NTFS_ATTR_ENCRYPTED

#define NTFS_ATTR_ENCRYPTED   0x4000

Definition at line 55 of file ntfs.h.

◆ NTFS_ATTR_NORMAL

#define NTFS_ATTR_NORMAL   0

Definition at line 52 of file ntfs.h.

◆ NTFS_ATTR_RESIDENT

#define NTFS_ATTR_RESIDENT   2

Definition at line 54 of file ntfs.h.

◆ NTFS_ATTR_TYPE_ATTRIBUTE_LIST

#define NTFS_ATTR_TYPE_ATTRIBUTE_LIST   0x20

Definition at line 37 of file ntfs.h.

◆ NTFS_ATTR_TYPE_BITMAP

#define NTFS_ATTR_TYPE_BITMAP   0xb0

Definition at line 46 of file ntfs.h.

◆ NTFS_ATTR_TYPE_DATA

#define NTFS_ATTR_TYPE_DATA   0x80

Definition at line 43 of file ntfs.h.

◆ NTFS_ATTR_TYPE_EA

#define NTFS_ATTR_TYPE_EA   0xe0

Definition at line 49 of file ntfs.h.

◆ NTFS_ATTR_TYPE_EA_INFORMATION

#define NTFS_ATTR_TYPE_EA_INFORMATION   0xd0

Definition at line 48 of file ntfs.h.

◆ NTFS_ATTR_TYPE_END

#define NTFS_ATTR_TYPE_END   0xffffffff

Definition at line 50 of file ntfs.h.

◆ NTFS_ATTR_TYPE_FILENAME

#define NTFS_ATTR_TYPE_FILENAME   0x30

Definition at line 38 of file ntfs.h.

◆ NTFS_ATTR_TYPE_INDEX_ALLOCATION

#define NTFS_ATTR_TYPE_INDEX_ALLOCATION   0xa0

Definition at line 45 of file ntfs.h.

◆ NTFS_ATTR_TYPE_INDEX_ROOT

#define NTFS_ATTR_TYPE_INDEX_ROOT   0x90

Definition at line 44 of file ntfs.h.

◆ NTFS_ATTR_TYPE_OBJECT_ID

#define NTFS_ATTR_TYPE_OBJECT_ID   0x40

Definition at line 39 of file ntfs.h.

◆ NTFS_ATTR_TYPE_REPARSE_POINT

#define NTFS_ATTR_TYPE_REPARSE_POINT   0xc0

Definition at line 47 of file ntfs.h.

◆ NTFS_ATTR_TYPE_SECURITY_DESCRIPTOR

#define NTFS_ATTR_TYPE_SECURITY_DESCRIPTOR   0x50

Definition at line 40 of file ntfs.h.

◆ NTFS_ATTR_TYPE_STANDARD_INFORMATION

#define NTFS_ATTR_TYPE_STANDARD_INFORMATION   0x10

Definition at line 36 of file ntfs.h.

◆ NTFS_ATTR_TYPE_VOLUME_INFORMATION

#define NTFS_ATTR_TYPE_VOLUME_INFORMATION   0x70

Definition at line 42 of file ntfs.h.

◆ NTFS_ATTR_TYPE_VOLUME_NAME

#define NTFS_ATTR_TYPE_VOLUME_NAME   0x60

Definition at line 41 of file ntfs.h.

◆ NTFS_FILE_ATTRDEF

#define NTFS_FILE_ATTRDEF   4

Definition at line 27 of file ntfs.h.

◆ NTFS_FILE_BADCLUS

#define NTFS_FILE_BADCLUS   8

Definition at line 31 of file ntfs.h.

◆ NTFS_FILE_BITMAP

#define NTFS_FILE_BITMAP   6

Definition at line 29 of file ntfs.h.

◆ NTFS_FILE_BOOT

#define NTFS_FILE_BOOT   7

Definition at line 30 of file ntfs.h.

◆ NTFS_FILE_EXTEND

#define NTFS_FILE_EXTEND   11

Definition at line 34 of file ntfs.h.

◆ NTFS_FILE_LOGFILE

#define NTFS_FILE_LOGFILE   2

Definition at line 25 of file ntfs.h.

◆ NTFS_FILE_MFT

#define NTFS_FILE_MFT   0

Definition at line 23 of file ntfs.h.

◆ NTFS_FILE_MFTMIRR

#define NTFS_FILE_MFTMIRR   1

Definition at line 24 of file ntfs.h.

◆ NTFS_FILE_NAME_DOS

#define NTFS_FILE_NAME_DOS   2

Definition at line 65 of file ntfs.h.

◆ NTFS_FILE_NAME_POSIX

#define NTFS_FILE_NAME_POSIX   0

Definition at line 63 of file ntfs.h.

◆ NTFS_FILE_NAME_WIN32

#define NTFS_FILE_NAME_WIN32   1

Definition at line 64 of file ntfs.h.

◆ NTFS_FILE_NAME_WIN32_AND_DOS

#define NTFS_FILE_NAME_WIN32_AND_DOS   3

Definition at line 66 of file ntfs.h.

◆ NTFS_FILE_QUOTA

#define NTFS_FILE_QUOTA   9

Definition at line 32 of file ntfs.h.

◆ NTFS_FILE_ROOT

#define NTFS_FILE_ROOT   5

Definition at line 28 of file ntfs.h.

◆ NTFS_FILE_UPCASE

#define NTFS_FILE_UPCASE   10

Definition at line 33 of file ntfs.h.

◆ NTFS_FILE_VOLUME

#define NTFS_FILE_VOLUME   3

Definition at line 26 of file ntfs.h.

◆ NTFS_INDEX_ENTRY_END

#define NTFS_INDEX_ENTRY_END   2

Definition at line 61 of file ntfs.h.

◆ NTFS_INDEX_ENTRY_NODE

#define NTFS_INDEX_ENTRY_NODE   1

Definition at line 60 of file ntfs.h.

◆ NTFS_LARGE_INDEX

#define NTFS_LARGE_INDEX   1

Definition at line 58 of file ntfs.h.

◆ NTFS_MFT_MASK

#define NTFS_MFT_MASK   0x0000FFFFFFFFFFFFULL

Definition at line 68 of file ntfs.h.

◆ NTFS_SMALL_INDEX

#define NTFS_SMALL_INDEX   0

Definition at line 57 of file ntfs.h.

Typedef Documentation

◆ PNTFS_ATTR_CONTEXT

◆ PNTFS_ATTR_LIST_ATTR

◆ PNTFS_ATTR_RECORD

◆ PNTFS_BOOTSECTOR

◆ PNTFS_FILE_HANDLE

◆ PNTFS_FILE_NAME_ATTR

◆ PNTFS_INDEX_ENTRY

◆ PNTFS_INDEX_HEADER

◆ PNTFS_INDEX_ROOT

◆ PNTFS_MFT_RECORD

◆ PNTFS_RECORD

◆ PNTFS_VOLUME_INFO

Definition at line 241 of file ntfs.h.

Function Documentation

◆ NtfsMount()

const DEVVTBL * NtfsMount ( ULONG  DeviceId)

Definition at line 881 of file ntfs.c.

882{
885 ULONG Count;
887
888 TRACE("Enter NtfsMount(%lu)\n", DeviceId);
889
890 //
891 // Allocate data for volume information
892 //
894 if (!Volume)
895 return NULL;
897
898 //
899 // Read the BootSector
900 //
901 Position.QuadPart = 0;
902 Status = ArcSeek(DeviceId, &Position, SeekAbsolute);
903 if (Status != ESUCCESS)
904 {
906 return NULL;
907 }
908 Status = ArcRead(DeviceId, &Volume->BootSector, sizeof(Volume->BootSector), &Count);
909 if (Status != ESUCCESS || Count != sizeof(Volume->BootSector))
910 {
912 return NULL;
913 }
914
915 //
916 // Check if BootSector is valid. If no, return early
917 //
918 if (!RtlEqualMemory(Volume->BootSector.SystemId, "NTFS", 4))
919 {
921 return NULL;
922 }
923
924 //
925 // Calculate cluster size and MFT record size
926 //
927 Volume->ClusterSize = Volume->BootSector.SectorsPerCluster * Volume->BootSector.BytesPerSector;
928 if (Volume->BootSector.ClustersPerMftRecord > 0)
929 Volume->MftRecordSize = Volume->BootSector.ClustersPerMftRecord * Volume->ClusterSize;
930 else
931 Volume->MftRecordSize = 1 << (-Volume->BootSector.ClustersPerMftRecord);
932 if (Volume->BootSector.ClustersPerIndexRecord > 0)
933 Volume->IndexRecordSize = Volume->BootSector.ClustersPerIndexRecord * Volume->ClusterSize;
934 else
935 Volume->IndexRecordSize = 1 << (-Volume->BootSector.ClustersPerIndexRecord);
936
937 TRACE("ClusterSize: 0x%x\n", Volume->ClusterSize);
938 TRACE("ClustersPerMftRecord: %d\n", Volume->BootSector.ClustersPerMftRecord);
939 TRACE("ClustersPerIndexRecord: %d\n", Volume->BootSector.ClustersPerIndexRecord);
940 TRACE("MftRecordSize: 0x%x\n", Volume->MftRecordSize);
941 TRACE("IndexRecordSize: 0x%x\n", Volume->IndexRecordSize);
942
943 //
944 // Read MFT index
945 //
946 TRACE("Reading MFT index...\n");
947 Volume->MasterFileTable = FrLdrTempAlloc(Volume->MftRecordSize, TAG_NTFS_MFT);
948 if (!Volume->MasterFileTable)
949 {
951 return NULL;
952 }
953 Position.QuadPart = Volume->BootSector.MftLocation * Volume->ClusterSize;
954 Status = ArcSeek(DeviceId, &Position, SeekAbsolute);
955 if (Status != ESUCCESS)
956 {
957 FileSystemError("Failed to seek to Master File Table record.");
958 FrLdrTempFree(Volume->MasterFileTable, TAG_NTFS_MFT);
960 return NULL;
961 }
962 Status = ArcRead(DeviceId, Volume->MasterFileTable, Volume->MftRecordSize, &Count);
963 if (Status != ESUCCESS || Count != Volume->MftRecordSize)
964 {
965 FileSystemError("Failed to read the Master File Table record.");
966 FrLdrTempFree(Volume->MasterFileTable, TAG_NTFS_MFT);
968 return NULL;
969 }
970
971 //
972 // Keep room to read partial sectors
973 //
974 Volume->TemporarySector = FrLdrTempAlloc(Volume->BootSector.BytesPerSector, TAG_NTFS_DATA);
975 if (!Volume->TemporarySector)
976 {
977 FileSystemError("Failed to allocate memory.");
978 FrLdrTempFree(Volume->MasterFileTable, TAG_NTFS_MFT);
980 return NULL;
981 }
982
983 //
984 // Keep device id
985 //
986 Volume->DeviceId = DeviceId;
987
988 //
989 // Search DATA attribute
990 //
991 TRACE("Searching for DATA attribute...\n");
992 Volume->MFTContext = NtfsFindAttribute(Volume, Volume->MasterFileTable, NTFS_ATTR_TYPE_DATA, L"");
993 if (!Volume->MFTContext)
994 {
995 FileSystemError("Can't find data attribute for Master File Table.");
996 FrLdrTempFree(Volume->MasterFileTable, TAG_NTFS_MFT);
998 return NULL;
999 }
1000
1001 //
1002 // Remember NTFS volume information
1003 //
1004 NtfsVolumes[DeviceId] = Volume;
1005
1006 //
1007 // Return success
1008 //
1009 TRACE("NtfsMount(%lu) success\n", DeviceId);
1010 return &NtfsFuncTable;
1011}
#define NTFS_ATTR_TYPE_DATA
Definition: ntfs.h:43
ARC_STATUS ArcSeek(ULONG FileId, LARGE_INTEGER *Position, SEEKMODE SeekMode)
Definition: fs.c:245
VOID FileSystemError(PCSTR ErrorString)
Definition: fs.c:261
ARC_STATUS ArcRead(ULONG FileId, VOID *Buffer, ULONG N, ULONG *Count)
Definition: fs.c:238
FORCEINLINE PVOID FrLdrTempAlloc(_In_ SIZE_T Size, _In_ ULONG Tag)
Definition: mm.h:188
FORCEINLINE VOID FrLdrTempFree(PVOID Allocation, ULONG Tag)
Definition: mm.h:197
PNTFS_VOLUME_INFO NtfsVolumes[MAX_FDS]
Definition: ntfs.c:55
#define TAG_NTFS_MFT
Definition: ntfs.c:35
const DEVVTBL NtfsFuncTable
Definition: ntfs.c:871
#define TAG_NTFS_DATA
Definition: ntfs.c:40
static PNTFS_ATTR_CONTEXT NtfsFindAttribute(PNTFS_VOLUME_INFO Volume, PNTFS_MFT_RECORD MftRecord, ULONG Type, const WCHAR *Name)
Definition: ntfs.c:443
#define TAG_NTFS_VOLUME
Definition: ntfs.c:39
#define NULL
Definition: types.h:112
Status
Definition: gdiplustypes.h:25
#define RtlEqualMemory(dst, src, len)
Definition: kdvm.h:18
UNICODE_STRING Volume
Definition: fltkernel.h:1172
int Count
Definition: noreturn.cpp:7
#define L(x)
Definition: ntvdm.h:50
@ ESUCCESS
Definition: arc.h:32
ULONG ARC_STATUS
Definition: arc.h:4
@ SeekAbsolute
Definition: arc.h:59
#define TRACE(s)
Definition: solgame.cpp:4
static COORD Position
Definition: mouse.c:34
#define RtlZeroMemory(Destination, Length)
Definition: typedefs.h:262
uint32_t ULONG
Definition: typedefs.h:59

Referenced by ArcOpen().