From owner-svn-src-stable-9@FreeBSD.ORG Sun Jan 13 00:58:03 2013 Return-Path: Delivered-To: svn-src-stable-9@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 87800EC; Sun, 13 Jan 2013 00:58:03 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) by mx1.freebsd.org (Postfix) with ESMTP id 479A0FF8; Sun, 13 Jan 2013 00:58:03 +0000 (UTC) Received: from svn.freebsd.org (svn.FreeBSD.org [8.8.178.70]) by svn.freebsd.org (8.14.5/8.14.5) with ESMTP id r0D0w36O036286; Sun, 13 Jan 2013 00:58:03 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.5/8.14.5/Submit) id r0D0w3sw036285; Sun, 13 Jan 2013 00:58:03 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201301130058.r0D0w3sw036285@svn.freebsd.org> From: Konstantin Belousov Date: Sun, 13 Jan 2013 00:58:03 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org Subject: svn commit: r245354 - stable/9/sbin/mount_nullfs X-SVN-Group: stable-9 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-9@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for only the 9-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 13 Jan 2013 00:58:03 -0000 Author: kib Date: Sun Jan 13 00:58:02 2013 New Revision: 245354 URL: http://svnweb.freebsd.org/changeset/base/245354 Log: MFC r245005: Allow to specify "cache" and "nocache" as an option for mount_nullfs(8). Modified: stable/9/sbin/mount_nullfs/mount_nullfs.c Directory Properties: stable/9/sbin/mount_nullfs/ (props changed) Modified: stable/9/sbin/mount_nullfs/mount_nullfs.c ============================================================================== --- stable/9/sbin/mount_nullfs/mount_nullfs.c Sun Jan 13 00:55:30 2013 (r245353) +++ stable/9/sbin/mount_nullfs/mount_nullfs.c Sun Jan 13 00:58:02 2013 (r245354) @@ -57,27 +57,35 @@ static const char rcsid[] = #include "mntopts.h" -struct mntopt mopts[] = { - MOPT_STDOPTS, - MOPT_END -}; - int subdir(const char *, const char *); static void usage(void) __dead2; int main(int argc, char *argv[]) { - struct iovec iov[6]; - int ch, mntflags; + struct iovec *iov; + char *p, *val; char source[MAXPATHLEN]; char target[MAXPATHLEN]; + char errmsg[255]; + int ch, mntflags, iovlen; + char nullfs[] = "nullfs"; + iov = NULL; + iovlen = 0; mntflags = 0; + errmsg[0] = '\0'; while ((ch = getopt(argc, argv, "o:")) != -1) switch(ch) { case 'o': - getmntopts(optarg, mopts, &mntflags, 0); + val = strdup(""); + p = strchr(optarg, '='); + if (p != NULL) { + free(val); + *p = '\0'; + val = p + 1; + } + build_iovec(&iov, &iovlen, optarg, val, (size_t)-1); break; case '?': default: @@ -97,21 +105,16 @@ main(int argc, char *argv[]) errx(EX_USAGE, "%s (%s) and %s are not distinct paths", argv[0], target, argv[1]); - iov[0].iov_base = strdup("fstype"); - iov[0].iov_len = sizeof("fstype"); - iov[1].iov_base = strdup("nullfs"); - iov[1].iov_len = strlen(iov[1].iov_base) + 1; - iov[2].iov_base = strdup("fspath"); - iov[2].iov_len = sizeof("fspath"); - iov[3].iov_base = source; - iov[3].iov_len = strlen(source) + 1; - iov[4].iov_base = strdup("target"); - iov[4].iov_len = sizeof("target"); - iov[5].iov_base = target; - iov[5].iov_len = strlen(target) + 1; - - if (nmount(iov, 6, mntflags)) - err(1, NULL); + build_iovec(&iov, &iovlen, "fstype", nullfs, (size_t)-1); + build_iovec(&iov, &iovlen, "fspath", source, (size_t)-1); + build_iovec(&iov, &iovlen, "target", target, (size_t)-1); + build_iovec(&iov, &iovlen, "errmsg", errmsg, sizeof(errmsg)); + if (nmount(iov, iovlen, mntflags) < 0) { + if (errmsg[0] != 0) + err(1, "%s: %s", source, errmsg); + else + err(1, "%s", source); + } exit(0); }