1 /* 2 * msdos common header file 3 * [obtained from mtools -wfj] 4 * how to decipher DOS disk structures in coexisting with DOS 5 */ 6 7 #define MSECTOR_SIZE 512 /* MSDOS sector size in bytes */ 8 #define MDIR_SIZE 32 /* MSDOS directory size in bytes */ 9 #define MAX_CLUSTER 8192 /* largest cluster size */ 10 #define MAX_PATH 128 /* largest MSDOS path length */ 11 #define MAX_DIR_SECS 64 /* largest directory (in sectors) */ 12 13 #define NEW 1 14 #define OLD 0 15 16 struct directory { 17 unsigned char name[8]; /* file name */ 18 unsigned char ext[3]; /* file extension */ 19 unsigned char attr; /* attribute byte */ 20 unsigned char reserved[10]; /* ?? */ 21 unsigned char time[2]; /* time stamp */ 22 unsigned char date[2]; /* date stamp */ 23 unsigned char start[2]; /* starting cluster number */ 24 unsigned char size[4]; /* size of the file */ 25 }; 26 27 struct bootsector { 28 unsigned char jump[3]; /* Jump to boot code */ 29 unsigned char banner[8]; /* OEM name & version */ 30 unsigned char secsiz[2]; /* Bytes per sector hopefully 512 */ 31 unsigned char clsiz; /* Cluster size in sectors */ 32 unsigned char nrsvsect[2]; /* Number of reserved (boot) sectors */ 33 unsigned char nfat; /* Number of FAT tables hopefully 2 */ 34 unsigned char dirents[2]; /* Number of directory slots */ 35 unsigned char psect[2]; /* Total sectors on disk */ 36 unsigned char descr; /* Media descriptor=first byte of FAT */ 37 unsigned char fatlen[2]; /* Sectors in FAT */ 38 unsigned char nsect[2]; /* Sectors/track */ 39 unsigned char nheads[2]; /* Heads */ 40 unsigned char nhs[4]; /* number of hidden sectors */ 41 unsigned char bigsect[4]; /* big total sectors */ 42 unsigned char junk[476]; /* who cares? */ 43 }; 44 45 /* DOS partition table -- located in boot block */ 46 47 #define DOSBBSECTOR 0 /* DOS boot block relative sector number */ 48 #define DOSPARTOFF 446 49 #define NDOSPART 4 50 51 struct dos_partition { 52 unsigned char dp_flag; /* bootstrap flags */ 53 unsigned char dp_shd; /* starting head */ 54 unsigned char dp_ssect; /* starting sector */ 55 unsigned char dp_scyl; /* starting cylinder */ 56 unsigned char dp_typ; /* partition type */ 57 #define DOSPTYP_386BSD 0xa5 /* 386BSD partition type */ 58 unsigned char dp_ehd; /* end head */ 59 unsigned char dp_esect; /* end sector */ 60 unsigned char dp_ecyl; /* end cylinder */ 61 unsigned long dp_start; /* absolute starting sector number */ 62 unsigned long dp_size; /* partition size in sectors */ 63 } dos_partitions[NDOSPART]; 64