diff options
author | des <des@FreeBSD.org> | 2005-04-24 20:08:29 +0000 |
---|---|---|
committer | des <des@FreeBSD.org> | 2005-04-24 20:08:29 +0000 |
commit | e669069b43c7e2eed5fff4775fd3c6c18283165d (patch) | |
tree | dbcede987d92edb2ff66ad74e2a604408a2dd44c /sbin/gpt/remove.c | |
parent | 00d3abec3bb9c46bd452d05af3fe8c1919d14992 (diff) | |
download | FreeBSD-src-e669069b43c7e2eed5fff4775fd3c6c18283165d.zip FreeBSD-src-e669069b43c7e2eed5fff4775fd3c6c18283165d.tar.gz |
- distinguish between the device name (what the user called it on the
command line) and the device path (what we passed to open()). Use
the former in diagnostics.
- when adding or removing partitions, print a single line to stdout for
each partition that was added or removed, indicating its name.
- add an -a option to 'gpt remove' which must be explicitly specified
to remove all partitions.
Approved by: marcel (in prinicple)
MFC after: 2 weeks
Diffstat (limited to 'sbin/gpt/remove.c')
-rw-r--r-- | sbin/gpt/remove.c | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/sbin/gpt/remove.c b/sbin/gpt/remove.c index 42e1128..9949d00 100644 --- a/sbin/gpt/remove.c +++ b/sbin/gpt/remove.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include "map.h" #include "gpt.h" +static int all; static uuid_t type; static off_t block, size; static unsigned int entry; @@ -48,8 +49,9 @@ usage_remove(void) { fprintf(stderr, - "usage: %s [-b lba] [-i index] [-s lba] [-t uuid] device\n", - getprogname()); + "usage: %s -a device\n" + " %s [-b lba] [-i index] [-s lba] [-t uuid] device\n", + getprogname(), getprogname()); exit(1); } @@ -130,6 +132,8 @@ rem(int fd) gpt_write(fd, lbt); gpt_write(fd, tpg); + printf("%sp%u removed\n", device_name, m->map_index); + removed++; } @@ -144,8 +148,13 @@ cmd_remove(int argc, char *argv[]) uint32_t status; /* Get the remove options */ - while ((ch = getopt(argc, argv, "b:i:s:t:")) != -1) { + while ((ch = getopt(argc, argv, "ab:i:s:t:")) != -1) { switch(ch) { + case 'a': + if (all > 0) + usage_remove(); + all = 1; + break; case 'b': if (block > 0) usage_remove(); @@ -194,6 +203,10 @@ cmd_remove(int argc, char *argv[]) } } + if (!all ^ + (block > 0 || entry > 0 || size > 0 || !uuid_is_nil(&type, NULL))) + usage_remove(); + if (argc == optind) usage_remove(); |