Subject: port-i386/9590: disklabel -r -R clobbers boot code on i386 (+fix)
To: None <gnats-bugs@gnats.netbsd.org, gsollish@mail.gisco.net, frank@wins.uva.nl,>
From: None <salvet@ics.muni.cz>
List: netbsd-bugs
Date: 03/09/2000 07:54:37
>Number: 9590
>Category: port-i386
>Synopsis: disklabel -r -R clobbers boot code on i386
>Confidential: no
>Severity: serious
>Priority: high
>Responsible: port-i386-maintainer (NetBSD/i386 Portmaster)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Thu Mar 9 07:54:00 2000
>Last-Modified:
>Originator: Zdenek Salvet
>Organization:
Masaryk University, Brno, Czech Republic
>Release: 1.4.1, 1.4.2, -current of Mar 9, 2000
>Environment:
i386-1.4.1, i386-1.4.2
>Description:
>How-To-Repeat:
disklabel wd0 >wd0.label
# edit, e.g. to add MSDOS partition
disklabel -r -R wd0 wd0.label
reboot
<< watch bootselector return error 3 >>
<< recover by running installboot from floppy >>
>Fix:
Add MBR support to SAVEBOOTAREA code and define SAVEBOOTAREA
for i386.
patch against current of Thu Mar 9, 2000:
(apply in /usr/src/sbin)
diff -ur disklabel/Makefile disklabel.new/Makefile
--- disklabel/Makefile Tue Feb 1 04:14:19 2000
+++ disklabel.new/Makefile Thu Mar 9 09:00:44 2000
@@ -7,13 +7,6 @@
LDADD+= -lutil
DPADD+= ${LIBUTIL}
-.if (${MACHINE} == "i386")
-# recognize old partition ID for a while
-CPPFLAGS+= -DCOMPAT_386BSD_MBRPART
-# use MBR partition info
-CPPFLAGS+= -DUSE_MBR
-.endif
-
.if (${MACHINE} == "hp300") || (${MACHINE} == "vax") \
|| (${MACHINE} == "arm32")
CPPFLAGS+= -DNUMBOOT=1
@@ -31,7 +24,7 @@
CPPFLAGS+= -DSAVEBOOTAREA
.endif
-.if (${MACHINE} == "hpcmips" || ${MACHINE} == "arc")
+.if (${MACHINE} == "hpcmips" || ${MACHINE} == "arc" || ${MACHINE} == "i386")
# recognize old partition ID for a while
CPPFLAGS+= -DCOMPAT_386BSD_MBRPART
# use MBR partition info
diff -ur disklabel/disklabel.c disklabel.new/disklabel.c
--- disklabel/disklabel.c Tue Feb 1 04:14:19 2000
+++ disklabel.new/disklabel.c Thu Mar 9 08:56:47 2000
@@ -894,6 +894,10 @@
if (rflag) {
off_t sectoffset = 0;
+#ifdef USE_MBR
+ if (dosdp)
+ sectoffset = (off_t)dosdp->mbrp_start * DEV_BSIZE;
+#endif
if (lseek(f, sectoffset, SEEK_SET) < 0 ||
read(f, boot, BBSIZE) < BBSIZE)
err(4, "%s", specname);
>Audit-Trail:
>Unformatted: