aboutsummaryrefslogtreecommitdiffstats
path: root/com32/modules
diff options
context:
space:
mode:
authorShao Miller <shao.miller@yrdsb.edu.on.ca>2010-06-28 03:02:14 -0400
committerShao Miller <shao.miller@yrdsb.edu.on.ca>2010-07-10 01:03:06 -0400
commit6ba6279507775172c5d7dfe2a3b147ee0a7a0814 (patch)
tree065af631cf148a8aafc981728342ccefa4ea483b /com32/modules
parent8cee41716005ff8495349241de3eeb33ae7b53a0 (diff)
downloadsyslinux-6ba6279507775172c5d7dfe2a3b147ee0a7a0814.tar.gz
syslinux-6ba6279507775172c5d7dfe2a3b147ee0a7a0814.tar.xz
syslinux-6ba6279507775172c5d7dfe2a3b147ee0a7a0814.zip
chain.c32, libcom32: Move struct mbr as disk_dos_mbr
Also move mbr_sig_magic as disk_mbr_sig_magic macro. Moving portions of chain.c32 into libcom32. Signed-off-by: Shao Miller <shao.miller@yrdsb.edu.on.ca>
Diffstat (limited to 'com32/modules')
-rw-r--r--com32/modules/chain.c40
1 files changed, 16 insertions, 24 deletions
diff --git a/com32/modules/chain.c b/com32/modules/chain.c
index 04b15603..896727d1 100644
--- a/com32/modules/chain.c
+++ b/com32/modules/chain.c
@@ -147,22 +147,12 @@ static inline void error(const char *msg)
static struct disk_info diskinfo;
-/* A DOS MBR */
-struct mbr {
- char code[440];
- uint32_t disk_sig;
- char pad[2];
- struct disk_dos_part_entry table[4];
- uint16_t sig;
-} __attribute__ ((packed));
-static const uint16_t mbr_sig_magic = 0xAA55;
-
/* Search for a specific drive, based on the MBR signature; bytes 440-443 */
static int find_disk(uint32_t mbr_sig)
{
int drive;
bool is_me;
- struct mbr *mbr;
+ struct disk_dos_mbr *mbr;
for (drive = 0x80; drive <= 0xff; drive++) {
if (disk_get_params(drive, &diskinfo))
@@ -229,14 +219,14 @@ static struct disk_part_iter *next_ebr_part(struct disk_part_iter *part)
{
const struct disk_dos_part_entry *ebr_table;
const struct disk_dos_part_entry *parent_table =
- ((const struct mbr *)part->private.ebr.parent->block)->table;
+ ((const struct disk_dos_mbr *)part->private.ebr.parent->block)->table;
static const struct disk_dos_part_entry phony = {.start_lba = 0 };
uint64_t ebr_lba;
/* Don't look for a "next EBR" the first time around */
if (part->private.ebr.parent_index >= 0)
/* Look at the linked list */
- ebr_table = ((const struct mbr *)part->block)->table + 1;
+ ebr_table = ((const struct disk_dos_mbr *)part->block)->table + 1;
/* Do we need to look for an extended partition? */
if (part->private.ebr.parent_index < 0 || !ebr_table->start_lba) {
/* Start looking for an extended partition in the MBR */
@@ -261,7 +251,7 @@ static struct disk_part_iter *next_ebr_part(struct disk_part_iter *part)
error("Could not load EBR!\n");
goto err_ebr;
}
- ebr_table = ((const struct mbr *)part->block)->table;
+ ebr_table = ((const struct disk_dos_mbr *)part->block)->table;
dprintf("next_ebr_part:\n");
disk_dos_part_dump(ebr_table);
@@ -271,8 +261,8 @@ static struct disk_part_iter *next_ebr_part(struct disk_part_iter *part)
* put crap in some entries.
*/
{
- const struct mbr *mbr =
- (const struct mbr *)part->private.ebr.parent->block;
+ const struct disk_dos_mbr *mbr =
+ (const struct disk_dos_mbr *)part->private.ebr.parent->block;
const struct disk_dos_part_entry *extended =
mbr->table + part->private.ebr.parent_index;
@@ -306,7 +296,8 @@ static struct disk_part_iter *next_mbr_part(struct disk_part_iter *part)
{
struct disk_part_iter *ebr_part;
/* Look at the partition table */
- struct disk_dos_part_entry *table = ((struct mbr *)part->block)->table;
+ struct disk_dos_part_entry *table =
+ ((struct disk_dos_mbr *)part->block)->table;
/* Look for data partitions */
while (++part->private.mbr_index < 4) {
@@ -622,7 +613,7 @@ static struct disk_part_iter *get_first_partition(struct disk_part_iter *part)
goto err_read_mbr;
}
/* Check for an MBR */
- if (((struct mbr *)part->block)->sig != mbr_sig_magic) {
+ if (((struct disk_dos_mbr *)part->block)->sig != disk_mbr_sig_magic) {
error("No MBR magic!\n");
goto err_mbr;
}
@@ -909,7 +900,7 @@ enomem:
return;
}
-static int hide_unhide(struct mbr *mbr, int part)
+static int hide_unhide(struct disk_dos_mbr *mbr, int part)
{
int i;
struct disk_dos_part_entry *pt;
@@ -1016,7 +1007,7 @@ See syslinux/com32/modules/chain.c for more information\n";
int main(int argc, char *argv[])
{
- struct mbr *mbr = NULL;
+ struct disk_dos_mbr *mbr = NULL;
char *p;
struct disk_part_iter *cur_part = NULL;
struct syslinux_rm_regs regs;
@@ -1436,10 +1427,11 @@ int main(int argc, char *argv[])
data[ndata].base = load_base;
if (!opt.loadfile) {
- const struct mbr *br =
- (const struct mbr *)((char *)data[ndata].data +
- data[ndata].size - sizeof(struct mbr));
- if (br->sig != mbr_sig_magic) {
+ const struct disk_dos_mbr *br =
+ (const struct disk_dos_mbr *)((char *)data[ndata].data +
+ data[ndata].size -
+ sizeof(struct disk_dos_mbr));
+ if (br->sig != disk_mbr_sig_magic) {
error
("Boot sector signature not found (unbootable disk/partition?)\n");
goto bail;