Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 14 Dec 2016 21:30:44 +0000 (UTC)
From:      Brooks Davis <brooks@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r310095 - head/bin/df
Message-ID:  <201612142130.uBELUimH023854@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
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 <err.h>
 #include <libutil.h>
 #include <locale.h>
+#ifdef MOUNT_CHAR_DEVS
+#include <mntopts.h>
+#endif
 #include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -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);



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201612142130.uBELUimH023854>