2009-01-29

Master Boot Record

/** * From Solaris x86, /usr/include/dktp/fdisk.h */ struct fdisk_partition { unsigned char bootid; /* bootable? 0=no, 128=yes */ unsigned char beghead; /* beginning head number */ unsigned char begsect; /* beginning sector number */ unsigned char begcyl; /* 10 bit nmbr, with high 2 bits put in begsect */ unsigned char systid; /* Operating System type indicator code */ unsigned char endhead; /* ending head number */ unsigned char endsect; /* ending sector number */ unsigned char endcyl; /* also a 10 bit nmbr, with same high 2 bit trick */ int relsect; /* first sector relative to start of disk */ int numsect; /* number of sectors in partition */ }; struct master_boot_record { char bootinst[446]; /* space to hold actual boot code */ char parts[4 * sizeof (struct fdisk_partition_table)]; ushort signature; /* set to 0xAA55 to indicate PC MBR format */ }; /** * From util-linux-2.12r/fdisk/fdisk.h */ #define sector(s) ((s) & 0x3f) #define cylinder(s, c) ((c) | (((s) & 0xc0) << 2)) struct partition { unsigned char boot_ind; /* 0x80 - active */ unsigned char head; /* starting head */ unsigned char sector; /* starting sector */ unsigned char cyl; /* starting cylinder */ unsigned char sys_ind; /* What partition type */ unsigned char end_head; /* end head */ unsigned char end_sector; /* end sector */ unsigned char end_cyl; /* end cylinder */ unsigned char start4[4]; /* starting sector counting from 0 */ unsigned char size4[4]; /* nr of sectors in partition */ } PACKED;

No comments: