7 // === On Disk Structures ===
\r
9 \struct fat_bootsect_s
\r
10 \brief Bootsector format
\r
12 struct fat_bootsect_s {
\r
13 Uint8 jmp[3]; //!< Jump Instruction
\r
14 char oemname[8]; //!< OEM Name. Typically MSDOS1.1
\r
15 Uint16 bps; //!< Bytes per Sector. Assumed to be 512
\r
16 Uint8 spc; //!< Sectors per Cluster
\r
17 Uint16 resvSectCount; //!< Number of reserved sectors at beginning of volume
\r
18 Uint8 fatCount; //!< Number of copies of the FAT
\r
19 Uint16 files_in_root; //!< Count of files in the root directory
\r
20 Uint16 totalSect16; //!< Total sector count (FAT12/16)
\r
21 Uint8 mediaDesc; //!< Media Desctiptor
\r
22 Uint16 fatSz16; //!< FAT Size (FAT12/16)
\r
23 Uint16 spt; //!< Sectors per track. Ignored (Acess uses LBA)
\r
24 Uint16 heads; //!< Heads. Ignored (Acess uses LBA)
\r
25 Uint32 hiddenCount; //!< ???
\r
26 Uint32 totalSect32; //!< Total sector count (FAT32)
\r
29 Uint8 drvNum; //!< Drive Number. BIOS Drive ID (E.g. 0x80)
\r
30 Uint8 resv; //!< Reserved byte
\r
31 Uint8 bootSig; //!< Boot Signature. ???
\r
32 Uint32 volId; //!< Volume ID
\r
33 char label[11]; //!< Disk Label
\r
34 char fsType[8]; //!< FS Type. ???
\r
35 } __attribute__((packed)) fat16; //!< FAT16 Specific information
\r
37 Uint32 fatSz32; //!< 32-Bit FAT Size
\r
38 Uint16 extFlags; //!< Extended flags
\r
39 Uint16 fsVer; //!< Filesystem Version
\r
40 Uint32 rootClust; //!< Root Cluster ID
\r
41 Uint16 fsInfo; //!< FS Info. ???
\r
42 Uint16 backupBS; //!< Backup Bootsector Sector Offset
\r
43 char resv[12]; //!< Reserved Data
\r
44 Uint8 drvNum; //!< Drive Number
\r
45 char resv2; //!< Reserved Data
\r
46 Uint8 bootSig; //!< Boot Signature. ???
\r
47 Uint32 volId; //!< Volume ID
\r
48 char label[11]; //!< Disk Label
\r
49 char fsType[8]; //!< Filesystem Type. ???
\r
50 } __attribute__((packed)) fat32; //!< FAT32 Specific Information
\r
51 }__attribute__((packed)) spec; //!< Non Shared Data
\r
52 char pad[512-90]; //!< Bootsector Data (Code/Boot Signature 0xAA55)
\r
53 } __attribute__((packed));
\r
56 \struct fat_filetable_s
\r
57 \brief Format of a 8.3 file entry on disk
\r
59 struct fat_filetable_s {
\r
60 char name[11]; //!< 8.3 Name
\r
61 //char ext[3]; //!< Extention
\r
62 Uint8 attrib; //!< File Attributes.
\r
63 Uint8 ntres; //!< Reserved for NT - Set to 0
\r
64 Uint8 ctimems; //!< 10ths of a second ranging from 0-199 (2 seconds)
\r
65 Uint16 ctime; //!< Creation Time
\r
66 Uint16 cdate; //!< Creation Date
\r
67 Uint16 adate; //!< Accessed Data. No Time feild though
\r
68 Uint16 clusterHi; //!< High Cluster. 0 for FAT12 and FAT16
\r
69 Uint16 mtime; //!< Last Modified Time
\r
70 Uint16 mdate; //!< Last Modified Date
\r
71 Uint16 cluster; //!< Low Word of First cluster
\r
72 Uint32 size; //!< Size of file
\r
73 } __attribute__((packed));
\r
76 \struct fat_longfilename_s
\r
77 \brief Format of a long file name entry on disk
\r
79 struct fat_longfilename_s {
\r
80 Uint8 id; //!< ID of entry. Bit 6 is set for last entry
\r
81 Uint16 name1[5]; //!< 5 characters of name
\r
82 Uint8 attrib; //!< Attributes. Must be ATTR_LFN
\r
83 Uint8 type; //!< Type. ???
\r
84 Uint8 checksum; //!< Checksum
\r
85 Uint16 name2[6]; //!< 6 characters of name
\r
86 Uint16 firstCluster; //!< Used for non LFN compatability. Set to 0
\r
87 Uint16 name3[2]; //!< Last 2 characters of name
\r
88 } __attribute__((packed));
\r
90 #define ATTR_READONLY 0x01
\r
91 #define ATTR_HIDDEN 0x02
\r
92 #define ATTR_SYSTEM 0x04
\r
93 #define ATTR_VOLUMEID 0x08
\r
94 #define ATTR_DIRECTORY 0x10
\r
95 #define ATTR_ARCHIVE 0x20
\r
96 #define ATTR_LFN (ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUMEID)
\r
100 \brief Internal Ids for FAT types
\r
103 // FAT_NULL, //!< NULL Entry
\r
104 FAT12, //!< FAT12 Volume
\r
105 FAT16, //!< FAT16 Volume
\r
106 FAT32, //!< FAT32 Volume
\r
107 // FAT_LAST //!< LAST Entry. Unused
\r
110 #define EOC_FAT12 0x0FFF
\r
111 #define EOC_FAT16 0xFFFF
\r
112 #define EOC_FAT32 0x0FFFFFF
\r
114 typedef struct fat_bootsect_s fat_bootsect;
\r
115 typedef struct fat_filetable_s fat_filetable;
\r
116 typedef struct fat_longfilename_s fat_longfilename;
\r
118 // === Memory Structures ===
\r
120 \struct drv_fat_volinfo_s
\r
121 \brief Representation of a volume in memory
\r
123 struct drv_fat_volinfo_s {
\r
124 int fileHandle; //!< File Handle
\r
125 int type; //!< FAT Type. See eFatType
\r
126 char name[12]; //!< Volume Name (With NULL Terminator)
\r
127 Uint32 firstDataSect; //!< First data sector
\r
128 Uint32 rootOffset; //!< Root Offset (clusters)
\r
129 Uint32 clusterCount; //!< Total Cluster Count
\r
130 fat_bootsect bootsect; //!< Boot Sector
\r
131 tVFS_Node rootNode; //!< Root Node
\r
132 int inodeHandle; //!< Inode Cache Handle
\r
135 typedef struct drv_fat_volinfo_s tFAT_VolInfo;
\r