summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormillert <millert@openbsd.org>1999-03-13 19:07:35 +0000
committermillert <millert@openbsd.org>1999-03-13 19:07:35 +0000
commit945ae268f45bc7edb53f60a3f7aa355ed03d1a06 (patch)
tree34e127a48b2ab816ca41eaf761dfdcbf7edb9197
parentmake ifa_refcnt a u_int; andrewb@demon.net (diff)
downloadwireguard-openbsd-945ae268f45bc7edb53f60a3f7aa355ed03d1a06.tar.xz
wireguard-openbsd-945ae268f45bc7edb53f60a3f7aa355ed03d1a06.zip
Add support for delete "*"
-rw-r--r--sbin/disklabel/disklabel.86
-rw-r--r--sbin/disklabel/editor.c23
2 files changed, 24 insertions, 5 deletions
diff --git a/sbin/disklabel/disklabel.8 b/sbin/disklabel/disklabel.8
index 614dc413f11..fada5ac6ae9 100644
--- a/sbin/disklabel/disklabel.8
+++ b/sbin/disklabel/disklabel.8
@@ -1,4 +1,4 @@
-.\" $OpenBSD: disklabel.8,v 1.24 1999/03/01 01:50:45 millert Exp $
+.\" $OpenBSD: disklabel.8,v 1.25 1999/03/13 19:07:35 millert Exp $
.\" $NetBSD: disklabel.8,v 1.9 1995/03/18 14:54:38 cgd Exp $
.\"
.\" Copyright (c) 1987, 1988, 1991, 1993
@@ -336,7 +336,9 @@ or
.Dq -
to change the size by a relative amount.
.It d Op part
-Delete an existing partition. If no partition is specified, the
+Delete an existing partition (or
+.Dq *
+to delete all partitions). If no partition is specified, the
user will be prompted for one. You may not delete the
.Dq c
partition.
diff --git a/sbin/disklabel/editor.c b/sbin/disklabel/editor.c
index 63f96946ad4..f61d81a0809 100644
--- a/sbin/disklabel/editor.c
+++ b/sbin/disklabel/editor.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: editor.c,v 1.46 1999/03/01 01:50:45 millert Exp $ */
+/* $OpenBSD: editor.c,v 1.47 1999/03/13 19:07:37 millert Exp $ */
/*
* Copyright (c) 1997-1999 Todd C. Miller <Todd.Miller@courtesan.com>
@@ -28,7 +28,7 @@
*/
#ifndef lint
-static char rcsid[] = "$OpenBSD: editor.c,v 1.46 1999/03/01 01:50:45 millert Exp $";
+static char rcsid[] = "$OpenBSD: editor.c,v 1.47 1999/03/13 19:07:37 millert Exp $";
#endif /* not lint */
#include <sys/types.h>
@@ -857,12 +857,29 @@ editor_delete(lp, freep, p)
if (p == NULL) {
p = getstring(lp, "partition to delete",
- "The letter of the partition to delete, a - p.", NULL);
+ "The letter of the partition to delete, a - p, or '*'.",
+ NULL);
}
if (p == NULL) {
fputs("Command aborted\n", stderr);
return;
}
+ if (p[0] == '*') {
+ for (c = 0; c < lp->d_npartitions; c++) {
+ if (c == 2)
+ continue;
+
+ /* Update free sector count. */
+ if (lp->d_partitions[c].p_fstype != FS_UNUSED &&
+ lp->d_partitions[c].p_fstype != FS_BOOT &&
+ lp->d_partitions[c].p_size != 0)
+ *freep += lp->d_partitions[c].p_size;
+
+ (void)memset(&lp->d_partitions[c], 0,
+ sizeof(lp->d_partitions[c]));
+ }
+ return;
+ }
c = p[0] - 'a';
if (c < 0 || c >= lp->d_npartitions)
fprintf(stderr, "Partition must be between 'a' and '%c'.\n",