aboutsummaryrefslogtreecommitdiff
path: root/sbin
diff options
context:
space:
mode:
authorMaxim Sobolev <sobomax@FreeBSD.org>2017-08-28 15:54:07 +0000
committerMaxim Sobolev <sobomax@FreeBSD.org>2017-08-28 15:54:07 +0000
commitf7ca2bbe447a5224efb4078fdd1d29910f495b91 (patch)
treecb56738fbda43529121c81ce104b97435b0fe35d /sbin
parent505f20a67b7448f332704d03ab3ceb0b83a0bf87 (diff)
Notes
Diffstat (limited to 'sbin')
-rw-r--r--sbin/mdconfig/mdconfig.89
-rw-r--r--sbin/mdconfig/mdconfig.c26
2 files changed, 26 insertions, 9 deletions
diff --git a/sbin/mdconfig/mdconfig.8 b/sbin/mdconfig/mdconfig.8
index a437e40d58ec..cf05d8f43efb 100644
--- a/sbin/mdconfig/mdconfig.8
+++ b/sbin/mdconfig/mdconfig.8
@@ -37,7 +37,7 @@
.\"
.\" $FreeBSD$
.\"
-.Dd October 10, 2015
+.Dd August 28, 2017
.Dt MDCONFIG 8
.Os
.Sh NAME
@@ -55,6 +55,7 @@
.Op Fl u Ar unit
.Op Fl x Ar sectors/track
.Op Fl y Ar heads/cylinder
+.Op Fl L Ar label
.Nm
.Fl d
.Fl u Ar unit
@@ -189,6 +190,12 @@ and
options can be used to specify a synthetic geometry.
This is useful for constructing bootable images for later download to
other devices.
+.It Fl L Ar label
+Associate a label (arbitrary string) with the new memory disk.
+The label can then be inspected with
+.Bd -literal -offset indent
+.Nm Fl l v
+.Ed
.It Fl o Oo Cm no Oc Ns Ar option
Set or reset options.
.Bl -tag -width indent
diff --git a/sbin/mdconfig/mdconfig.c b/sbin/mdconfig/mdconfig.c
index 12c2a82c44d7..a76af2c7fdb0 100644
--- a/sbin/mdconfig/mdconfig.c
+++ b/sbin/mdconfig/mdconfig.c
@@ -79,7 +79,7 @@ usage(void)
fprintf(stderr,
"usage: mdconfig -a -t type [-n] [-o [no]option] ... [-f file]\n"
-" [-s size] [-S sectorsize] [-u unit]\n"
+" [-s size] [-S sectorsize] [-u unit] [-L label]\n"
" [-x sectors/track] [-y heads/cylinder]\n"
" mdconfig -d -u unit [-o [no]force]\n"
" mdconfig -r -u unit -s size [-o [no]force]\n"
@@ -102,15 +102,17 @@ main(int argc, char **argv)
bzero(&mdio, sizeof(mdio));
mdio.md_file = malloc(PATH_MAX);
- if (mdio.md_file == NULL)
+ mdio.md_label = malloc(PATH_MAX);
+ if (mdio.md_file == NULL || mdio.md_label == NULL)
err(1, "could not allocate memory");
vflag = 0;
bzero(mdio.md_file, PATH_MAX);
+ bzero(mdio.md_label, PATH_MAX);
if (argc == 1)
usage();
- while ((ch = getopt(argc, argv, "ab:df:lno:rs:S:t:u:vx:y:")) != -1) {
+ while ((ch = getopt(argc, argv, "ab:df:lno:rs:S:t:u:vx:y:L:")) != -1) {
switch (ch) {
case 'a':
if (action != UNSET && action != ATTACH)
@@ -243,6 +245,9 @@ main(int argc, char **argv)
case 'y':
mdio.md_fwheads = strtoul(optarg, &p, 0);
break;
+ case 'L':
+ strlcpy(mdio.md_label, optarg, PATH_MAX);
+ break;
default:
usage();
}
@@ -422,7 +427,8 @@ md_list(const char *units, int opt, const char *fflag)
struct gclass *gcl;
void *sq;
int retcode, ffound, ufound;
- char *type, *file, *length;
+ char *length;
+ const char *type, *file, *label;
type = file = length = NULL;
@@ -477,10 +483,14 @@ md_list(const char *units, int opt, const char *fflag)
printf("\t%s\t", type);
if (length != NULL)
md_prthumanval(length);
- if (file != NULL) {
- printf("\t%s", file);
- file = NULL;
- }
+ if (file == NULL)
+ file = "-";
+ printf("\t%s", file);
+ file = NULL;
+ label = geom_config_get(gc, "label");
+ if (label == NULL)
+ label = "";
+ printf("\t%s", label);
}
opt |= OPT_DONE;
if ((opt & OPT_LIST) && !(opt & OPT_VERBOSE))