// FAT disk structure definitions // // Author: J. van Wijk // // JvW 04-12-97 Initial version, derived from DFSHPFS // #ifndef DFSFAT_H #define DFSFAT_H #define FAT_MAXCLUST ((ULONG) 0x0ffffff5) // found max for FAT32 #define FAT_MINEOFCL ((ULONG) 0x0ffffff8) #define SG_FAT12 2 #define SV_FAT12 (char)0xff,(char)0xff typedef struct s_fat12 // FAT disk structure 12-bit { BYTE MediaType; char Signature[SG_FAT12]; BYTE Reserved[509]; } S_FAT12; // end of struct "s_fat12" #define SG_FAT16 3 #define SV_FAT16 (char)0xff,(char)0xff,(char)0xff typedef struct s_fat16 // FAT disk structure 16-bit { BYTE MediaType; char Signature[SG_FAT16]; BYTE Reserved[508]; } S_FAT16; // end of struct "s_fat16" #define SG_FAT32 7 #define SV_FAT32 (char)0xff,(char)0xff,(char)0xff, \ (char)0xff,(char)0xff,(char)0xff,(char)0xff typedef struct s_fat32 // FAT disk structure 32-bit { BYTE MediaType; char Signature[SG_FAT32]; BYTE Reserved[504]; } S_FAT32; // end of struct "s_fat32" #if defined (WIN32) // force 16-bit on MSC++ #define DFS_BITFIELD unsigned short #else #define DFS_BITFIELD unsigned #endif typedef struct s_time { DFS_BITFIELD twosecs : 5; DFS_BITFIELD minutes : 6; DFS_BITFIELD hours : 5; } S_TIME; typedef struct s_date { DFS_BITFIELD day : 5; DFS_BITFIELD month : 4; DFS_BITFIELD year : 7; } S_DATE; typedef union s_datim // combined date/time int { S_TIME t; S_DATE d; USHORT u; } S_DATIM; // end of union "s_datim" #define FAT_DIRFREE 0x00 // Fat dir free entrie #define FAT_DIRDEL 0xe5 // Fat dir deleted entry #define FAT_DIRDOT 0x2e // Fat dir . or .. entry #define FAT_DIRENT 16 // Fat dir entries per sector #define FAT_NSIZE 8 #define FAT_ESIZE 3 typedef struct s_fatdir { char Name[ FAT_NSIZE]; // Name part 8.3 char Ext[ FAT_ESIZE]; // Ext. part 8.3 BYTE FatAttrib; // FAT attribute bits BYTE Vlcase; // VFAT lowercase flag BYTE Vctime_ms; // VFAT creation time millisec S_DATIM Vctime; // VFAT creation time S_DATIM Vcdate; // VFAT creation date S_DATIM Vadate; // VFAT last-access time union { USHORT OS2EA; // OS/2 EA index in EA DATA USHORT clustHi; // High word of 32-bit cluster }; // end of union S_DATIM time; // Last modification time S_DATIM date; // Last modification date USHORT clust; // First cluster number ULONG fsize; // File size } S_FATDIR; // end of struct "s_fatdir" #define VFAT_ATTRIB 0x0f // fixed attrib value lfn's #define VFAT_CLUSTR 0x00 // fixed cluster value lfn's #define VFAT_SLOT_1 0x40 // bit-mask for 1st lfn slot typedef struct s_vfslot { BYTE SlotId; // USHORT lfn5[5]; // 1st group unicode chars lfn BYTE FatAttrib; // FAT attribute bits BYTE Vzero; // reserved, must be zero BYTE Vcheck; // VFAT 8.3 alias checksum USHORT lfn6[6]; // 2nd group unicode chars lfn USHORT clust; // First cluster number (zero!) USHORT lfn2[2]; // 3rd group unicode chars lfn } S_VFSLOT; // end of struct "s_vfslot" typedef union s_vfat { S_FATDIR d; // FAT directory entry S_VFSLOT v; // VFAT lsn entry } S_VFAT; // end of union "s_vfat" /* */ #define SV_EACLUST ((USHORT) 0x4145) #define FAT_EAOFFS ((USHORT) 30) // offset to 1st eadata typedef struct s_eaclust { USHORT signature; // signature 'EA' = 0x4145 USHORT index; // EA-index, matching OS2EA ULONG reserv1; // unknown, assume 0 for now char fname[12]; // null-terminated filename BYTE reserv2[6]; // unknown USHORT ealength; // total length of EA data BYTE reserv3[2]; // unknown S_EABLK eadata[1]; // first of EA-data sequence } S_EACLUST; // end of struct "s_eaclust" /* Note: The eadata[1] field actualy is a repeating, variable length structure for each EA belonging to the file. */ #define SV_EAINDEX ((USHORT) 0x4445) #define EAI_SIZE 240 typedef struct s_eaindex { USHORT signature; // signature 'EA' = 0x4145 BYTE reserv1[30]; // unknown, seems to be 0 USHORT base[EAI_SIZE]; // Base values for Map USHORT mapsector[1]; // First of Map sectors } S_EAINDEX; // end of struct "s_eaclust" /* Note: above EAINDEX structure is defined here at it's minimum size being two sectors like seen on 1 sector/cluster volumes (diskettes) On a harddisk it is usualy 1 cluster, depending on the number of EA's actualy present. */ #endif