size of FAT12 boot sector structure
Posted: Sat Dec 22, 2007 1:14 am
sizeof(FATBootStructure) reports this struct is 520 bytes long:
If I use __attribute__((packed)) it becomes 511 bytes long. It is annoying since data near the beginning of the structure is aligned, but not near the end.
Code: Select all
struct FATBootSector
{
unsigned char BootStrapCode[3]; // code to jump to the bootstrap code
unsigned char OEMID[8]; // name of the formatting OS
unsigned short BytesPerSector;
unsigned char SectorsPerCluster;
unsigned short ReservedSectors;
unsigned char FATCopies;
unsigned short NumberOfPossibleRootEntries;
unsigned short TotalSectors;
unsigned char MediaDescriptor;
unsigned short SectorsPerFAT;
unsigned short SectorsPerTrack;
unsigned short NumberOfHeads;
unsigned int HiddenSectors;
unsigned int LargeNumberOfSectors;
union
{
struct
{
unsigned char FATDriveNumber;
unsigned char FAT_Reserved;
unsigned char FATExtendedBootSignature;
unsigned int FATVolumeSerialNumber;
unsigned char FATVolumeLabel[11];
unsigned char FATFileSystemType[8];
unsigned char FATBootstrapCode[448];
};
struct
{
unsigned int FAT32SectorsPerFAT;
unsigned short FAT32FATFlags;
unsigned short FAT32Version;
unsigned int FAT32ClusterNumberOfRootDirectoryStart;
unsigned short FAT32SectorNumberOfFSInformationSector;
unsigned short FAT32SectorNumberOfFSInformationSectorCopy;
unsigned char FAT32_Reserved[12];
unsigned char FAT32DriveNumber;
unsigned char FAT32_Reserved1;
unsigned char FAT32ExtendedBootSignature;
unsigned int FAT32ID;
unsigned char FAT32VolumeLabel[11];
unsigned char FAT32FileSystemType[8];
unsigned char FAT32BootstrapCode[420];
};
};
unsigned char FAT32BootSectorSignature;
};