9 #define FAT16_MIN_SECTORS 4085
\r
10 #define FAT32_MIN_CLUSTERS 65525
\r
12 // === On Disk Structures ===
\r
14 * \struct fat_bootsect_s
\r
15 * \brief Bootsector format
\r
17 struct fat_bootsect_s
\r
19 Uint8 jmp[3]; //!< Jump Instruction
\r
20 char oemname[8]; //!< OEM Name. Typically MSDOS1.1
\r
21 Uint16 bps; //!< Bytes per Sector. Assumed to be 512
\r
22 Uint8 spc; //!< Sectors per Cluster
\r
23 Uint16 resvSectCount; //!< Number of reserved sectors at beginning of volume
\r
25 Uint8 fatCount; //!< Number of copies of the FAT
\r
26 Uint16 files_in_root; //!< Count of files in the root directory
\r
27 Uint16 totalSect16; //!< Total sector count (FAT12/16)
\r
28 Uint8 mediaDesc; //!< Media Desctiptor
\r
29 Uint16 fatSz16; //!< FAT Size (FAT12/16)
\r
31 Uint16 spt; //!< Sectors per track. Ignored (Acess uses LBA)
\r
32 Uint16 heads; //!< Heads. Ignored (Acess uses LBA)
\r
33 Uint32 hiddenCount; //!< ???
\r
34 Uint32 totalSect32; //!< Total sector count (FAT32)
\r
37 Uint8 drvNum; //!< Drive Number. BIOS Drive ID (E.g. 0x80)
\r
38 Uint8 resv; //!< Reserved byte
\r
39 Uint8 bootSig; //!< Boot Signature. ???
\r
40 Uint32 volId; //!< Volume ID
\r
41 char label[11]; //!< Disk Label
\r
42 char fsType[8]; //!< FS Type. ???
\r
43 } __attribute__((packed)) fat16; //!< FAT16 Specific information
\r
45 Uint32 fatSz32; //!< 32-Bit FAT Size
\r
46 Uint16 extFlags; //!< Extended flags
\r
47 Uint16 fsVer; //!< Filesystem Version
\r
48 Uint32 rootClust; //!< Root Cluster ID
\r
49 Uint16 fsInfo; //!< FS Info. ???
\r
50 Uint16 backupBS; //!< Backup Bootsector Sector Offset
\r
51 char resv[12]; //!< Reserved Data
\r
52 Uint8 drvNum; //!< Drive Number
\r
53 char resv2; //!< Reserved Data
\r
54 Uint8 bootSig; //!< Boot Signature. ???
\r
55 Uint32 volId; //!< Volume ID
\r
56 char label[11]; //!< Disk Label
\r
57 char fsType[8]; //!< Filesystem Type. ???
\r
58 } __attribute__((packed)) fat32; //!< FAT32 Specific Information
\r
59 }__attribute__((packed)) spec; //!< Non Shared Data
\r
60 char pad[512-90]; //!< Bootsector Data (Code/Boot Signature 0xAA55)
\r
61 } __attribute__((packed));
\r
64 \struct fat_filetable_s
\r
65 \brief Format of a 8.3 file entry on disk
\r
67 struct fat_filetable_s {
\r
68 char name[11]; //!< 8.3 Name
\r
69 Uint8 attrib; //!< File Attributes.
\r
70 Uint8 ntres; //!< Reserved for NT - Set to 0
\r
71 Uint8 ctimems; //!< 10ths of a second ranging from 0-199 (2 seconds)
\r
72 Uint16 ctime; //!< Creation Time
\r
73 Uint16 cdate; //!< Creation Date
\r
74 Uint16 adate; //!< Accessed Date. No Time feild though
\r
75 Uint16 clusterHi; //!< High Cluster. 0 for FAT12 and FAT16
\r
76 Uint16 mtime; //!< Last Modified Time
\r
77 Uint16 mdate; //!< Last Modified Date
\r
78 Uint16 cluster; //!< Low Word of First cluster
\r
79 Uint32 size; //!< Size of file
\r
80 } __attribute__((packed));
\r
83 * \struct fat_longfilename_s
\r
84 * \brief Format of a long file name entry on disk
\r
86 struct fat_longfilename_s {
\r
87 Uint8 id; //!< ID of entry. Bit 6 is set for last entry
\r
88 Uint16 name1[5]; //!< 5 characters of name
\r
89 Uint8 attrib; //!< Attributes. Must be ATTR_LFN
\r
90 Uint8 type; //!< Type. ???
\r
91 Uint8 checksum; //!< Checksum
\r
92 Uint16 name2[6]; //!< 6 characters of name
\r
93 Uint16 firstCluster; //!< Used for non LFN compatability. Set to 0
\r
94 Uint16 name3[2]; //!< Last 2 characters of name
\r
95 } __attribute__((packed));
\r
98 * \name File Attributes
\r
99 * \brief Flag values for ::fat_filetable_s.attrib
\r
102 #define ATTR_READONLY 0x01 //!< Read-only file
\r
103 #define ATTR_HIDDEN 0x02 //!< Hidden File
\r
104 #define ATTR_SYSTEM 0x04 //!< System File
\r
105 #define ATTR_VOLUMEID 0x08 //!< Volume ID (Deprecated)
\r
106 #define ATTR_DIRECTORY 0x10 //!< Directory
\r
108 * \brief File needs archiving
\r
109 * \note User set flag, no significance to the FS driver
\r
111 #define ATTR_ARCHIVE 0x20
\r
113 * \brief Meta Attribute
\r
115 * If ::fat_filetable_s.attrib equals ATTR_LFN the file is a LFN entry
\r
117 #define ATTR_LFN (ATTR_READONLY | ATTR_HIDDEN | ATTR_SYSTEM | ATTR_VOLUMEID)
\r
123 * \name End of Cluster marks
\r
124 * \brief FAT values that indicate the end of a cluster chain in
\r
125 * different versions.
\r
128 #define EOC_FAT12 0x0FFF //!< FAT-12 Mark
\r
129 #define EOC_FAT16 0xFFFF //!< FAT-16 Mark
\r
130 #define EOC_FAT32 0x00FFFFFF //!< FAT-32 Mark
\r
135 typedef struct fat_bootsect_s fat_bootsect;
\r
136 typedef struct fat_filetable_s fat_filetable;
\r
137 typedef struct fat_longfilename_s fat_longfilename;
\r