summaryrefslogtreecommitdiff
path: root/sbin/disklabel
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2010-08-03 00:08:31 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2010-08-03 00:08:31 +0000
commit611cd11b9b0b71643ab376833c2d19baf6608987 (patch)
tree9a8c0bd09d9abb9445bc785c135aba8879c6ea95 /sbin/disklabel
parent0ab20addf8170413e72716f47cad51549ac6513e (diff)
Start with the default label when RESTORE'ing a saved ascii label.
This ensures that all physical fields are filled in with current values. Lack of values (boundstart, boundend in particular) noted by ray@. ok deraadt@
Diffstat (limited to 'sbin/disklabel')
-rw-r--r--sbin/disklabel/disklabel.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c
index 6b1e24df180..7047ad7840d 100644
--- a/sbin/disklabel/disklabel.c
+++ b/sbin/disklabel/disklabel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disklabel.c,v 1.167 2010/07/27 00:07:26 krw Exp $ */
+/* $OpenBSD: disklabel.c,v 1.168 2010/08/03 00:08:30 krw Exp $ */
/*
* Copyright (c) 1987, 1993
@@ -265,11 +265,13 @@ main(int argc, char *argv[])
case RESTORE:
if (argc < 2 || argc > 3)
usage();
+ readlabel(f);
#if NUMBOOT > 0
if (installboot && argc == 3)
makelabel(argv[2], NULL, &lab);
#endif
lp = makebootarea(bootarea, &lab, f);
+ *lp = lab;
if (!(t = fopen(argv[1], "r")))
err(4, "%s", argv[1]);
error = getasciilabel(t, lp);
@@ -481,7 +483,7 @@ readlabel(int f)
if (cflag && ioctl(f, DIOCRLDINFO) < 0)
err(4, "ioctl DIOCRLDINFO");
- if (dflag | aflag) {
+ if ((op == RESTORE) || dflag || aflag) {
if (ioctl(f, DIOCGPDINFO, &lab) < 0)
err(4, "ioctl DIOCGPDINFO");
} else {