9 // === On Disk Structures ===
\r
11 * \struct fat_bootsect_s
\r
12 * \brief Bootsector format
\r
14 struct fat_bootsect_s
\r
16 Uint8 jmp[3]; //!< Jump Instruction
\r
17 char oemname[8]; //!< OEM Name. Typically MSDOS1.1
\r
18 Uint16 bps; //!< Bytes per Sector. Assumed to be 512
\r
19 Uint8 spc; //!< Sectors per Cluster
\r
20 Uint16 resvSectCount; //!< Number of reserved sectors at beginning of volume
\r
22 Uint8 fatCount; //!< Number of copies of the FAT
\r
23 Uint16 files_in_root; //!< Count of files in the root directory
\r
24 Uint16 totalSect16; //!< Total sector count (FAT12/16)
\r
25 Uint8 mediaDesc; //!< Media Desctiptor
\r
26 Uint16 fatSz16; //!< FAT Size (FAT12/16)
\r
28 Uint16 spt; //!< Sectors per track. Ignored (Acess uses LBA)
\r
29 Uint16 heads; //!< Heads. Ignored (Acess uses LBA)
\r
30 Uint32 hiddenCount; //!< ???
\r
31 Uint32 totalSect32; //!< Total sector count (FAT32)
\r
34 Uint8 drvNum; //!< Drive Number. BIOS Drive ID (E.g. 0x80)
\r
35 Uint8 resv; //!< Reserved byte
\r
36 Uint8 bootSig; //!< Boot Signature. ???
\r
37 Uint32 volId; //!< Volume ID
\r
38 char label[11]; //!< Disk Label
\r
39 char fsType[8]; //!< FS Type. ???
\r
40 } __attribute__((packed)) fat16; //!< FAT16 Specific information
\r
42 Uint32 fatSz32; //!< 32-Bit FAT Size
\r
43 Uint16 extFlags; //!< Extended flags
\r
44 Uint16 fsVer; //!< Filesystem Version
\r
45 Uint32 rootClust; //!< Root Cluster ID
\r
46 Uint16 fsInfo; //!< FS Info. ???
\r
47 Uint16 backupBS; //!< Backup Bootsector Sector Offset
\r
48 char resv[12]; //!< Reserved Data
\r
49 Uint8 drvNum; //!< Drive Number
\r
50 char resv2; //!< Reserved Data
\r
51 Uint8 bootSig; //!< Boot Signature. ???
\r
52 Uint32 volId; //!< Volume ID
\r
53 char label[11]; //!< Disk Label
\r
54 char fsType[8]; //!< Filesystem Type. ???
\r
55 } __attribute__((packed)) fat32; //!< FAT32 Specific Information
\r
56 }__attribute__((packed)) spec; //!< Non Shared Data
\r
57 char pad[512-90]; //!< Bootsector Data (Code/Boot Signature 0xAA55)
\r
58 } __attribute__((packed));
\r
61 \struct fat_filetable_s
\r
62 \brief Format of a 8.3 file entry on disk
\r
64 struct fat_filetable_s {
\r
65 char name[11]; //!< 8.3 Name
\r
66 Uint8 attrib; //!< File Attributes.
\r
67 Uint8 ntres; //!< Reserved for NT - Set to 0
\r
68 Uint8 ctimems; //!< 10ths of a second ranging from 0-199 (2 seconds)
\r
69 Uint16 ctime; //!< Creation Time
\r
70 Uint16 cdate; //!< Creation Date
\r
71 Uint16 adate; //!< Accessed Date. No Time feild though
\r
72 Uint16 clusterHi; //!< High Cluster. 0 for FAT12 and FAT16
\r
73 Uint16 mtime; //!< Last Modified Time
\r
74 Uint16 mdate; //!< Last Modified Date
\r
75 Uint16 cluster; //!< Low Word of First cluster
\r
76 Uint32 size; //!< Size of file
\r
77 } __attribute__((packed));
\r
80 * \struct fat_longfilename_s
\r
81 * \brief Format of a long file name entry on disk
\r
83 struct fat_longfilename_s {
\r
84 Uint8 id; //!< ID of entry. Bit 6 is set for last entry
\r
85 Uint16 name1[5]; //!< 5 characters of name
\r
86 Uint8 attrib; //!< Attributes. Must be ATTR_LFN
\r
87 Uint8 type; //!< Type. ???
\r
88 Uint8 checksum; //!< Checksum
\r
89 Uint16 name2[6]; //!< 6 characters of name
\r
90 Uint16 firstCluster; //!< Used for non LFN compatability. Set to 0
\r
91 Uint16 name3[2]; //!< Last 2 characters of name
\r
92 } __attribute__((packed));
\r
95 * \name File Attributes
\r
96 * \brief Flag values for ::fat_filetable_s.attrib
\r
99 #define ATTR_READONLY 0x01 //!< Read-only file
\r
100 #define ATTR_HIDDEN 0x02 //!< Hidden File
\r
101 #define ATTR_SYSTEM 0x04 //!< System File
\r
102 #define ATTR_VOLUMEID 0x08 //!< Volume ID (Deprecated)
\r
103 #define ATTR_DIRECTORY 0x10 //!< Directory
\r
105 * \brief File needs archiving
\r
106 * \note User set flag, no significance to the FS driver
\r
108 #define ATTR_ARCHIVE 0x20
\r
110 * \brief Meta Attribute
\r
112 * If ::fat_filetable_s.attrib equals ATTR_LFN the file is a LFN entry
\r
114 #define ATTR_LFN (ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUMEID)
\r
120 * \brief Internal IDs for FAT types
\r
124 FAT12, //!< FAT12 Volume
\r
125 FAT16, //!< FAT16 Volume
\r
126 FAT32, //!< FAT32 Volume
\r
130 * \name End of Cluster marks
\r
131 * \brief FAT values that indicate the end of a cluster chain in
\r
132 * different versions.
\r
135 #define EOC_FAT12 0x0FFF //!< FAT-12 Mark
\r
136 #define EOC_FAT16 0xFFFF //!< FAT-16 Mark
\r
137 #define EOC_FAT32 0x00FFFFFF //!< FAT-32 Mark
\r
142 typedef struct fat_bootsect_s fat_bootsect;
\r
143 typedef struct fat_filetable_s fat_filetable;
\r
144 typedef struct fat_longfilename_s fat_longfilename;
\r
146 // === Memory Structures ===
\r
148 * \struct drv_fat_volinfo_s
\r
149 * \brief Representation of a volume in memory
\r
151 struct drv_fat_volinfo_s
\r
153 int fileHandle; //!< File Handle
\r
154 int type; //!< FAT Type. See eFatType
\r
155 char name[12]; //!< Volume Name (With NULL Terminator)
\r
156 tMutex lFAT; //!< Lock to prevent double-writing to the FAT
\r
157 Uint32 firstDataSect; //!< First data sector
\r
158 Uint32 rootOffset; //!< Root Offset (clusters)
\r
159 Uint32 ClusterCount; //!< Total Cluster Count
\r
160 fat_bootsect bootsect; //!< Boot Sector
\r
161 tVFS_Node rootNode; //!< Root Node
\r
162 int BytesPerCluster;
\r
163 int inodeHandle; //!< Inode Cache Handle
\r
165 Uint32 *FATCache; //!< FAT Cache
\r
169 typedef struct drv_fat_volinfo_s tFAT_VolInfo;
\r