eliminate static globals so that commands can be re-used.

This commit is contained in:
christos 2015-12-03 01:07:28 +00:00
parent 0bc066df68
commit da0a3b4c0b
18 changed files with 178 additions and 187 deletions

View File

@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $"); __FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
#endif #endif
#ifdef __RCSID #ifdef __RCSID
__RCSID("$NetBSD: add.c,v 1.37 2015/12/02 11:20:34 jnemeth Exp $"); __RCSID("$NetBSD: add.c,v 1.38 2015/12/03 01:07:28 christos Exp $");
#endif #endif
#include <sys/types.h> #include <sys/types.h>
@ -51,15 +51,11 @@ __RCSID("$NetBSD: add.c,v 1.37 2015/12/02 11:20:34 jnemeth Exp $");
#include "gpt.h" #include "gpt.h"
#include "gpt_private.h" #include "gpt_private.h"
static gpt_uuid_t type;
static off_t alignment, block, sectors, size;
static unsigned int entry;
static uint8_t *name;
static int cmd_add(gpt_t, int, char *[]); static int cmd_add(gpt_t, int, char *[]);
static const char *addhelp[] = { static const char *addhelp[] = {
"[-a alignment] [-b blocknr] [-i index] [-l label]", "[-a alignment] [-b blocknr] [-i index] [-l label]",
"[-s size] [-t type]", "[-s size] [-t type]",
}; };
struct gpt_cmd c_add = { struct gpt_cmd c_add = {
@ -84,7 +80,8 @@ ent_set(struct gpt_ent *ent, const map_t map, const gpt_uuid_t xtype,
} }
static int static int
add(gpt_t gpt) add(gpt_t gpt, off_t alignment, off_t block, off_t sectors, off_t size,
u_int entry, uint8_t *name, gpt_uuid_t type)
{ {
map_t map; map_t map;
struct gpt_hdr *hdr; struct gpt_hdr *hdr;
@ -157,6 +154,12 @@ static int
cmd_add(gpt_t gpt, int argc, char *argv[]) cmd_add(gpt_t gpt, int argc, char *argv[])
{ {
int ch; int ch;
off_t alignment = 0, block = 0, sectors = 0, size = 0;
unsigned int entry = 0;
uint8_t *name = NULL;
gpt_uuid_t type;
gpt_uuid_copy(type, gpt_uuid_nil);
while ((ch = getopt(argc, argv, GPT_AIS "b:l:t:")) != -1) { while ((ch = getopt(argc, argv, GPT_AIS "b:l:t:")) != -1) {
switch(ch) { switch(ch) {
@ -193,5 +196,5 @@ cmd_add(gpt_t gpt, int argc, char *argv[])
if ((sectors = gpt_check_ais(gpt, alignment, ~0, size)) == -1) if ((sectors = gpt_check_ais(gpt, alignment, ~0, size)) == -1)
return -1; return -1;
return add(gpt); return add(gpt, alignment, block, sectors, size, entry, name, type);
} }

View File

@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/show.c,v 1.14 2006/06/22 22:22:32 marcel Exp $"); __FBSDID("$FreeBSD: src/sbin/gpt/show.c,v 1.14 2006/06/22 22:22:32 marcel Exp $");
#endif #endif
#ifdef __RCSID #ifdef __RCSID
__RCSID("$NetBSD: backup.c,v 1.13 2015/12/02 12:36:53 christos Exp $"); __RCSID("$NetBSD: backup.c,v 1.14 2015/12/03 01:07:28 christos Exp $");
#endif #endif
#include <sys/bootblock.h> #include <sys/bootblock.h>
@ -51,10 +51,8 @@ __RCSID("$NetBSD: backup.c,v 1.13 2015/12/02 12:36:53 christos Exp $");
#include "gpt.h" #include "gpt.h"
#include "gpt_private.h" #include "gpt_private.h"
static const char *outfile = "/dev/stdout";
static const char *backuphelp[] = { static const char *backuphelp[] = {
"[-o outfile]", "[-o outfile]",
}; };
static int cmd_backup(gpt_t, int, char *[]); static int cmd_backup(gpt_t, int, char *[]);
@ -241,7 +239,7 @@ store_tbl(gpt_t gpt, const map_t m, prop_dictionary_t *type_dict)
} }
static int static int
backup(gpt_t gpt) backup(gpt_t gpt, const char *outfile)
{ {
map_t m; map_t m;
struct mbr *mbr; struct mbr *mbr;
@ -309,12 +307,14 @@ backup(gpt_t gpt)
propext = prop_dictionary_externalize(props); propext = prop_dictionary_externalize(props);
PROP_ERR(propext); PROP_ERR(propext);
prop_object_release(props); prop_object_release(props);
if ((fp = fopen(outfile, "w")) == NULL) { fp = strcmp(outfile, "-") == 0 ? stdout : fopen(outfile, "w");
if (fp == NULL) {
gpt_warn(gpt, "Can't open `%s'", outfile); gpt_warn(gpt, "Can't open `%s'", outfile);
return -1; return -1;
} }
fputs(propext, fp); fputs(propext, fp);
fclose(fp); if (fp != stdin)
fclose(fp);
free(propext); free(propext);
return 0; return 0;
} }
@ -323,6 +323,7 @@ static int
cmd_backup(gpt_t gpt, int argc, char *argv[]) cmd_backup(gpt_t gpt, int argc, char *argv[])
{ {
int ch; int ch;
const char *outfile = "-";
while ((ch = getopt(argc, argv, "o:")) != -1) { while ((ch = getopt(argc, argv, "o:")) != -1) {
switch(ch) { switch(ch) {
@ -336,5 +337,5 @@ cmd_backup(gpt_t gpt, int argc, char *argv[])
if (argc != optind) if (argc != optind)
return usage(); return usage();
return backup(gpt); return backup(gpt, outfile);
} }

View File

@ -1,4 +1,4 @@
/* $NetBSD: biosboot.c,v 1.20 2015/12/02 12:24:02 christos Exp $ */ /* $NetBSD: biosboot.c,v 1.21 2015/12/03 01:07:28 christos Exp $ */
/* /*
* Copyright (c) 2009 The NetBSD Foundation, Inc. * Copyright (c) 2009 The NetBSD Foundation, Inc.
@ -37,7 +37,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifdef __RCSID #ifdef __RCSID
__RCSID("$NetBSD: biosboot.c,v 1.20 2015/12/02 12:24:02 christos Exp $"); __RCSID("$NetBSD: biosboot.c,v 1.21 2015/12/03 01:07:28 christos Exp $");
#endif #endif
#include <sys/stat.h> #include <sys/stat.h>
@ -65,20 +65,13 @@ __RCSID("$NetBSD: biosboot.c,v 1.20 2015/12/02 12:24:02 christos Exp $");
#define DEFAULT_BOOTDIR "/usr/mdec" #define DEFAULT_BOOTDIR "/usr/mdec"
#define DEFAULT_BOOTCODE "gptmbr.bin" #define DEFAULT_BOOTCODE "gptmbr.bin"
static daddr_t start;
static uint64_t size;
static char *bootpath;
static unsigned int entry;
static uint8_t *label;
static int cmd_biosboot(gpt_t, int, char *[]); static int cmd_biosboot(gpt_t, int, char *[]);
static const char *biosboothelp[] = { static const char *biosboothelp[] = {
"[-c bootcode] [-i index] [-L label]", "[-c bootcode] [-i index] [-L label]",
#if notyet #if notyet
"[-a alignment] [-b blocknr] [-i index] [-l label]", "[-a alignment] [-b blocknr] [-i index] [-l label]",
"[-s size] [-t type]", "[-s size] [-t type]",
#endif #endif
}; };
@ -92,25 +85,26 @@ struct gpt_cmd c_biosboot = {
#define usage() gpt_usage(NULL, &c_biosboot) #define usage() gpt_usage(NULL, &c_biosboot)
static struct mbr* static struct mbr*
read_boot(gpt_t gpt) read_boot(gpt_t gpt, const char *bootpath)
{ {
int bfd, ret = 0; int bfd, ret = -1;
struct mbr *buf; struct mbr *buf;
struct stat st; struct stat st;
char *bp;
buf = NULL; buf = NULL;
bfd = -1; bfd = -1;
if (bootpath == NULL) if (bootpath == NULL)
bootpath = strdup(DEFAULT_BOOTDIR "/" DEFAULT_BOOTCODE); bp = strdup(DEFAULT_BOOTDIR "/" DEFAULT_BOOTCODE);
else if (*bootpath == '/') else if (*bootpath == '/')
bootpath = strdup(bootpath); bp = strdup(bootpath);
else { else {
if (asprintf(&bootpath, "%s/%s", DEFAULT_BOOTDIR, bootpath) < 0) if (asprintf(&bp, "%s/%s", DEFAULT_BOOTDIR, bootpath) < 0)
bootpath = NULL; bp = NULL;
} }
if (bootpath == NULL) { if (bp == NULL) {
gpt_warn(gpt, "Can't allocate memory for bootpath"); gpt_warn(gpt, "Can't allocate memory for bootpath");
goto fail; goto fail;
} }
@ -121,31 +115,31 @@ read_boot(gpt_t gpt)
} }
if ((bfd = open(bootpath, O_RDONLY)) < 0 || fstat(bfd, &st) == -1) { if ((bfd = open(bp, O_RDONLY)) < 0 || fstat(bfd, &st) == -1) {
gpt_warn(gpt, "Can't open `%s'", bootpath); gpt_warn(gpt, "Can't open `%s'", bp);
goto fail; goto fail;
} }
if (st.st_size != MBR_DSN_OFFSET) { if (st.st_size != MBR_DSN_OFFSET) {
gpt_warnx(gpt, "The bootcode in `%s' does not match the" gpt_warnx(gpt, "The bootcode in `%s' does not match the"
" expected size %u", bootpath, MBR_DSN_OFFSET); " expected size %u", bp, MBR_DSN_OFFSET);
goto fail; goto fail;
} }
if (read(bfd, buf, st.st_size) != st.st_size) { if (read(bfd, buf, st.st_size) != st.st_size) {
gpt_warn(gpt, "Error reading from `%s'", bootpath); gpt_warn(gpt, "Error reading from `%s'", bp);
goto fail; goto fail;
} }
ret++; ret = 0;
fail:
fail:
if (bfd != -1) if (bfd != -1)
close(bfd); close(bfd);
if (ret == 0) { if (ret == -1) {
free(buf); free(buf);
buf = NULL; buf = NULL;
} }
free(bp);
return buf; return buf;
} }
@ -169,7 +163,8 @@ set_bootable(gpt_t gpt, map_t map, map_t tbl, unsigned int i)
} }
static int static int
biosboot(gpt_t gpt) biosboot(gpt_t gpt, daddr_t start, uint64_t size, u_int entry, uint8_t *label,
const char *bootpath)
{ {
map_t mbrmap, m; map_t mbrmap, m;
struct mbr *mbr, *bootcode; struct mbr *mbr, *bootcode;
@ -194,7 +189,7 @@ biosboot(gpt_t gpt)
/* /*
* Update the boot code * Update the boot code
*/ */
if ((bootcode = read_boot(gpt)) == NULL) { if ((bootcode = read_boot(gpt, bootpath)) == NULL) {
gpt_warnx(gpt, "Error reading bootcode"); gpt_warnx(gpt, "Error reading bootcode");
return -1; return -1;
} }
@ -256,9 +251,13 @@ cmd_biosboot(gpt_t gpt, int argc, char *argv[])
#ifdef DIOCGWEDGEINFO #ifdef DIOCGWEDGEINFO
struct dkwedge_info dkw; struct dkwedge_info dkw;
#endif #endif
char *dev;
int ch; int ch;
gpt_t ngpt = gpt; gpt_t ngpt = gpt;
daddr_t start = 0;
uint64_t size = 0;
unsigned int entry = 0;
uint8_t *label = NULL;
const char *bootpath = NULL;
while ((ch = getopt(argc, argv, "c:i:L:")) != -1) { while ((ch = getopt(argc, argv, "c:i:L:")) != -1) {
switch(ch) { switch(ch) {
@ -282,25 +281,21 @@ cmd_biosboot(gpt_t gpt, int argc, char *argv[])
if (argc != optind) if (argc != optind)
return usage(); return usage();
start = 0;
size = 0;
#ifdef DIOCGWEDGEINFO #ifdef DIOCGWEDGEINFO
if ((gpt->sb.st_mode & S_IFMT) != S_IFREG && if ((gpt->sb.st_mode & S_IFMT) != S_IFREG &&
ioctl(gpt->fd, DIOCGWEDGEINFO, &dkw) != -1) { ioctl(gpt->fd, DIOCGWEDGEINFO, &dkw) != -1) {
if (entry > 0) if (entry > 0)
/* wedges and indexes are mutually exclusive */ /* wedges and indexes are mutually exclusive */
return usage(); return usage();
dev = dkw.dkw_parent;
start = dkw.dkw_offset; start = dkw.dkw_offset;
size = dkw.dkw_size; size = dkw.dkw_size;
ngpt = gpt_open(dev, gpt->flags, gpt->verbose, ngpt = gpt_open(dkw.dkw_parent, gpt->flags, gpt->verbose,
gpt->mediasz, gpt->secsz); gpt->mediasz, gpt->secsz);
if (ngpt == NULL) if (ngpt == NULL)
return -1; return -1;
} }
#endif #endif
biosboot(ngpt); biosboot(ngpt, start, size, entry, label, bootpath);
if (ngpt != gpt) if (ngpt != gpt)
gpt_close(ngpt); gpt_close(ngpt);

View File

@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/create.c,v 1.11 2005/08/31 01:47:19 marcel Exp $"); __FBSDID("$FreeBSD: src/sbin/gpt/create.c,v 1.11 2005/08/31 01:47:19 marcel Exp $");
#endif #endif
#ifdef __RCSID #ifdef __RCSID
__RCSID("$NetBSD: create.c,v 1.16 2015/12/01 19:25:24 christos Exp $"); __RCSID("$NetBSD: create.c,v 1.17 2015/12/03 01:07:28 christos Exp $");
#endif #endif
#include <sys/types.h> #include <sys/types.h>
@ -52,13 +52,10 @@ __RCSID("$NetBSD: create.c,v 1.16 2015/12/01 19:25:24 christos Exp $");
#include "gpt.h" #include "gpt.h"
#include "gpt_private.h" #include "gpt_private.h"
static int force;
static u_int parts;
static int primary_only;
static int cmd_create(gpt_t, int, char *[]); static int cmd_create(gpt_t, int, char *[]);
static const char *createhelp[] = { static const char *createhelp[] = {
"[-fP] [-p <partitions>]", "[-fP] [-p partitions]",
}; };
struct gpt_cmd c_create = { struct gpt_cmd c_create = {
@ -72,7 +69,7 @@ struct gpt_cmd c_create = {
static int static int
create(gpt_t gpt) create(gpt_t gpt, u_int parts, int force, int primary_only)
{ {
off_t last = gpt_last(gpt); off_t last = gpt_last(gpt);
map_t map; map_t map;
@ -128,8 +125,9 @@ static int
cmd_create(gpt_t gpt, int argc, char *argv[]) cmd_create(gpt_t gpt, int argc, char *argv[])
{ {
int ch; int ch;
int force = 0;
parts = 128; int primary_only = 0;
u_int parts = 128;
while ((ch = getopt(argc, argv, "fPp:")) != -1) { while ((ch = getopt(argc, argv, "fPp:")) != -1) {
switch(ch) { switch(ch) {
@ -150,5 +148,5 @@ cmd_create(gpt_t gpt, int argc, char *argv[])
if (argc != optind) if (argc != optind)
return usage(); return usage();
return create(gpt); return create(gpt, parts, force, primary_only);
} }

View File

@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/destroy.c,v 1.6 2005/08/31 01:47:19 marcel Exp $"); __FBSDID("$FreeBSD: src/sbin/gpt/destroy.c,v 1.6 2005/08/31 01:47:19 marcel Exp $");
#endif #endif
#ifdef __RCSID #ifdef __RCSID
__RCSID("$NetBSD: destroy.c,v 1.9 2015/12/01 16:32:19 christos Exp $"); __RCSID("$NetBSD: destroy.c,v 1.10 2015/12/03 01:07:28 christos Exp $");
#endif #endif
#include <sys/types.h> #include <sys/types.h>
@ -49,12 +49,10 @@ __RCSID("$NetBSD: destroy.c,v 1.9 2015/12/01 16:32:19 christos Exp $");
#include "gpt.h" #include "gpt.h"
#include "gpt_private.h" #include "gpt_private.h"
static int recoverable;
static int force;
static int cmd_destroy(gpt_t, int, char *[]); static int cmd_destroy(gpt_t, int, char *[]);
static const char *destroyhelp[] = { static const char *destroyhelp[] = {
"[-rf]", "[-rf]",
}; };
struct gpt_cmd c_destroy = { struct gpt_cmd c_destroy = {
@ -68,7 +66,7 @@ struct gpt_cmd c_destroy = {
static int static int
destroy(gpt_t gpt) destroy(gpt_t gpt, int force, int recoverable)
{ {
map_t pri_hdr, sec_hdr; map_t pri_hdr, sec_hdr;
@ -108,6 +106,8 @@ static int
cmd_destroy(gpt_t gpt, int argc, char *argv[]) cmd_destroy(gpt_t gpt, int argc, char *argv[])
{ {
int ch; int ch;
int recoverable = 0;
int force = 0;
while ((ch = getopt(argc, argv, "fr")) != -1) { while ((ch = getopt(argc, argv, "fr")) != -1) {
switch(ch) { switch(ch) {
@ -125,5 +125,5 @@ cmd_destroy(gpt_t gpt, int argc, char *argv[])
if (argc != optind) if (argc != optind)
return usage(); return usage();
return destroy(gpt); return destroy(gpt, force, recoverable);
} }

View File

@ -33,7 +33,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifdef __RCSID #ifdef __RCSID
__RCSID("$NetBSD: header.c,v 1.5 2015/12/01 16:32:19 christos Exp $"); __RCSID("$NetBSD: header.c,v 1.6 2015/12/03 01:07:28 christos Exp $");
#endif #endif
#include <sys/types.h> #include <sys/types.h>
@ -52,7 +52,7 @@ __RCSID("$NetBSD: header.c,v 1.5 2015/12/01 16:32:19 christos Exp $");
static int cmd_header(gpt_t, int, char *[]); static int cmd_header(gpt_t, int, char *[]);
static const char *headerhelp[] = { static const char *headerhelp[] = {
"", "",
}; };
struct gpt_cmd c_header = { struct gpt_cmd c_header = {

View File

@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/label.c,v 1.3 2006/10/04 18:20:25 marcel Exp $"); __FBSDID("$FreeBSD: src/sbin/gpt/label.c,v 1.3 2006/10/04 18:20:25 marcel Exp $");
#endif #endif
#ifdef __RCSID #ifdef __RCSID
__RCSID("$NetBSD: label.c,v 1.24 2015/12/02 04:07:11 christos Exp $"); __RCSID("$NetBSD: label.c,v 1.25 2015/12/03 01:07:28 christos Exp $");
#endif #endif
#include <sys/types.h> #include <sys/types.h>
@ -53,8 +53,9 @@ __RCSID("$NetBSD: label.c,v 1.24 2015/12/02 04:07:11 christos Exp $");
static int cmd_label(gpt_t, int, char *[]); static int cmd_label(gpt_t, int, char *[]);
static const char *labelhelp[] = { static const char *labelhelp[] = {
"-a <-l label | -f file>", "-a <-l label | -f file>",
"[-b blocknr] [-i index] [-L label] [-s sectors] [-t uuid] <-l label | -f file>", "[-b blocknr] [-i index] [-L label] [-s sectors] [-t uuid] "
"<-l label | -f file>",
}; };
struct gpt_cmd c_label = { struct gpt_cmd c_label = {

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.4 2015/12/01 16:33:55 christos Exp $ */ /* $NetBSD: main.c,v 1.5 2015/12/03 01:07:28 christos Exp $ */
/*- /*-
* Copyright (c) 2002 Marcel Moolenaar * Copyright (c) 2002 Marcel Moolenaar
@ -34,7 +34,7 @@
#include <sys/cdefs.h> #include <sys/cdefs.h>
#ifdef __RCSID #ifdef __RCSID
__RCSID("$NetBSD: main.c,v 1.4 2015/12/01 16:33:55 christos Exp $"); __RCSID("$NetBSD: main.c,v 1.5 2015/12/03 01:07:28 christos Exp $");
#endif #endif
#include <stdio.h> #include <stdio.h>
@ -100,15 +100,15 @@ usage(void)
{ {
const char *p = getprogname(); const char *p = getprogname();
const char *f = const char *f =
"[-nrqv] [-m <mediasize>] [-s <sectorsize>]"; "[-nrqv] [-m mediasize] [-s sectorsize]";
size_t i; size_t i;
if (strcmp(p, "gpt") == 0) if (strcmp(p, "gpt") == 0)
fprintf(stderr, fprintf(stderr,
"Usage: %s %s <command> [<args>] <device>\n", p, f); "Usage: %s %s command device\n", p, f);
else else
fprintf(stderr, fprintf(stderr,
"Usage: %s %s <device> <command> [<args>]\n", p, f); "Usage: %s %s device command\n", p, f);
fprintf(stderr, "Commands:\n"); fprintf(stderr, "Commands:\n");
for (i = 0; i < __arraycount(cmdsw); i++) for (i = 0; i < __arraycount(cmdsw); i++)
gpt_usage("\t", cmdsw[i]); gpt_usage("\t", cmdsw[i]);

View File

@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/migrate.c,v 1.16 2005/09/01 02:42:52 marcel Exp $"); __FBSDID("$FreeBSD: src/sbin/gpt/migrate.c,v 1.16 2005/09/01 02:42:52 marcel Exp $");
#endif #endif
#ifdef __RCSID #ifdef __RCSID
__RCSID("$NetBSD: migrate.c,v 1.25 2015/12/01 19:25:24 christos Exp $"); __RCSID("$NetBSD: migrate.c,v 1.26 2015/12/03 01:07:28 christos Exp $");
#endif #endif
#include <sys/types.h> #include <sys/types.h>
@ -76,14 +76,10 @@ __RCSID("$NetBSD: migrate.c,v 1.25 2015/12/01 19:25:24 christos Exp $");
#define FREEBSD_FS_VINUM 14 #define FREEBSD_FS_VINUM 14
#define FREEBSD_FS_ZFS 27 #define FREEBSD_FS_ZFS 27
static int force;
static int slice;
static u_int parts;
static int cmd_migrate(gpt_t, int, char *[]); static int cmd_migrate(gpt_t, int, char *[]);
static const char *migratehelp[] = { static const char *migratehelp[] = {
"[-fs] [-p <partitions>]", "[-fs] [-p partitions]",
}; };
struct gpt_cmd c_migrate = { struct gpt_cmd c_migrate = {
@ -260,7 +256,7 @@ migrate_netbsd_disklabel(gpt_t gpt, off_t start, struct gpt_ent *ent)
} }
static int static int
migrate(gpt_t gpt) migrate(gpt_t gpt, u_int parts, int force, int slice)
{ {
off_t last = gpt_last(gpt); off_t last = gpt_last(gpt);
map_t map; map_t map;
@ -348,8 +344,9 @@ static int
cmd_migrate(gpt_t gpt, int argc, char *argv[]) cmd_migrate(gpt_t gpt, int argc, char *argv[])
{ {
int ch; int ch;
int force = 0;
parts = 128; int slice = 0;
u_int parts = 128;
/* Get the migrate options */ /* Get the migrate options */
while ((ch = getopt(argc, argv, "fp:s")) != -1) { while ((ch = getopt(argc, argv, "fp:s")) != -1) {
@ -371,5 +368,5 @@ cmd_migrate(gpt_t gpt, int argc, char *argv[])
if (argc != optind) if (argc != optind)
return usage(); return usage();
return migrate(gpt); return migrate(gpt, parts, force, slice);
} }

View File

@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/recover.c,v 1.8 2005/08/31 01:47:19 marcel Exp $"); __FBSDID("$FreeBSD: src/sbin/gpt/recover.c,v 1.8 2005/08/31 01:47:19 marcel Exp $");
#endif #endif
#ifdef __RCSID #ifdef __RCSID
__RCSID("$NetBSD: recover.c,v 1.11 2015/12/02 20:42:07 christos Exp $"); __RCSID("$NetBSD: recover.c,v 1.12 2015/12/03 01:07:28 christos Exp $");
#endif #endif
#include <sys/types.h> #include <sys/types.h>
@ -49,12 +49,10 @@ __RCSID("$NetBSD: recover.c,v 1.11 2015/12/02 20:42:07 christos Exp $");
#include "gpt.h" #include "gpt.h"
#include "gpt_private.h" #include "gpt_private.h"
static int recoverable;
static int cmd_recover(gpt_t, int, char *[]); static int cmd_recover(gpt_t, int, char *[]);
static const char *recoverhelp[] = { static const char *recoverhelp[] = {
"", "",
}; };
struct gpt_cmd c_recover = { struct gpt_cmd c_recover = {
@ -158,7 +156,7 @@ recover_gpt_tbl(gpt_t gpt, int type, off_t start)
} }
static int static int
recover(gpt_t gpt) recover(gpt_t gpt, int recoverable)
{ {
uint64_t last; uint64_t last;
@ -215,6 +213,7 @@ static int
cmd_recover(gpt_t gpt, int argc, char *argv[]) cmd_recover(gpt_t gpt, int argc, char *argv[])
{ {
int ch; int ch;
int recoverable = 0;
while ((ch = getopt(argc, argv, "r")) != -1) { while ((ch = getopt(argc, argv, "r")) != -1) {
switch(ch) { switch(ch) {
@ -229,5 +228,5 @@ cmd_recover(gpt_t gpt, int argc, char *argv[])
if (argc != optind) if (argc != optind)
return usage(); return usage();
return recover(gpt); return recover(gpt, recoverable);
} }

View File

@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/remove.c,v 1.10 2006/10/04 18:20:25 marcel Exp $"); __FBSDID("$FreeBSD: src/sbin/gpt/remove.c,v 1.10 2006/10/04 18:20:25 marcel Exp $");
#endif #endif
#ifdef __RCSID #ifdef __RCSID
__RCSID("$NetBSD: remove.c,v 1.20 2015/12/01 19:25:24 christos Exp $"); __RCSID("$NetBSD: remove.c,v 1.21 2015/12/03 01:07:28 christos Exp $");
#endif #endif
#include <sys/types.h> #include <sys/types.h>
@ -52,8 +52,8 @@ __RCSID("$NetBSD: remove.c,v 1.20 2015/12/01 19:25:24 christos Exp $");
static int cmd_remove(gpt_t, int, char *[]); static int cmd_remove(gpt_t, int, char *[]);
static const char *removehelp[] = { static const char *removehelp[] = {
"-a", "-a",
"[-b blocknr] [-i index] [-L label] [-s sectors] [-t type]", "[-b blocknr] [-i index] [-L label] [-s sectors] [-t type]",
}; };
struct gpt_cmd c_remove = { struct gpt_cmd c_remove = {

View File

@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $"); __FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
#endif #endif
#ifdef __RCSID #ifdef __RCSID
__RCSID("$NetBSD: resize.c,v 1.18 2015/12/02 20:01:44 christos Exp $"); __RCSID("$NetBSD: resize.c,v 1.19 2015/12/03 01:07:28 christos Exp $");
#endif #endif
#include <sys/types.h> #include <sys/types.h>
@ -49,13 +49,10 @@ __RCSID("$NetBSD: resize.c,v 1.18 2015/12/02 20:01:44 christos Exp $");
#include "gpt.h" #include "gpt.h"
#include "gpt_private.h" #include "gpt_private.h"
static off_t alignment, sectors, size;
static unsigned int entry;
static int cmd_resize(gpt_t, int, char *[]); static int cmd_resize(gpt_t, int, char *[]);
static const char *resizehelp[] = { static const char *resizehelp[] = {
"-i index [-a alignment] [-s size]", "-i index [-a alignment] [-s size]",
}; };
struct gpt_cmd c_resize = { struct gpt_cmd c_resize = {
@ -68,7 +65,7 @@ struct gpt_cmd c_resize = {
#define usage() gpt_usage(NULL, &c_resize) #define usage() gpt_usage(NULL, &c_resize)
static int static int
resize(gpt_t gpt) resize(gpt_t gpt, u_int entry, off_t alignment, off_t sectors, off_t size)
{ {
map_t map; map_t map;
struct gpt_hdr *hdr; struct gpt_hdr *hdr;
@ -134,6 +131,8 @@ static int
cmd_resize(gpt_t gpt, int argc, char *argv[]) cmd_resize(gpt_t gpt, int argc, char *argv[])
{ {
int ch; int ch;
off_t alignment = 0, sectors, size = 0;
unsigned int entry = 0;
while ((ch = getopt(argc, argv, GPT_AIS)) != -1) { while ((ch = getopt(argc, argv, GPT_AIS)) != -1) {
if (gpt_add_ais(gpt, &alignment, &entry, &size, ch) == -1) if (gpt_add_ais(gpt, &alignment, &entry, &size, ch) == -1)
@ -146,5 +145,5 @@ cmd_resize(gpt_t gpt, int argc, char *argv[])
if ((sectors = gpt_check_ais(gpt, alignment, entry, size)) == -1) if ((sectors = gpt_check_ais(gpt, alignment, entry, size)) == -1)
return -1; return -1;
return resize(gpt); return resize(gpt, entry, alignment, sectors, size);
} }

View File

@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $"); __FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
#endif #endif
#ifdef __RCSID #ifdef __RCSID
__RCSID("$NetBSD: resizedisk.c,v 1.11 2015/12/02 20:09:54 christos Exp $"); __RCSID("$NetBSD: resizedisk.c,v 1.12 2015/12/03 01:07:28 christos Exp $");
#endif #endif
#include <sys/bootblock.h> #include <sys/bootblock.h>
@ -50,12 +50,11 @@ __RCSID("$NetBSD: resizedisk.c,v 1.11 2015/12/02 20:09:54 christos Exp $");
#include "gpt.h" #include "gpt.h"
#include "gpt_private.h" #include "gpt_private.h"
static off_t sector, size;
static int cmd_resizedisk(gpt_t, int, char *[]); static int cmd_resizedisk(gpt_t, int, char *[]);
static const char *resizediskhelp[] = { static const char *resizediskhelp[] = {
"[-s size]", "[-s size]",
}; };
struct gpt_cmd c_resizedisk = { struct gpt_cmd c_resizedisk = {
@ -79,7 +78,7 @@ struct gpt_cmd c_resizedisk = {
* - when shrinking, verify that table fits * - when shrinking, verify that table fits
*/ */
static int static int
resizedisk(gpt_t gpt) resizedisk(gpt_t gpt, off_t sector, off_t size)
{ {
map_t mbrmap; map_t mbrmap;
struct gpt_hdr *hdr; struct gpt_hdr *hdr;
@ -241,6 +240,7 @@ static int
cmd_resizedisk(gpt_t gpt, int argc, char *argv[]) cmd_resizedisk(gpt_t gpt, int argc, char *argv[])
{ {
int ch; int ch;
off_t sector, size = 0;
while ((ch = getopt(argc, argv, "s:")) != -1) { while ((ch = getopt(argc, argv, "s:")) != -1) {
switch(ch) { switch(ch) {
@ -259,5 +259,5 @@ cmd_resizedisk(gpt_t gpt, int argc, char *argv[])
if ((sector = gpt_check_ais(gpt, 0, ~0, size)) == -1) if ((sector = gpt_check_ais(gpt, 0, ~0, size)) == -1)
return -1; return -1;
return resizedisk(gpt); return resizedisk(gpt, sector, size);
} }

View File

@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/create.c,v 1.11 2005/08/31 01:47:19 marcel Exp $"); __FBSDID("$FreeBSD: src/sbin/gpt/create.c,v 1.11 2005/08/31 01:47:19 marcel Exp $");
#endif #endif
#ifdef __RCSID #ifdef __RCSID
__RCSID("$NetBSD: restore.c,v 1.14 2015/12/02 22:32:04 christos Exp $"); __RCSID("$NetBSD: restore.c,v 1.15 2015/12/03 01:07:28 christos Exp $");
#endif #endif
#include <sys/types.h> #include <sys/types.h>
@ -52,16 +52,12 @@ __RCSID("$NetBSD: restore.c,v 1.14 2015/12/02 22:32:04 christos Exp $");
#include "gpt.h" #include "gpt.h"
#include "gpt_private.h" #include "gpt_private.h"
static int force;
static int cmd_restore(gpt_t, int, char *[]); static int cmd_restore(gpt_t, int, char *[]);
static const char *restorehelp[] = { static const char *restorehelp[] = {
"[-F] [-i <infile>]", "[-F] [-i infile]",
}; };
static const char *infile = "/dev/stdin";
struct gpt_cmd c_restore = { struct gpt_cmd c_restore = {
"restore", "restore",
cmd_restore, cmd_restore,
@ -195,7 +191,7 @@ restore_ent(gpt_t gpt, prop_dictionary_t gpt_dict, void *secbuf, u_int gpt_size,
} }
static int static int
restore(gpt_t gpt) restore(gpt_t gpt, const char *infile, int force)
{ {
gpt_uuid_t gpt_guid, uuid; gpt_uuid_t gpt_guid, uuid;
off_t firstdata, last, lastdata, gpe_start, gpe_end; off_t firstdata, last, lastdata, gpe_start, gpe_end;
@ -233,7 +229,8 @@ restore(gpt_t gpt)
map->map_type = MAP_TYPE_UNUSED; map->map_type = MAP_TYPE_UNUSED;
} }
props = prop_dictionary_internalize_from_file(infile); props = prop_dictionary_internalize_from_file(
strcmp(infile, "-") == 0 ? "/dev/stdin" : infile);
if (props == NULL) { if (props == NULL) {
gpt_warnx(gpt, "Unable to read/parse backup file"); gpt_warnx(gpt, "Unable to read/parse backup file");
return -1; return -1;
@ -421,6 +418,8 @@ static int
cmd_restore(gpt_t gpt, int argc, char *argv[]) cmd_restore(gpt_t gpt, int argc, char *argv[])
{ {
int ch; int ch;
int force = 0;
const char *infile = "-";
while ((ch = getopt(argc, argv, "Fi:")) != -1) { while ((ch = getopt(argc, argv, "Fi:")) != -1) {
switch(ch) { switch(ch) {
@ -438,5 +437,5 @@ cmd_restore(gpt_t gpt, int argc, char *argv[])
if (argc != optind) if (argc != optind)
return usage(); return usage();
return restore(gpt); return restore(gpt, infile, force);
} }

View File

@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $"); __FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
#endif #endif
#ifdef __RCSID #ifdef __RCSID
__RCSID("$NetBSD: set.c,v 1.9 2015/12/01 19:25:24 christos Exp $"); __RCSID("$NetBSD: set.c,v 1.10 2015/12/03 01:07:28 christos Exp $");
#endif #endif
#include <sys/types.h> #include <sys/types.h>
@ -52,7 +52,7 @@ __RCSID("$NetBSD: set.c,v 1.9 2015/12/01 19:25:24 christos Exp $");
static int cmd_set(gpt_t, int, char *[]); static int cmd_set(gpt_t, int, char *[]);
static const char *sethelp[] = { static const char *sethelp[] = {
"-a attribute -i index", "-a attribute -i index",
}; };
struct gpt_cmd c_set = { struct gpt_cmd c_set = {

View File

@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/show.c,v 1.14 2006/06/22 22:22:32 marcel Exp $"); __FBSDID("$FreeBSD: src/sbin/gpt/show.c,v 1.14 2006/06/22 22:22:32 marcel Exp $");
#endif #endif
#ifdef __RCSID #ifdef __RCSID
__RCSID("$NetBSD: show.c,v 1.27 2015/12/02 04:07:11 christos Exp $"); __RCSID("$NetBSD: show.c,v 1.28 2015/12/03 01:07:28 christos Exp $");
#endif #endif
#include <sys/types.h> #include <sys/types.h>
@ -49,17 +49,16 @@ __RCSID("$NetBSD: show.c,v 1.27 2015/12/02 04:07:11 christos Exp $");
#include "gpt.h" #include "gpt.h"
#include "gpt_private.h" #include "gpt_private.h"
static int show_label = 0;
static int show_uuid = 0;
static int show_guid = 0;
static unsigned int entry = 0;
static int cmd_show(gpt_t, int, char *[]); static int cmd_show(gpt_t, int, char *[]);
static const char *showhelp[] = { static const char *showhelp[] = {
"[-glu] [-i index]", "[-glu] [-i index]",
}; };
#define SHOW_UUID 1
#define SHOW_GUID 2
#define SHOW_LABEL 4
struct gpt_cmd c_show = { struct gpt_cmd c_show = {
"show", "show",
cmd_show, cmd_show,
@ -70,13 +69,14 @@ struct gpt_cmd c_show = {
#define usage() gpt_usage(NULL, &c_show) #define usage() gpt_usage(NULL, &c_show)
static int static int
show(gpt_t gpt) show(gpt_t gpt, int show)
{ {
off_t start; off_t start;
map_t m, p; map_t m, p;
struct mbr *mbr; struct mbr *mbr;
struct gpt_ent *ent; struct gpt_ent *ent;
unsigned int i; unsigned int i;
char buf[128], *b = buf;
uint8_t utfbuf[__arraycount(ent->ent_name) * 3 + 1]; uint8_t utfbuf[__arraycount(ent->ent_name) * 3 + 1];
printf(" %*s", gpt->lbawidth, "start"); printf(" %*s", gpt->lbawidth, "start");
@ -134,23 +134,21 @@ show(gpt_t gpt)
case MAP_TYPE_GPT_PART: case MAP_TYPE_GPT_PART:
printf("GPT part "); printf("GPT part ");
ent = m->map_data; ent = m->map_data;
if (show_label) { if (show & SHOW_LABEL) {
utf16_to_utf8(ent->ent_name, utfbuf, utf16_to_utf8(ent->ent_name, utfbuf,
sizeof(utfbuf)); sizeof(utfbuf));
printf("- \"%s\"", (char *)utfbuf); b = (char *)buf;
} else if (show_guid) { } else if (show & SHOW_GUID) {
char buf[128]; gpt_uuid_snprintf( buf, sizeof(buf), "%d",
gpt_uuid_snprintf( ent->ent_guid);
buf, sizeof(buf), "%d", ent->ent_guid); } else if (show & SHOW_UUID) {
printf("- %s", buf); gpt_uuid_snprintf(buf, sizeof(buf),
"%d", ent->ent_type);
} else { } else {
char buf[128]; gpt_uuid_snprintf(buf, sizeof(buf), "%ls",
if (show_uuid || gpt_uuid_snprintf(buf, ent->ent_type);
sizeof(buf), "%ls", ent->ent_type) == -1)
gpt_uuid_snprintf(buf, sizeof(buf),
"%d", ent->ent_type);
printf("- %s", buf);
} }
printf("- %s", b);
break; break;
case MAP_TYPE_PMBR: case MAP_TYPE_PMBR:
printf("PMBR"); printf("PMBR");
@ -165,16 +163,31 @@ show(gpt_t gpt)
return 0; return 0;
} }
static void
show_num(gpt_t gpt, const char *prompt, uintmax_t num)
{
#ifdef HN_AUTOSCALE
char human_num[5];
if (humanize_number(human_num, 5, (int64_t)(num * gpt->secsz),
"", HN_AUTOSCALE, HN_NOSPACE|HN_B) < 0)
human_num[0] = '\0';
#endif
printf("%s: %ju", prompt, num);
#ifdef HN_AUTOSCALE
if (human_num[0] != '\0')
printf("(%s)", human_num);
#endif
printf("\n");
}
static int static int
show_one(gpt_t gpt) show_one(gpt_t gpt, unsigned int entry)
{ {
map_t m; map_t m;
struct gpt_ent *ent; struct gpt_ent *ent;
char s1[128], s2[128]; char s1[128], s2[128];
uint8_t utfbuf[__arraycount(ent->ent_name) * 3 + 1]; uint8_t utfbuf[__arraycount(ent->ent_name) * 3 + 1];
#ifdef HN_AUTOSCALE
char human_num[5];
#endif
for (m = map_first(gpt); m != NULL; m = m->map_next) for (m = map_first(gpt); m != NULL; m = m->map_next)
if (entry == m->map_index) if (entry == m->map_index)
@ -186,25 +199,8 @@ show_one(gpt_t gpt)
ent = m->map_data; ent = m->map_data;
printf("Details for index %d:\n", entry); printf("Details for index %d:\n", entry);
#ifdef HN_AUTOSCALE show_num(gpt, "Start", m->map_start);
if (humanize_number(human_num, 5, (int64_t)(m->map_start * gpt->secsz), show_num(gpt, "Size", m->map_size);
"", HN_AUTOSCALE, HN_NOSPACE|HN_B) < 0)
human_num[0] = '\0';
if (human_num[0] != '\0')
printf("Start: %llu (%s)\n", (long long)m->map_start,
human_num);
else
#endif
printf("Start: %llu\n", (long long)m->map_start);
#ifdef HN_AUTOSCALE
if (humanize_number(human_num, 5, (int64_t)(m->map_size * gpt->secsz),
"", HN_AUTOSCALE, HN_NOSPACE|HN_B) < 0)
human_num[0] = '\0';
if (human_num[0] != '\0')
printf("Size: %llu (%s)\n", (long long)m->map_size, human_num);
else
#endif
printf("Size: %llu\n", (long long)m->map_size);
gpt_uuid_snprintf(s1, sizeof(s1), "%s", ent->ent_type); gpt_uuid_snprintf(s1, sizeof(s1), "%s", ent->ent_type);
gpt_uuid_snprintf(s2, sizeof(s2), "%d", ent->ent_type); gpt_uuid_snprintf(s2, sizeof(s2), "%d", ent->ent_type);
@ -219,22 +215,22 @@ show_one(gpt_t gpt)
printf("Label: %s\n", (char *)utfbuf); printf("Label: %s\n", (char *)utfbuf);
printf("Attributes:\n"); printf("Attributes:\n");
if (ent->ent_attr == 0) if (ent->ent_attr == 0) {
printf(" None\n"); printf(" None\n");
else { return 0;
if (ent->ent_attr & GPT_ENT_ATTR_REQUIRED_PARTITION)
printf(" required for platform to function\n");
if (ent->ent_attr & GPT_ENT_ATTR_NO_BLOCK_IO_PROTOCOL)
printf(" UEFI won't recognize file system\n");
if (ent->ent_attr & GPT_ENT_ATTR_LEGACY_BIOS_BOOTABLE)
printf(" legacy BIOS boot partition\n");
if (ent->ent_attr & GPT_ENT_ATTR_BOOTME)
printf(" indicates a bootable partition\n");
if (ent->ent_attr & GPT_ENT_ATTR_BOOTONCE)
printf(" attempt to boot this partition only once\n");
if (ent->ent_attr & GPT_ENT_ATTR_BOOTFAILED)
printf(" partition that was marked bootonce but failed to boot\n");
} }
if (ent->ent_attr & GPT_ENT_ATTR_REQUIRED_PARTITION)
printf(" required for platform to function\n");
if (ent->ent_attr & GPT_ENT_ATTR_NO_BLOCK_IO_PROTOCOL)
printf(" UEFI won't recognize file system\n");
if (ent->ent_attr & GPT_ENT_ATTR_LEGACY_BIOS_BOOTABLE)
printf(" legacy BIOS boot partition\n");
if (ent->ent_attr & GPT_ENT_ATTR_BOOTME)
printf(" indicates a bootable partition\n");
if (ent->ent_attr & GPT_ENT_ATTR_BOOTONCE)
printf(" attempt to boot this partition only once\n");
if (ent->ent_attr & GPT_ENT_ATTR_BOOTFAILED)
printf(" partition was marked bootonce but failed to boot\n");
return 0; return 0;
} }
@ -242,21 +238,23 @@ static int
cmd_show(gpt_t gpt, int argc, char *argv[]) cmd_show(gpt_t gpt, int argc, char *argv[])
{ {
int ch; int ch;
int xshow = 0;
unsigned int entry = 0;
while ((ch = getopt(argc, argv, "gi:lu")) != -1) { while ((ch = getopt(argc, argv, "gi:lu")) != -1) {
switch(ch) { switch(ch) {
case 'g': case 'g':
show_guid = 1; xshow |= SHOW_GUID;
break; break;
case 'i': case 'i':
if (gpt_entry_get(&entry) == -1) if (gpt_entry_get(&entry) == -1)
return usage(); return usage();
break; break;
case 'l': case 'l':
show_label = 1; xshow |= SHOW_LABEL;
break; break;
case 'u': case 'u':
show_uuid = 1; xshow |= SHOW_UUID;
break; break;
default: default:
return usage(); return usage();
@ -266,5 +264,5 @@ cmd_show(gpt_t gpt, int argc, char *argv[])
if (argc != optind) if (argc != optind)
return usage(); return usage();
return entry > 0 ? show_one(gpt) : show(gpt); return entry > 0 ? show_one(gpt, entry) : show(gpt, xshow);
} }

View File

@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/remove.c,v 1.10 2006/10/04 18:20:25 marcel Exp $"); __FBSDID("$FreeBSD: src/sbin/gpt/remove.c,v 1.10 2006/10/04 18:20:25 marcel Exp $");
#endif #endif
#ifdef __RCSID #ifdef __RCSID
__RCSID("$NetBSD: type.c,v 1.11 2015/12/02 04:06:10 christos Exp $"); __RCSID("$NetBSD: type.c,v 1.12 2015/12/03 01:07:28 christos Exp $");
#endif #endif
#include <sys/types.h> #include <sys/types.h>
@ -52,8 +52,8 @@ __RCSID("$NetBSD: type.c,v 1.11 2015/12/02 04:06:10 christos Exp $");
static int cmd_type(gpt_t, int, char *[]); static int cmd_type(gpt_t, int, char *[]);
static const char *typehelp[] = { static const char *typehelp[] = {
"-a -T newtype", "-a -T newtype",
"[-b blocknr] [-i index] [-L label] [-s sectors] [-t type] -T newtype", "[-b blocknr] [-i index] [-L label] [-s sectors] [-t type] -T newtype",
}; };
struct gpt_cmd c_type = { struct gpt_cmd c_type = {
@ -80,6 +80,7 @@ cmd_type(gpt_t gpt, int argc, char *argv[])
struct gpt_find find; struct gpt_find find;
memset(&find, 0, sizeof(find)); memset(&find, 0, sizeof(find));
gpt_uuid_copy(newtype, gpt_uuid_nil);
find.msg = "type changed"; find.msg = "type changed";
/* Get the type options */ /* Get the type options */

View File

@ -33,7 +33,7 @@
__FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $"); __FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
#endif #endif
#ifdef __RCSID #ifdef __RCSID
__RCSID("$NetBSD: unset.c,v 1.9 2015/12/01 19:25:24 christos Exp $"); __RCSID("$NetBSD: unset.c,v 1.10 2015/12/03 01:07:28 christos Exp $");
#endif #endif
#include <sys/types.h> #include <sys/types.h>
@ -52,7 +52,7 @@ __RCSID("$NetBSD: unset.c,v 1.9 2015/12/01 19:25:24 christos Exp $");
static int cmd_unset(gpt_t, int, char *[]); static int cmd_unset(gpt_t, int, char *[]);
static const char *unsethelp[] = { static const char *unsethelp[] = {
"-a attribute -i index", "-a attribute -i index",
}; };
struct gpt_cmd c_unset = { struct gpt_cmd c_unset = {