Skip to content

FAT

struct fat12_16_ext_bpb {
uint8_t drive_number;
uint8_t reserved;
uint8_t boot_signature;
uint32_t volume_id;
uint8_t volume_label[11];
uint8_t fs_type[8];
uint8_t reserved1[448];
};
struct fat32_ext_bpb {
uint32_t fat_size_32;
uint16_t ext_flags;
uint16_t fs_version;
uint32_t root_cluster;
uint16_t fs_info;
uint16_t backup_boot_sector;
uint8_t reserved[12];
uint8_t drive_number;
uint8_t reserved1;
uint8_t boot_signature;
uint32_t volume_id;
uint8_t volume_label[11];
uint8_t fs_type[8];
uint8_t reserved2[420];
};
struct fat_bpb {
uint8_t jump_boot[3];
uint8_t oem_name[8];
uint16_t bytes_per_sector;
uint8_t sectors_per_cluster;
uint16_t reserved_sector_count;
uint8_t num_fats;
uint16_t root_entry_count;
uint16_t total_sectors_16;
uint8_t media;
uint16_t fat_size_16;
uint16_t sectors_per_track;
uint16_t num_heads;
uint32_t hidden_sectors;
uint32_t total_sectors_32;
union {
struct fat32_ext_bpb ext_32;
struct fat12_16_ext_bpb ext_12_16;
};
};

struct fat_bpb referenced types:

struct fat_date {
uint16_t day;
uint16_t month;
uint16_t year;
};
struct fat_time {
uint16_t second;
uint16_t minute;
uint16_t hour;
};
struct fat_dirent {
char name[11];
enum fat_fileattr attr;
uint8_t ntres;
uint8_t crttimetenth;
struct fat_time crttime;
struct fat_date crtdate;
struct fat_date lastaccess;
uint16_t high_cluster;
struct fat_time modtime;
struct fat_date moddate;
uint16_t low_cluster;
uint32_t filesize;
};

struct fat_dirent referenced types:

struct fat_fs {
enum fat_fstype type;
struct fat_bpb *bpb;
struct generic_partition *partition;
struct generic_disk *disk;
uint32_t volume_base_lba;
uint32_t total_clusters;
uint32_t root_cluster;
uint32_t cluster_size;
uint32_t fsinfo_sector;
uint32_t free_clusters;
uint32_t last_alloc_cluster;
uint32_t entries_per_cluster;
uint16_t fat_size;
uint8_t boot_signature;
uint8_t drive_number;
uint32_t volume_id;
uint8_t volume_label[11];
uint8_t fs_type[8];
};

struct fat_fs referenced types:

enum fat_fstype {
FAT_12,
FAT_16,
FAT_32,
};
enum fat_fileattr {
FAT_RO = 0x01,
FAT_HIDDEN = 0x02,
FAT_SYSTEM = 0x04,
FAT_VOL_ID = 0x08,
FAT_DIR = 0x10,
FAT_ARCHIVE = 0x20,
};
typedef bool (*fat_walk_callback)(struct fat_dirent *, uint32_t, void *);

type alias fat_walk_callback referenced types:

char get_fileattr_string(enum fat_fileattr f);

get_fileattr_string referenced types:

#define FAT12_PARTITION_TYPE 0x01 // FAT12, CHS addressing
#define FAT16_PARTITION_TYPE 0x04 // FAT16, CHS addressing (less than 32MB)
#define FAT16_PARTITION_TYPE2 0x06 // FAT16, LBA addressing (greater than 32MB)
#define FAT32_PARTITION_TYPE1 0x0B // FAT32, CHS addressing
#define FAT32_PARTITION_TYPE2 0x0C // FAT32, LBA addressing
#define FAT_DIR_CLUSTER_ROOT 0xFFFFFFFF