summaryrefslogtreecommitdiff
path: root/sbin/disklabel/disklabel.c
diff options
context:
space:
mode:
authorTodd C. Miller <millert@cvs.openbsd.org>1999-08-14 15:11:12 +0000
committerTodd C. Miller <millert@cvs.openbsd.org>1999-08-14 15:11:12 +0000
commita1075e6fff0ee8f214489e3ab9519114ce060e64 (patch)
tree55b693c07470b9eecba308c21c2ea6cf19c4b1a8 /sbin/disklabel/disklabel.c
parente331d413f5de083d20e54c5efd7074594eeef5be (diff)
Add -c flag that uses DIOCRLDINFO to clear (and update) the in-core label.
Diffstat (limited to 'sbin/disklabel/disklabel.c')
-rw-r--r--sbin/disklabel/disklabel.c39
1 files changed, 24 insertions, 15 deletions
diff --git a/sbin/disklabel/disklabel.c b/sbin/disklabel/disklabel.c
index cc4f138d8cb..3debf2fcf65 100644
--- a/sbin/disklabel/disklabel.c
+++ b/sbin/disklabel/disklabel.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: disklabel.c,v 1.66 1999/08/13 02:06:58 deraadt Exp $ */
+/* $OpenBSD: disklabel.c,v 1.67 1999/08/14 15:11:11 millert Exp $ */
/* $NetBSD: disklabel.c,v 1.30 1996/03/14 19:49:24 ghudson Exp $ */
/*
@@ -44,7 +44,7 @@ static char copyright[] =
#endif /* not lint */
#ifndef lint
-static char rcsid[] = "$OpenBSD: disklabel.c,v 1.66 1999/08/13 02:06:58 deraadt Exp $";
+static char rcsid[] = "$OpenBSD: disklabel.c,v 1.67 1999/08/14 15:11:11 millert Exp $";
#endif /* not lint */
#include <sys/param.h>
@@ -107,6 +107,7 @@ enum {
UNSPEC, EDIT, EDITOR, READ, RESTORE, SETWRITEABLE, WRITE, WRITEBOOT
} op = UNSPEC;
+int cflag;
int dflag;
int rflag;
int tflag;
@@ -150,7 +151,7 @@ main(argc, argv)
struct disklabel *lp;
FILE *t;
- while ((ch = getopt(argc, argv, "BEFf:NRWb:denrs:tvw")) != -1)
+ while ((ch = getopt(argc, argv, "BEFf:NRWb:cdenrs:tvw")) != -1)
switch (ch) {
#if NUMBOOT > 0
case 'B':
@@ -182,6 +183,9 @@ main(argc, argv)
writeable = 1;
op = SETWRITEABLE;
break;
+ case 'c':
+ ++cflag;
+ break;
case 'd':
++dflag;
break;
@@ -236,7 +240,8 @@ main(argc, argv)
op = READ;
#endif
- if (argc < 1 || (rflag && dflag) || (fstabfile && op != EDITOR))
+ if (argc < 1 || (rflag && cflag + dflag > 0) ||
+ (fstabfile && op != EDITOR))
usage();
dkname = argv[0];
@@ -730,14 +735,18 @@ readlabel(f)
}
warnx(msg);
return(NULL);
- } else if (dflag) {
- lp = &lab;
- if (ioctl(f, DIOCGPDINFO, lp) < 0)
- err(4, "ioctl DIOCGPDINFO");
} else {
- lp = &lab;
- if (ioctl(f, DIOCGDINFO, lp) < 0)
- err(4, "ioctl DIOCGDINFO");
+ if (cflag && ioctl(f, DIOCRLDINFO) < 0)
+ err(4, "ioctl DIOCRLDINFO");
+ if (dflag) {
+ lp = &lab;
+ if (ioctl(f, DIOCGPDINFO, lp) < 0)
+ err(4, "ioctl DIOCGPDINFO");
+ } else {
+ lp = &lab;
+ if (ioctl(f, DIOCGDINFO, lp) < 0)
+ err(4, "ioctl DIOCGDINFO");
+ }
}
return (lp);
}
@@ -1748,14 +1757,14 @@ usage()
fprintf(stderr, "usage:\n");
fprintf(stderr,
- " disklabel [-nv] [-r|-d] [-t] disk%s (read)\n",
+ " disklabel [-nv] [-r|-cd] [-t] disk%s (read)\n",
blank);
fprintf(stderr,
- " disklabel [-nv] [-r|-d] -e disk%s (edit)\n",
+ " disklabel [-nv] [-r|-cd] -e disk%s (edit)\n",
blank);
fprintf(stderr,
- " disklabel [-nv] [-r|-d] [-f temp] -E disk%.*s (simple editor)\n",
- strlen(blank) - 4, blank);
+ " disklabel [-nv] [-r|-cd] [-f temp] -E disk%.*s (simple editor)\n",
+ strlen(blank) - 5, blank);
fprintf(stderr,
" disklabel [-nv] [-r]%s -R disk proto (restore)\n",
boot);