summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2007-05-24 13:01:24 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2007-05-24 13:01:24 +0000
commitec203dafb689adf25a28be214786944bba293f38 (patch)
tree8dff4caceabb13380d3215d1c7dcce965f754daf
parent721363f3c82896423f35701a6a4a6d041b6ea145 (diff)
Make 'disklabel -w -d <disk>' work. i.e. write the default disklabel
onto disk. More elegant than "dd if=/dev/zero of= ..." to clear out an old disklabel. Think of it as treating the spoofed disklabel created by readdisklabel() like an automatically generated disktab entry. Makes some install scripts (macppc to start) easier.
-rw-r--r--sbin/disklabel/disklabel.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c
index 047a2ac9e25..3a93a1abeef 100644
--- a/sbin/disklabel/disklabel.c
+++ b/sbin/disklabel/disklabel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disklabel.c,v 1.108 2007/05/13 14:19:18 ray Exp $ */
+/* $OpenBSD: disklabel.c,v 1.109 2007/05/24 13:01:23 krw Exp $ */
/*
* Copyright (c) 1987, 1993
@@ -39,7 +39,7 @@ static const char copyright[] =
#endif /* not lint */
#ifndef lint
-static const char rcsid[] = "$OpenBSD: disklabel.c,v 1.108 2007/05/13 14:19:18 ray Exp $";
+static const char rcsid[] = "$OpenBSD: disklabel.c,v 1.109 2007/05/24 13:01:23 krw Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -306,9 +306,13 @@ main(int argc, char *argv[])
}
break;
case WRITE:
- if (argc < 2 || argc > 3)
+ if (dflag) {
+ if (readlabel(f) == NULL)
+ exit(1);
+ } else if (argc < 2 || argc > 3)
usage();
- makelabel(argv[1], argc == 3 ? argv[2] : NULL, &lab);
+ else
+ makelabel(argv[1], argc == 3 ? argv[2] : NULL, &lab);
lp = makebootarea(bootarea, &lab, f);
*lp = lab;
if (checklabel(lp) == 0)