From b103cd4113dc4c57443ada9c149156edd670dd53 Mon Sep 17 00:00:00 2001 From: Marcel Moolenaar Date: Sat, 30 Nov 2002 22:51:46 +0000 Subject: Allow aliases to be used when specifying partition types. The use of UUIDs can then be limited to those cases when an alias doesn't exist. This greatly increases the likelyhood that a sysadmin finishes the partitioning without intermittent mental breakdowns. Current aliases are "efi", "swap" and "ufs". While here, staticize global variables and expand the usage message. Approved by: re (blanket) --- sbin/gpt/add.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'sbin') diff --git a/sbin/gpt/add.c b/sbin/gpt/add.c index 3a8dc6f8a6f3..ee6454d427bb 100644 --- a/sbin/gpt/add.c +++ b/sbin/gpt/add.c @@ -41,15 +41,15 @@ #include "map.h" #include "gpt.h" -off_t block, size; -uuid_t type; +static uuid_t type; +static off_t block, size; static void usage_add(void) { fprintf(stderr, - "usage: %s [-bst] device\n", getprogname()); + "usage: %s [-b lba] [-s lba] [-t uuid] device\n", getprogname()); exit(1); } @@ -164,8 +164,17 @@ cmd_add(int argc, char *argv[]) usage_add(); uuid_from_string(optarg, &type, &status); if (status != uuid_s_ok) { - /* TODO: accept aliases. */ - usage_add(); + if (strcmp(optarg, "efi") == 0) { + uuid_t efi = GPT_ENT_TYPE_EFI; + type = efi; + } else if (strcmp(optarg, "swap") == 0) { + uuid_t sw = GPT_ENT_TYPE_FREEBSD_SWAP; + type = sw; + } else if (strcmp(optarg, "ufs") == 0) { + uuid_t ufs = GPT_ENT_TYPE_FREEBSD_UFS; + type = ufs; + } else + usage_add(); } break; default: -- cgit v1.3