diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1999-08-14 15:11:12 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1999-08-14 15:11:12 +0000 |
commit | a1075e6fff0ee8f214489e3ab9519114ce060e64 (patch) | |
tree | 55b693c07470b9eecba308c21c2ea6cf19c4b1a8 | |
parent | e331d413f5de083d20e54c5efd7074594eeef5be (diff) |
Add -c flag that uses DIOCRLDINFO to clear (and update) the in-core label.
-rw-r--r-- | sbin/disklabel/disklabel.8 | 20 | ||||
-rw-r--r-- | sbin/disklabel/disklabel.c | 39 |
2 files changed, 37 insertions, 22 deletions
diff --git a/sbin/disklabel/disklabel.8 b/sbin/disklabel/disklabel.8 index c4cb020c543..9fb449d0ec2 100644 --- a/sbin/disklabel/disklabel.8 +++ b/sbin/disklabel/disklabel.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: disklabel.8,v 1.31 1999/07/04 18:59:38 aaron Exp $ +.\" $OpenBSD: disklabel.8,v 1.32 1999/08/14 15:11:11 millert Exp $ .\" $NetBSD: disklabel.8,v 1.9 1995/03/18 14:54:38 cgd Exp $ .\" .\" Copyright (c) 1987, 1988, 1991, 1993 @@ -46,28 +46,28 @@ .Sh SYNOPSIS .Nm disklabel .Op Fl n -.Op Fl d Li \&| Fl r +.Op Fl cd Li \&| Fl r .Op Fl t .Op Fl v .Ar disk .Nm disklabel .Fl w .Op Fl n -.Op Fl d Li \&| Fl r +.Op Fl cd Li \&| Fl r .Op Fl v .Ar disk Ar disktype .Oo Ar packid Oc .Nm disklabel .Fl e .Op Fl n -.Op Fl d Li \&| Fl r +.Op Fl cd Li \&| Fl r .Op Fl v .Ar disk .Nm disklabel .Fl E .Op Fl f Ar tempfile .Op Fl n -.Op Fl d Li \&| Fl r +.Op Fl cd Li \&| Fl r .Op Fl v .Ar disk .Nm disklabel @@ -158,9 +158,15 @@ label. This ignores any existing .Ox partitions on the disk. Note that this option will only work for disks that are capable of reporting their geometry, such as SCSI, -IDE, and ESDI. Also note that the +IDE, and ESDI. +Additionally, the +.Fl c +flag may be used to clear the system's in-core copy of the label +and update it based on the on-disk label. Note that the .Fl d -flag may not be used in conjuction with the +and +.Fl c +flags may not be used in conjuction with the .Fl r flag. .Pp 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); |