From owner-svn-src-head@freebsd.org Mon Feb 13 17:44:09 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 19256CDDC49; Mon, 13 Feb 2017 17:44:09 +0000 (UTC) (envelope-from stevek@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id CE2DE134A; Mon, 13 Feb 2017 17:44:08 +0000 (UTC) (envelope-from stevek@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v1DHi7X9064010; Mon, 13 Feb 2017 17:44:07 GMT (envelope-from stevek@FreeBSD.org) Received: (from stevek@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v1DHi7NO064008; Mon, 13 Feb 2017 17:44:07 GMT (envelope-from stevek@FreeBSD.org) Message-Id: <201702131744.v1DHi7NO064008@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: stevek set sender to stevek@FreeBSD.org using -f From: "Stephen J. Kiernan" Date: Mon, 13 Feb 2017 17:44:07 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r313701 - in head: sbin/mdconfig sys/dev/md X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 13 Feb 2017 17:44:09 -0000 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%d\n", indent, @@ -1855,7 +1859,8 @@ g_md_dumpconf(struct sbuf *sb, const cha "read-only"); sbuf_printf(sb, "%s%s\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", indent); g_conf_printf_escaped(sb, "%s", mp->file); sbuf_printf(sb, "\n");