diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 1997-08-30 02:13:49 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 1997-08-30 02:13:49 +0000 |
commit | 0c3d9b3e167ecbadde8d858630d069f66dcfc70d (patch) | |
tree | d74ce0076c7dace38258e9cfea37c1c16389f297 /sys | |
parent | 3d831030ef38d51545a20845e26a5b6b696f2235 (diff) |
don't muck w/ MBR on !hd
Diffstat (limited to 'sys')
-rw-r--r-- | sys/arch/i386/stand/installboot/installboot.c | 46 |
1 files changed, 25 insertions, 21 deletions
diff --git a/sys/arch/i386/stand/installboot/installboot.c b/sys/arch/i386/stand/installboot/installboot.c index 3dfaa3164c9..67a1671f624 100644 --- a/sys/arch/i386/stand/installboot/installboot.c +++ b/sys/arch/i386/stand/installboot/installboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: installboot.c,v 1.7 1997/08/29 20:08:36 mickey Exp $ */ +/* $OpenBSD: installboot.c,v 1.8 1997/08/30 02:13:48 mickey Exp $ */ /* $NetBSD: installboot.c,v 1.5 1995/11/17 23:23:50 gwr Exp $ */ /* @@ -104,6 +104,7 @@ main(argc, argv) struct disklabel dl; struct dos_mbr mbr; struct dos_partition *dp; + off_t startoff = 0; nsectors = heads = -1; while ((c = getopt(argc, argv, "vnh:s:")) != EOF) { @@ -204,30 +205,33 @@ main(argc, argv) /* Sync filesystems (to clean in-memory superblock?) */ sync(); sleep(1); - if (lseek(devfd, (off_t)DOSBBSECTOR, SEEK_SET) < 0 || - read(devfd, &mbr, sizeof(mbr)) < sizeof(mbr)) - err(4, "can't read master boot record"); - - if (mbr.dmbr_sign != DOSMBR_SIGNATURE) - errx(1, "broken MBR"); - - /* Find OpenBSD partition. */ - for (dp = mbr.dmbr_parts; dp < &mbr.dmbr_parts[NDOSPART]; dp++) { - if (dp->dp_size && dp->dp_typ == DOSPTYP_OPENBSD) { - fprintf(stderr, "using MBR partition %d: " - "type %d (0x%02x) offset %d (0x%x)\n", - dp - mbr.dmbr_parts, - dp->dp_typ, dp->dp_typ, - dp->dp_start, dp->dp_start); - break; + if (dl.d_type != 0 && dl.d_type < DTYPE_FLOPPY) { + if (lseek(devfd, (off_t)DOSBBSECTOR, SEEK_SET) < 0 || + read(devfd, &mbr, sizeof(mbr)) < sizeof(mbr)) + err(4, "can't read master boot record"); + + if (mbr.dmbr_sign != DOSMBR_SIGNATURE) + errx(1, "broken MBR"); + + /* Find OpenBSD partition. */ + for (dp = mbr.dmbr_parts; dp < &mbr.dmbr_parts[NDOSPART]; dp++) { + if (dp->dp_size && dp->dp_typ == DOSPTYP_OPENBSD) { + startoff = dp->dp_start * dl.d_secsize; + fprintf(stderr, "using MBR partition %d: " + "type %d (0x%02x) offset %d (0x%x)\n", + dp - mbr.dmbr_parts, + dp->dp_typ, dp->dp_typ, + dp->dp_start, dp->dp_start); + break; + } } + /* don't check for old part number, that is ;-p */ + if (dp >= &mbr.dmbr_parts[NDOSPART]) + errx(1, "no OpenBSD partition"); } - /* don't check for old part number, that is ;-p */ - if (dp >= &mbr.dmbr_parts[NDOSPART]) - errx(1, "no OpenBSD partition"); if (!nowrite) { - if (lseek(devfd, dp->dp_start * dl.d_secsize, SEEK_SET) < 0 || + if (lseek(devfd, startoff, SEEK_SET) < 0 || write(devfd, protostore, protosize) != protosize) err(1, "write bootstrap"); } |