X-Git-Url: https://git.ucc.asn.au/?a=blobdiff_plain;f=KernelLand%2FModules%2FFilesystems%2FNTFS%2Fcommon.h;h=3ef810971e3625056d0fa688aaa5d4f731f0acf8;hb=c5680ddd7aa4934759203aac95f14ac40e5c456b;hp=598120d27c9023e7260448f114ce9ccd58355afa;hpb=48743e39650eb1ef988380e9d95f27fd40d3a9ce;p=tpg%2Facess2.git diff --git a/KernelLand/Modules/Filesystems/NTFS/common.h b/KernelLand/Modules/Filesystems/NTFS/common.h index 598120d2..3ef81097 100644 --- a/KernelLand/Modules/Filesystems/NTFS/common.h +++ b/KernelLand/Modules/Filesystems/NTFS/common.h @@ -6,148 +6,96 @@ * * common.h - Common Types and Definitions */ -#ifndef _COMMON_H_ -#define _COMMON_H_ +#ifndef _NTFS__COMMON_H_ +#define _NTFS__COMMON_H_ #include #include +#include "ntfs.h" -typedef Uint16 WCHAR; +typedef struct sNTFS_File tNTFS_File; +typedef struct sNTFS_Directory tNTFS_Directory; +typedef struct sNTFS_Disk tNTFS_Disk; +typedef struct sNTFS_Attrib tNTFS_Attrib; +typedef struct sNTFS_AttribDataRun tNTFS_AttribDataRun; // === STRUCTURES === + +struct sNTFS_File +{ + tVFS_Node Node; + tNTFS_Attrib *Data; +}; + +struct sNTFS_Directory +{ + tVFS_Node Node; + tNTFS_Attrib *I30Root; + tNTFS_Attrib *I30Allocation; +}; + /** * In-memory representation of an NTFS Disk */ -typedef struct sNTFS_Disk +struct sNTFS_Disk { int FD; - int CacheHandle; + tInodeCache *InodeCache; int ClusterSize; + Uint64 MFTBase; Uint32 MFTRecSize; - tVFS_Node RootNode; -} tNTFS_Disk; + tNTFS_Attrib *MFTDataAttr; + tNTFS_Attrib *MFTBitmapAttr; -typedef struct sNTFS_BootSector -{ - // 0 - Uint8 Jump[3]; - Uint8 SystemID[8]; // = "NTFS " - Uint16 BytesPerSector; - Uint8 SectorsPerCluster; - - // 0xE - Uint8 Unused[7]; - Uint8 MediaDescriptor; - Uint16 Unused2; - Uint16 SectorsPerTrack; - Uint16 Heads; - - // 0x1C - Uint64 Unused3; - Uint32 Unkown; // Usually 0x00800080 (according to Linux docs) - - // 0x28 - Uint64 TotalSectorCount; // Size of volume in sectors - Uint64 MFTStart; // Logical Cluster Number of Cluster 0 of MFT - Uint64 MFTMirrorStart; // Logical Cluster Number of Cluster 0 of MFT Backup - - // 0x40 - // If either of these are -ve, the size can be obtained via - // SizeInBytes = 2^(-1 * Value) - Sint8 ClustersPerMFTRecord; - Uint8 Unused4[3]; - Sint8 ClustersPerIndexRecord; - Uint8 Unused5[3]; - - Uint64 SerialNumber; - - Uint8 Padding[512-0x50]; - -} PACKED tNTFS_BootSector; + tNTFS_Directory RootDir; +}; -/** - * FILE header, an entry in the MFT - */ -typedef struct sNTFS_FILE_Header +struct sNTFS_AttribDataRun { - Uint32 Magic; // 'FILE' - Uint16 UpdateSequenceOfs; - Uint16 UpdateSequenceSize; // Size in words of the UpdateSequenceArray - - Uint64 LSN; // $LogFile Sequence Number - - Uint16 SequenceNumber; - Uint16 HardLinkCount; - Uint16 FirstAttribOfs; // Size of header? - Uint16 Flags; // 0: In Use, 1: Directory - - Uint32 RecordSize; // Real Size of FILE Record - Uint32 RecordSpace; // Allocated Size for FILE Record - - /** - * Base address of the MFT containing this record - */ - Uint64 Reference; // "File reference to the base FILE record" ??? - - Uint16 NextAttribID; - union - { - // Only in XP - struct { - Uint16 AlignTo4Byte; - Uint16 RecordNumber; // Number of this MFT Record - Uint16 UpdateSequenceNumber; - Uint16 UpdateSequenceArray[]; - } XP; - struct { - Uint16 UpdateSequenceNumber; - Uint16 UpdateSequenceArray[]; - } All; - } OSDep; - -} PACKED tNTFS_FILE_Header; + Uint64 Count; + Uint64 LCN; +}; -/** - * File Attribute, follows the FILE header - */ -typedef struct sNTFS_FILE_Attrib +struct sNTFS_Attrib { - Uint32 Type; // See eNTFS_FILE_Attribs - Uint32 Size; // Includes header - - Uint8 ResidentFlag; // (What does this mean?) - Uint8 NameLength; - Uint16 NameOffset; - Uint16 Flags; // 0: Compressed, 14: Encrypted, 15: Sparse - Uint16 AttributeID; - - union - { - struct { - Uint32 AttribLen; // In words - Uint16 AttribOfs; - Uint8 IndexedFlag; - Uint8 Padding; - - Uint16 Name[]; // UTF-16 - // Attribute Data - } Resident; + tNTFS_Disk *Disk; + Uint32 Type; + + char *Name; + + Uint64 DataSize; + + int IsResident; + union { + void *ResidentData; struct { - Uint64 StartingVCN; - Uint64 LastVCN; - Uint16 DataRunOfs; - Uint16 CompressionUnitSize; - Uint32 Padding; - Uint64 AllocatedSize; - Uint64 RealSize; - Uint64 InitiatedSize; // One assumes, ammount of actual data stored - Uint16 Name[]; // UTF-16 - // Data Runs - } NonResident; + int nRuns; + int CompressionUnitL2Size; // 0 = uncompressed + Uint64 FirstPopulatedCluster; + tNTFS_AttribDataRun *Runs; + } NonResident; }; -} PACKED tNTFS_FILE_Attrib; +}; + +extern tVFS_NodeType gNTFS_DirType; +extern tVFS_NodeType gNTFS_FileType; + +extern void NTFS_Close(tVFS_Node *Node); +extern void NTFS_FreeNode(tVFS_Node *Node); +extern int NTFS_int_ApplyUpdateSequence(void *Buf, size_t BufLen, const Uint16 *Sequence, size_t NumEntries); +// -- MFT Access / Manipulation +extern tNTFS_FILE_Header *NTFS_GetMFT(tNTFS_Disk *Disk, Uint32 MFTEntry); +extern void NTFS_ReleaseMFT(tNTFS_Disk *Disk, Uint32 MFTEntry, tNTFS_FILE_Header *Entry); +extern tNTFS_Attrib *NTFS_GetAttrib(tNTFS_Disk *Disk, Uint32 MFTEntry, int Type, const char *Name, int DesIdx); +extern void NTFS_FreeAttrib(tNTFS_Attrib *Attrib); +extern size_t NTFS_ReadAttribData(tNTFS_Attrib *Attrib, Uint64 Offset, size_t Length, void *Buffer); +// -- dir.c +extern int NTFS_ReadDir(tVFS_Node *Node, int Pos, char Dest[FILENAME_MAX]); +extern tVFS_Node *NTFS_FindDir(tVFS_Node *Node, const char *Name, Uint Flags); +// -- io.c +extern size_t NTFS_ReadFile(tVFS_Node *Node, Uint64 Offset, size_t Length, void *Buffer, Uint Flags); #endif