diff options
author | marcel <marcel@FreeBSD.org> | 2004-11-13 05:13:33 +0000 |
---|---|---|
committer | marcel <marcel@FreeBSD.org> | 2004-11-13 05:13:33 +0000 |
commit | 571405ddd692d7a10ed1b454ad3905dec737db60 (patch) | |
tree | 13b84cbffe5362cd195b061115f2dcc369686294 /sbin | |
parent | 69615940956025a5e3885ba5f9b40982cfa43c7e (diff) | |
download | FreeBSD-src-571405ddd692d7a10ed1b454ad3905dec737db60.zip FreeBSD-src-571405ddd692d7a10ed1b454ad3905dec737db60.tar.gz |
Add an -f option (for force) to the create command. The -f option
allows the user to force the creation of a GPT even when there's a
MBR on the device. The MBR is simply wiped and any partitions
described by it are lost. Without the -f option one cannot create
a GPT when there's a MBR.
Diffstat (limited to 'sbin')
-rw-r--r-- | sbin/gpt/create.c | 20 | ||||
-rw-r--r-- | sbin/gpt/gpt.8 | 11 |
2 files changed, 25 insertions, 6 deletions
diff --git a/sbin/gpt/create.c b/sbin/gpt/create.c index 6591b93..54084c2 100644 --- a/sbin/gpt/create.c +++ b/sbin/gpt/create.c @@ -39,6 +39,7 @@ __FBSDID("$FreeBSD$"); #include "map.h" #include "gpt.h" +static int force; static int primary_only; static void @@ -46,7 +47,7 @@ usage_create(void) { fprintf(stderr, - "usage: %s [-p] device ...\n", getprogname()); + "usage: %s [-fp] device ...\n", getprogname()); exit(1); } @@ -70,9 +71,15 @@ create(int fd) warnx("%s: error: device already contains a GPT", device_name); return; } - if (map_find(MAP_TYPE_MBR) != NULL) { - warnx("%s: error: device contains a MBR", device_name); - return; + map = map_find(MAP_TYPE_MBR); + if (map != NULL) { + if (!force) { + warnx("%s: error: device contains a MBR", device_name); + return; + } + + /* Nuke the MBR in our internal map. */ + map->map_type = MAP_TYPE_UNUSED; } /* @@ -206,8 +213,11 @@ cmd_create(int argc, char *argv[]) { int ch, fd; - while ((ch = getopt(argc, argv, "p")) != -1) { + while ((ch = getopt(argc, argv, "fp")) != -1) { switch(ch) { + case 'f': + force = 1; + break; case 'p': primary_only = 1; break; diff --git a/sbin/gpt/gpt.8 b/sbin/gpt/gpt.8 index a96d694..8909812 100644 --- a/sbin/gpt/gpt.8 +++ b/sbin/gpt/gpt.8 @@ -24,7 +24,7 @@ .\" .\" $FreeBSD$ .\" -.Dd October 30, 2004 +.Dd November 12, 2004 .Os .Dt GPT 8 .Sh NAME @@ -138,12 +138,21 @@ as aliases for the most commonly used partition types. .It Xo .Nm .Ic create +.Op Fl f .Op Fl p .Ar device ... .Xc The .Ic create command allows the user to create a new (empty) GPT. +By default one can not create a GPT when the device contains a MBR, +however this can be overridden with the +.Fl f +option. +If the +.Fl f +option is specified, an existing MBR is destroyed and any partitions +described by the MBR are lost. .Pp The .Fl p |