📄 fs_fat.h
字号:
#ifndef __FS_FAT_H__
#define __FS_FAT_H__
#define MSDOS_FAT_MAGIC 0x55aa
#pragma packed on
typedef struct __tag_fat_PartitionEntry
{
unsigned char bDefBootPartition;
unsigned char bStartHead; // Zero Base
unsigned char bStartSector; // One Base
unsigned char bStartCylinder;
unsigned char bPartitionType;
unsigned char bEndHead; // Zero Base
unsigned char bEndSector; // One Base
unsigned char bEndCylinder;
unsigned long int dwPartitionBootSector;
unsigned long int dwNumberOfSector;
} FAT_PARTITION_ENTRY;
#pragma packed off
// MBR, Master Boot Record Configuration
#pragma packed on
typedef struct __tag_fat_MBR
{
unsigned char MBR_BootCode[446]; //
FAT_PARTITION_ENTRY MBR_PartitionEntry[4]; // 446 16*4
unsigned short int MBR_wSignature; // 510 2
} FAT_MBR;
#pragma packed off
// Partition Boot Record Configurations
#pragma packed on
typedef struct __tag_fat_PBR_HEAD
{ // ofs size
unsigned char BS_BootJump[3]; // 0 3
unsigned char BS_OEMName[8]; // 3 8
unsigned short int BPB_wBytePerSector; // 11 2
unsigned char BPB_bSectorPerCluster; // 13 1
unsigned short int BPB_wReservedSector; // 14 2
unsigned char BPB_bFATCount; // 16 1
unsigned short int BPB_wRootEntryCount; // 17 2 FAT12 & FAT16 only
unsigned short int BPB_wTotalSector16; // 19 2
unsigned char BPB_bMediaType; // 21 1
unsigned short int BPB_wFATSize16; // 22 2 FAT12 & FAT16 only
unsigned short int BPB_wSectorPerTrack; // 24 2
unsigned short int BPB_wNumberOfHead; // 26 2
unsigned long int BPB_dwHiddenSector; // 28 4
unsigned long int BPB_dwTotalSector32; // 32 4
} FAT_PBR_HEAD; // 36
#pragma packed off
#pragma packed on
typedef struct __tag_fat_PBR_TAIL
{ // ofs16 ofs32 size
unsigned char BS_bDriverNum; // 36 64 1
unsigned char BS_bReserved1; // 37 65 1
unsigned char BS_bBootSignature; // 38 66 1
unsigned char BS_VolumeID[4]; // 39 67 4
unsigned char BS_VolumeLabel[11]; // 43 71 11
unsigned char BS_FileSysType[8]; // 54 82 8 "FAT12 "/"FAT16 "/"FAT32 "
} FAT_PBR_TAIL; // 62 90
#pragma packed off
#pragma packed on
typedef struct __tag_fat_PBR
{ // ofs size
unsigned char BS_BootJump[3]; // 0 3
unsigned char BS_OEMName[8]; // 3 8
unsigned short int BPB_wBytePerSector; // 11 2
unsigned char BPB_bSectorPerCluster; // 13 1
unsigned short int BPB_wReservedSector; // 14 2
unsigned char BPB_bFATCount; // 16 1
unsigned short int BPB_wRootEntryCount; // 17 2 FAT12 & FAT16 only
unsigned short int BPB_wTotalSector16; // 19 2
unsigned char BPB_bMediaType; // 21 1
unsigned short int BPB_wFATSize16; // 22 2 FAT12 & FAT16 only
unsigned short int BPB_wSectorPerTrack; // 24 2
unsigned short int BPB_wNumberOfHead; // 26 2
unsigned long int BPB_dwHiddenSector; // 28 4
unsigned long int BPB_dwTotalSector32; // 32 4
unsigned char BS_Extra[474]; // 36 474
unsigned short int PBR_wSignature; // 510 2
} FAT_PBR; // 512
#pragma packed off
#pragma packed on
typedef struct __tag_fat16_PBR
{
FAT_PBR_HEAD head;
FAT_PBR_TAIL tail;
} FAT16_PBR; // 62
#pragma packed off
#pragma packed on
typedef struct __tag_fat32_PBR
{
FAT_PBR_HEAD head;
unsigned long int BPB_dwFATSize32; // 36 4
unsigned short int BPB_wExtendedFlags; // 40 2
unsigned short int BPB_wFileSysVersion; // 42 2
unsigned long int BPB_dwRootClusterNumber; // 44 4
unsigned short int BPB_wFileSysInfo; // 48 2
unsigned short int BPB_wBackupBootSector; // 50 2
unsigned char BPB_Reserved[12]; // 52 12
FAT_PBR_TAIL tail;
} FAT32_PBR; // 90
#pragma packed on
#define FAT_FILE_ATTR_READONLY 0x01
#define FAT_FILE_ATTR_HIDDEN 0x02
#define FAT_FILE_ATTR_SYSTEM 0x04
#define FAT_FILE_ATTR_VOLUME 0x08
#define FAT_FILE_ATTR_DIRECTORY 0x10
#define FAT_FILE_ATTR_ARCHIVE 0x20
#define FAT_FILE_LONG_NAME_MASK 0x3f
#define FAT_FILE_LONG_NAME (FAT_FILE_ATTR_READONLY | \
FAT_FILE_ATTR_HIDDEN | \
FAT_FILE_ATTR_SYSTEM | \
FAT_FILE_ATTR_VOLUME)
#pragma packed on
typedef struct __tag_DirectoryEntry
{
unsigned char szShortName[11];
unsigned char bAttrib;
unsigned char bReserved1;
unsigned char bCreateTimeTenth;
unsigned short int wCreateTime;
unsigned short int wCreateDate;
unsigned short int wLastAccessDate;
unsigned short int wStartClusterHi;
unsigned short int wLastWriteTime;
unsigned short int wLastWriteDate;
unsigned short int wStartClusterLo;
unsigned long int dwFileSize;
} FAT_DIRECTORY_ENTRY;
#pragma packed off
#pragma packed on
typedef struct __tag_LongDirectoryEntry
{
unsigned char bOrder;
unsigned short int wszName1[5];
unsigned char bAttrib; // must be FAT_FILE_LONG_NAME
unsigned char bType;
unsigned char bChecksum;
unsigned short int wszName2[6];
unsigned short int wReserved1;
unsigned short int wszName3[2];
} FAT_LONG_DIRECTORY_ENTRY;
#pragma packed off
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -