Implement the set and unset verbs. While here, have the manpage

catch up with various changes.
This commit is contained in:
Marcel Moolenaar 2008-06-18 01:46:32 +00:00
parent f6aa3fccce
commit 7a4a5cc0f4
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=179854
2 changed files with 84 additions and 11 deletions

View File

@ -1,5 +1,5 @@
/*- /*-
* Copyright (c) 2007 Marcel Moolenaar * Copyright (c) 2007, 2008 Marcel Moolenaar
* All rights reserved. * All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -108,6 +108,13 @@ struct g_command PUBSYM(class_commands)[] = {
G_OPT_SENTINEL }, G_OPT_SENTINEL },
"geom", NULL "geom", NULL
}, },
{ "set", 0, NULL, {
{ 'a', "attrib", NULL, G_TYPE_STRING },
{ 'i', index_param, NULL, G_TYPE_STRING },
{ 'f', "flags", flags, G_TYPE_STRING },
G_OPT_SENTINEL },
"geom", NULL
},
{ "show", 0, gpart_show, { { "show", 0, gpart_show, {
{ 'l', "show_label", NULL, G_TYPE_BOOL }, { 'l', "show_label", NULL, G_TYPE_BOOL },
{ 'r', "show_rawtype", NULL, G_TYPE_BOOL }, { 'r', "show_rawtype", NULL, G_TYPE_BOOL },
@ -115,6 +122,13 @@ struct g_command PUBSYM(class_commands)[] = {
NULL, "[-lr] [geom ...]" NULL, "[-lr] [geom ...]"
}, },
{ "undo", 0, NULL, G_NULL_OPTS, "geom", NULL }, { "undo", 0, NULL, G_NULL_OPTS, "geom", NULL },
{ "unset", 0, NULL, {
{ 'a', "attrib", NULL, G_TYPE_STRING },
{ 'i', index_param, NULL, G_TYPE_STRING },
{ 'f', "flags", flags, G_TYPE_STRING },
G_OPT_SENTINEL },
"geom", NULL
},
G_CMD_SENTINEL G_CMD_SENTINEL
}; };
@ -206,6 +220,19 @@ fmtsize(long double rawsz)
return (buf); return (buf);
} }
static const char *
fmtattrib(struct gprovider *pp)
{
static char buf[64];
const char *val;
val = find_provcfg(pp, "attrib");
if (val == NULL)
return ("");
snprintf(buf, sizeof(buf), " [%s] ", val);
return (buf);
}
static void static void
gpart_show_geom(struct ggeom *gp, const char *element) gpart_show_geom(struct ggeom *gp, const char *element)
{ {
@ -244,10 +271,10 @@ gpart_show_geom(struct ggeom *gp, const char *element)
wname, "", wname, "",
fmtsize((sector - first) * secsz)); fmtsize((sector - first) * secsz));
} }
printf(" %*llu %*llu %*d %s (%s)\n", printf(" %*llu %*llu %*d %s %s (%s)\n",
wblocks, sector, wblocks, end - sector, wblocks, sector, wblocks, end - sector,
wname, idx, wname, idx, find_provcfg(pp, element),
find_provcfg(pp, element), fmtsize(pp->lg_mediasize)); fmtattrib(pp), fmtsize(pp->lg_mediasize));
first = end; first = end;
} }
if (first <= last) { if (first <= last) {

View File

@ -24,7 +24,7 @@
.\" .\"
.\" $FreeBSD$ .\" $FreeBSD$
.\" .\"
.Dd Jun 6, 2008 .Dd Jun 17, 2008
.Dt GPART 8 .Dt GPART 8
.Os .Os
.Sh NAME .Sh NAME
@ -106,6 +106,13 @@ utility:
.Op Fl t Ar type .Op Fl t Ar type
.Op Fl f Ar flags .Op Fl f Ar flags
.Ar geom .Ar geom
.\" ==== SET ====
.Nm
.Cm set
.Fl a Ar attrib
.Fl i Ar index
.Op Fl f Ar flags
.Ar geom
.\" ==== SHOW ==== .\" ==== SHOW ====
.Nm .Nm
.Cm show .Cm show
@ -114,6 +121,13 @@ utility:
.Nm .Nm
.Cm undo .Cm undo
.Ar geom .Ar geom
.\" ==== UNSET ====
.Nm
.Cm unset
.Fl a Ar attrib
.Fl i Ar index
.Op Fl f Ar flags
.Ar geom
.\" .\"
.Sh DESCRIPTION .Sh DESCRIPTION
The The
@ -181,6 +195,14 @@ The partition is specified by the
.Fl i Ar index .Fl i Ar index
option. option.
The size of the file must be smaller than the size of the partition. The size of the file must be smaller than the size of the partition.
.Pp
Addition options include:
.Bl -tag -width ".Fl w Ar wwwwwww"
.It Fl f Ar flags
Additional operational flags.
See the section entitled "Operational flags" below for a discussion
about its use.
.El
.\" ==== COMMIT ==== .\" ==== COMMIT ====
.It Cm commit .It Cm commit
Commit any pending changes for geom Commit any pending changes for geom
@ -275,6 +297,17 @@ Additional operational flags.
See the section entitled "Operational flags" below for a discussion See the section entitled "Operational flags" below for a discussion
about its use. about its use.
.El .El
.\" ==== SET ====
.It Cm set
Set the named attribute on the partition entry.
.Pp
Addition options include:
.Bl -tag -width ".Fl w Ar wwwwwww"
.It Fl f Ar flags
Additional operational flags.
See the section entitled "Operational flags" below for a discussion
about its use.
.El
.\" ==== SHOW ==== .\" ==== SHOW ====
.It Cm show .It Cm show
Show the current partition information of the specified geoms Show the current partition information of the specified geoms
@ -285,7 +318,19 @@ Revert any pending changes.
This action is the opposite of the This action is the opposite of the
.Cm commit .Cm commit
action and can be used to undo any changes that have not been committed. action and can be used to undo any changes that have not been committed.
.\" ==== UNSET ====
.It Cm unset
Clear the named attribute on the partition entry.
.Pp
Addition options include:
.Bl -tag -width ".Fl w Ar wwwwwww"
.It Fl f Ar flags
Additional operational flags.
See the section entitled "Operational flags" below for a discussion
about its use.
.El .El
.El
.\"
.Sh PARTITION TYPES .Sh PARTITION TYPES
The The
.Nm .Nm
@ -312,6 +357,9 @@ This is a legacy partition type and should not be used for the APM
or GPT schemes. or GPT schemes.
The scheme-specific types are "!165" for MBR, "!FreeBSD" for APM, and The scheme-specific types are "!165" for MBR, "!FreeBSD" for APM, and
"!516e7cb4-6ecf-11d6-8ff8-00022d09712b" for GPT. "!516e7cb4-6ecf-11d6-8ff8-00022d09712b" for GPT.
.It freebsd-boot
A FreeBSD partition dedicated to bootstrap code.
The scheme-specific type is "!83bd6b9d-7f41-11dc-be0b-001560b84f0f" for GPT.
.It freebsd-swap .It freebsd-swap
A FreeBSD partition dedicated to swap space. A FreeBSD partition dedicated to swap space.
The scheme-specific types are "!FreeBSD-swap" for APM, and The scheme-specific types are "!FreeBSD-swap" for APM, and
@ -324,6 +372,10 @@ the scheme-specific types are "!FreeBSD-UFS" for APM, and
A FreeBSD partition that contains a Vinum volume. A FreeBSD partition that contains a Vinum volume.
The scheme-specific types are "!FreeBSD-Vinum" for APM, and The scheme-specific types are "!FreeBSD-Vinum" for APM, and
"!516e7cb8-6ecf-11d6-8ff8-00022d09712b" for GPT. "!516e7cb8-6ecf-11d6-8ff8-00022d09712b" for GPT.
.It freebsd-zfs
A FreeBSD partition that contains a ZFS volume.
The scheme-specific types are "!FreeBSD-ZFS" for APM, and
"!516e7cba-6ecf-11d6-8ff8-00022d09712b" for GPT.
.It mbr .It mbr
A partition that is sub-partitioned by a master boot record (MBR). A partition that is sub-partitioned by a master boot record (MBR).
This type is known as "!024dee41-33e7-11d3-9d69-0008c781f39f" by GPT. This type is known as "!024dee41-33e7-11d3-9d69-0008c781f39f" by GPT.
@ -360,11 +412,5 @@ The
.Nm .Nm
utility appeared in utility appeared in
.Fx 7.0 . .Fx 7.0 .
.Sh BUGS
The MBR partitioning scheme cannot yet be used to create a bootable
MBR.
.Pp
Support for the PC98 or Sun partitioning schemes is not yet present.
The BSD disklabel is also not supported yet.
.Sh AUTHORS .Sh AUTHORS
.An Marcel Moolenaar Aq marcel@FreeBSD.org .An Marcel Moolenaar Aq marcel@FreeBSD.org