From: krw Date: Sun, 27 Apr 2014 13:41:50 +0000 (+0000) Subject: Don't zap disklabel (and next 6 blocks) when installing boot block on X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=775d271b9404d981ec8cbcd4dddeefa625d5d5d2;p=openbsd Don't zap disklabel (and next 6 blocks) when installing boot block on 4k-sector disk drives. Noted and fix tested by David Vasek via misc@ tweaks & ok jsing@ --- diff --git a/usr.sbin/installboot/i386_installboot.c b/usr.sbin/installboot/i386_installboot.c index 2a0d188cd29..fff16853700 100644 --- a/usr.sbin/installboot/i386_installboot.c +++ b/usr.sbin/installboot/i386_installboot.c @@ -1,4 +1,4 @@ -/* $OpenBSD: i386_installboot.c,v 1.1 2014/01/19 02:58:50 jsing Exp $ */ +/* $OpenBSD: i386_installboot.c,v 1.2 2014/04/27 13:41:50 krw Exp $ */ /* $NetBSD: installboot.c,v 1.5 1995/11/17 23:23:50 gwr Exp $ */ /* @@ -190,9 +190,13 @@ write_bootblocks(int devfd, char *dev, struct disklabel *dl) if (!nowrite) { if (lseek(devfd, (off_t)start * dl->d_secsize, SEEK_SET) < 0) - err(1, "seek bootstrap"); + err(1, "seek boot sector"); secbuf = calloc(1, dl->d_secsize); + if (read(devfd, secbuf, dl->d_secsize) != dl->d_secsize) + err(1, "read boot sector"); bcopy(blkstore, secbuf, blksize); + if (lseek(devfd, (off_t)start * dl->d_secsize, SEEK_SET) < 0) + err(1, "seek bootstrap"); if (write(devfd, secbuf, dl->d_secsize) != dl->d_secsize) err(1, "write bootstrap"); free(secbuf);