diff options
author | Michael Shalayeff <mickey@cvs.openbsd.org> | 1996-05-17 15:32:59 +0000 |
---|---|---|
committer | Michael Shalayeff <mickey@cvs.openbsd.org> | 1996-05-17 15:32:59 +0000 |
commit | cd5ef24052ff5dadafdc22b97023407ede8c8e81 (patch) | |
tree | 0069abb0d369eed02ff7e1d82689b81da4515a15 /sbin | |
parent | 4aa218b4570f236136496b4ca19d531b79defd48 (diff) |
from Hiroyuki Ito:
there is a race condition exists when disklabel
trashes boot blocks (writing label w/o -B).
fix this.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/disklabel/disklabel.c | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c index 56bdf71c2ba..b39d399f577 100644 --- a/sbin/disklabel/disklabel.c +++ b/sbin/disklabel/disklabel.c @@ -1,4 +1,4 @@ -/* $OpenBSD: disklabel.c,v 1.4 1996/05/16 11:08:54 pefo Exp $ */ +/* $OpenBSD: disklabel.c,v 1.5 1996/05/17 15:32:58 mickey Exp $ */ /* $NetBSD: disklabel.c,v 1.30 1996/03/14 19:49:24 ghudson Exp $ */ /* @@ -427,6 +427,25 @@ writelabel(f, boot, lp) } sectoffset = 0; } + /* + * If we are not installing a boot program + * we must read the current bootarea so we don't + * clobber the existing boot. + */ + if (!installboot) { + struct disklabel tlab; + + if (lseek(f, sectoffset, SEEK_SET) < 0) { + perror("lseek"); + return (1); + } + tlab = *lp; + if (read(f, boot, tlab.d_bbsize) != tlab.d_bbsize) { + perror("read"); + return (1); + } + *lp =tlab; + } #endif /* @@ -665,11 +684,13 @@ makebootarea(boot, dp, f) * clobber the existing boot. */ if (!installboot) { +#ifndef i386 if (rflag) { if (read(f, boot, BBSIZE) < BBSIZE) err(4, "%s", specname); memset(lp, 0, sizeof *lp); } +#endif return (lp); } /* |