svn commit: r313701 - in head: sbin/mdconfig sys/dev/md
Stephen J. Kiernan
stevek at FreeBSD.org
Mon Feb 13 17:44:09 UTC 2017
Author: stevek
Date: Mon Feb 13 17:44:07 2017
New Revision: 313701
URL: https://svnweb.freebsd.org/changeset/base/313701
Log:
For MD_PRELOAD type md(4) devices, if there is a file name in the preloaded
meta-data, copy it into the softc structure.
When returning md(4) device details to the caller, include the file name in
any MD_PRELOAD type devices if it is set (first character is not NUL.)
In mdconfig, for "preload" type md(4) devices, if there is file config
available, print it in the file column of the output.
Reviewed by: brooks
Approved by: sjg (mentor)
MFC after: 1 month
Sponsored by: Juniper Networks, Inc.
Differential Revision: https://reviews.freebsd.org/D9529
Modified:
head/sbin/mdconfig/mdconfig.c
head/sys/dev/md/md.c
Modified: head/sbin/mdconfig/mdconfig.c
==============================================================================
--- head/sbin/mdconfig/mdconfig.c Mon Feb 13 16:11:37 2017 (r313700)
+++ head/sbin/mdconfig/mdconfig.c Mon Feb 13 17:44:07 2017 (r313701)
@@ -452,7 +452,8 @@ md_list(const char *units, int opt, cons
}
gc = &pp->lg_config;
type = geom_config_get(gc, "type");
- if (strcmp(type, "vnode") == 0) {
+ if (strcmp(type, "vnode") == 0 ||
+ strcmp(type, "preload") == 0) {
file = geom_config_get(gc, "file");
if (fflag != NULL &&
strcmp(fflag, file) != 0)
Modified: head/sys/dev/md/md.c
==============================================================================
--- head/sys/dev/md/md.c Mon Feb 13 16:11:37 2017 (r313700)
+++ head/sys/dev/md/md.c Mon Feb 13 17:44:07 2017 (r313701)
@@ -1689,7 +1689,8 @@ xmdctlioctl(struct cdev *dev, u_long cmd
mdio->md_options = sc->flags;
mdio->md_mediasize = sc->mediasize;
mdio->md_sectorsize = sc->sectorsize;
- if (sc->type == MD_VNODE)
+ if (sc->type == MD_VNODE ||
+ (sc->type == MD_PRELOAD && mdio->md_file != NULL))
error = copyout(sc->file, mdio->md_file,
strlen(sc->file) + 1);
return (error);
@@ -1733,6 +1734,8 @@ md_preloaded(u_char *image, size_t lengt
sc->pl_ptr = image;
sc->pl_len = length;
sc->start = mdstart_preload;
+ if (name != NULL)
+ strlcpy(sc->file, name, sizeof(sc->file));
#if defined(MD_ROOT) && !defined(ROOTDEVNAME)
if (sc->unit == 0)
rootdevnames[0] = MD_ROOT_FSTYPE ":/dev/md0";
@@ -1835,7 +1838,8 @@ g_md_dumpconf(struct sbuf *sb, const cha
sbuf_printf(sb, " fs %ju", (uintmax_t) mp->fwsectors);
sbuf_printf(sb, " l %ju", (uintmax_t) mp->mediasize);
sbuf_printf(sb, " t %s", type);
- if (mp->type == MD_VNODE && mp->vnode != NULL)
+ if ((mp->type == MD_VNODE && mp->vnode != NULL) ||
+ (mp->type == MD_PRELOAD && mp->file[0] != '\0'))
sbuf_printf(sb, " file %s", mp->file);
} else {
sbuf_printf(sb, "%s<unit>%d</unit>\n", indent,
@@ -1855,7 +1859,8 @@ g_md_dumpconf(struct sbuf *sb, const cha
"read-only");
sbuf_printf(sb, "%s<type>%s</type>\n", indent,
type);
- if (mp->type == MD_VNODE && mp->vnode != NULL) {
+ if ((mp->type == MD_VNODE && mp->vnode != NULL) ||
+ (mp->type == MD_PRELOAD && mp->file[0] != '\0'))
sbuf_printf(sb, "%s<file>", indent);
g_conf_printf_escaped(sb, "%s", mp->file);
sbuf_printf(sb, "</file>\n");
More information about the svn-src-all
mailing list