Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F106067128
D10457.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
5 KB
Referenced Files
None
Subscribers
None
D10457.diff
View Options
Index: head/sbin/mdconfig/mdconfig.8
===================================================================
--- head/sbin/mdconfig/mdconfig.8
+++ head/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 @@
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
Index: head/sbin/mdconfig/mdconfig.c
===================================================================
--- head/sbin/mdconfig/mdconfig.c
+++ head/sbin/mdconfig/mdconfig.c
@@ -79,7 +79,7 @@
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 @@
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 @@
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 @@
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 @@
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))
Index: head/sys/dev/md/md.c
===================================================================
--- head/sys/dev/md/md.c
+++ head/sys/dev/md/md.c
@@ -226,6 +226,7 @@
/* MD_VNODE related fields */
struct vnode *vnode;
char file[PATH_MAX];
+ char label[PATH_MAX];
struct ucred *cred;
/* MD_SWAP related fields */
@@ -1645,6 +1646,11 @@
}
if (sc == NULL)
return (error);
+ if (mdio->md_label != NULL)
+ error = copyinstr(mdio->md_label, sc->label,
+ sizeof(sc->label), NULL);
+ if (error != 0)
+ goto err_after_new;
if (mdio->md_options & MD_AUTOUNIT)
mdio->md_unit = sc->unit;
sc->mediasize = mdio->md_mediasize;
@@ -1676,6 +1682,7 @@
error = mdcreate_null(sc, mdio, td);
break;
}
+err_after_new:
if (error != 0) {
mddestroy(sc, td);
return (error);
@@ -1721,6 +1728,11 @@
mdio->md_options = sc->flags;
mdio->md_mediasize = sc->mediasize;
mdio->md_sectorsize = sc->sectorsize;
+ error = 0;
+ if (mdio->md_label != NULL) {
+ error = copyout(sc->label, mdio->md_label,
+ strlen(sc->label) + 1);
+ }
if (sc->type == MD_VNODE ||
(sc->type == MD_PRELOAD && mdio->md_file != NULL))
error = copyout(sc->file, mdio->md_file,
@@ -1873,6 +1885,7 @@
if ((mp->type == MD_VNODE && mp->vnode != NULL) ||
(mp->type == MD_PRELOAD && mp->file[0] != '\0'))
sbuf_printf(sb, " file %s", mp->file);
+ sbuf_printf(sb, " label %s", mp->label);
} else {
sbuf_printf(sb, "%s<unit>%d</unit>\n", indent,
mp->unit);
@@ -1897,6 +1910,9 @@
g_conf_printf_escaped(sb, "%s", mp->file);
sbuf_printf(sb, "</file>\n");
}
+ sbuf_printf(sb, "%s<label>", indent);
+ g_conf_printf_escaped(sb, "%s", mp->label);
+ sbuf_printf(sb, "</label>\n");
}
}
}
Index: head/sys/sys/mdioctl.h
===================================================================
--- head/sys/sys/mdioctl.h
+++ head/sys/sys/mdioctl.h
@@ -49,7 +49,7 @@
* Ioctl definitions for memory disk pseudo-device.
*/
-#define MDNPAD 97
+#define MDNPAD 96
struct md_ioctl {
unsigned md_version; /* Structure layout version */
unsigned md_unit; /* unit number */
@@ -61,6 +61,7 @@
u_int64_t md_base; /* base address */
int md_fwheads; /* firmware heads */
int md_fwsectors; /* firmware sectors */
+ char *md_label; /* label of the device */
int md_pad[MDNPAD]; /* padding for future ideas */
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Wed, Dec 25, 8:20 PM (11 h, 10 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
15598481
Default Alt Text
D10457.diff (5 KB)
Attached To
Mode
D10457: Add ability to label md(4) devices
Attached
Detach File
Event Timeline
Log In to Comment