From owner-svn-src-all@freebsd.org Wed Dec 14 21:30:45 2016 Return-Path: Delivered-To: svn-src-all@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 E66CDC805B0; Wed, 14 Dec 2016 21:30:45 +0000 (UTC) (envelope-from brooks@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 9C2591E18; Wed, 14 Dec 2016 21:30:45 +0000 (UTC) (envelope-from brooks@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id uBELUioa023856; Wed, 14 Dec 2016 21:30:44 GMT (envelope-from brooks@FreeBSD.org) Received: (from brooks@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id uBELUimH023854; Wed, 14 Dec 2016 21:30:44 GMT (envelope-from brooks@FreeBSD.org) Message-Id: <201612142130.uBELUimH023854@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: brooks set sender to brooks@FreeBSD.org using -f From: Brooks Davis Date: Wed, 14 Dec 2016 21:30:44 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r310095 - head/bin/df X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 Dec 2016 21:30:46 -0000 Author: brooks Date: Wed Dec 14 21:30:44 2016 New Revision: 310095 URL: https://svnweb.freebsd.org/changeset/base/310095 Log: Use nmount(2) rather than the obsolete mount(2). Reviewed by: cem MFC after: 1 week Sponsored by: DARPA, AFRL Differential Revision: https://reviews.freebsd.org/D8513 Modified: head/bin/df/Makefile head/bin/df/df.c Modified: head/bin/df/Makefile ============================================================================== --- head/bin/df/Makefile Wed Dec 14 21:30:35 2016 (r310094) +++ head/bin/df/Makefile Wed Dec 14 21:30:44 2016 (r310095) @@ -9,7 +9,9 @@ PROG= df SRCS= df.c vfslist.c CFLAGS+= -I${MOUNT} + CFLAGS+= -DMOUNT_CHAR_DEVS +SRCS+= getmntopts.c LIBADD= xo util Modified: head/bin/df/df.c ============================================================================== --- head/bin/df/df.c Wed Dec 14 21:30:35 2016 (r310094) +++ head/bin/df/df.c Wed Dec 14 21:30:44 2016 (r310095) @@ -56,6 +56,9 @@ __FBSDID("$FreeBSD$"); #include #include #include +#ifdef MOUNT_CHAR_DEVS +#include +#endif #include #include #include @@ -111,14 +114,21 @@ main(int argc, char *argv[]) struct statfs statfsbuf, totalbuf; struct maxwidths maxwidths; struct statfs *mntbuf; +#ifdef MOUNT_CHAR_DEVS + struct iovec *iov = NULL; +#endif const char *fstype; #ifdef MOUNT_CHAR_DEVS char *mntpath; + char errmsg[255] = {0}; #endif char *mntpt; const char **vfslist; int i, mntsize; int ch, rv; +#ifdef MOUNT_CHAR_DEVS + int iovlen = 0; +#endif fstype = "ufs"; (void)setlocale(LC_ALL, ""); @@ -251,9 +261,23 @@ main(int argc, char *argv[]) free(mntpath); continue; } - if (mount(fstype, mntpt, MNT_RDONLY|MNT_NOEXEC, - &mdev) != 0) { - xo_warn("%s", *argv); + if (iov != NULL) + free_iovec(&iov, &iovlen); + build_iovec_argf(&iov, &iovlen, "fstype", "%s", + fstype); + build_iovec_argf(&iov, &iovlen, "fspath", "%s", + mntpath); + build_iovec_argf(&iov, &iovlen, "from", "%s", + *argv); + build_iovec(&iov, &iovlen, "errmsg", errmsg, + sizeof(errmsg)); + if (nmount(iov, iovlen, + MNT_RDONLY|MNT_NOEXEC) < 0) { + if (errmsg[0]) + xo_warn("%s: %s", *argv, + errmsg); + else + xo_warn("%s", *argv); rv = 1; (void)rmdir(mntpt); free(mntpath);