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
This commit is contained in:
parent
b32720888a
commit
facc3cb0ff
@ -9,7 +9,9 @@ PROG= df
|
|||||||
SRCS= df.c vfslist.c
|
SRCS= df.c vfslist.c
|
||||||
|
|
||||||
CFLAGS+= -I${MOUNT}
|
CFLAGS+= -I${MOUNT}
|
||||||
|
|
||||||
CFLAGS+= -DMOUNT_CHAR_DEVS
|
CFLAGS+= -DMOUNT_CHAR_DEVS
|
||||||
|
SRCS+= getmntopts.c
|
||||||
|
|
||||||
LIBADD= xo util
|
LIBADD= xo util
|
||||||
|
|
||||||
|
30
bin/df/df.c
30
bin/df/df.c
@ -56,6 +56,9 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <err.h>
|
#include <err.h>
|
||||||
#include <libutil.h>
|
#include <libutil.h>
|
||||||
#include <locale.h>
|
#include <locale.h>
|
||||||
|
#ifdef MOUNT_CHAR_DEVS
|
||||||
|
#include <mntopts.h>
|
||||||
|
#endif
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
@ -111,14 +114,21 @@ main(int argc, char *argv[])
|
|||||||
struct statfs statfsbuf, totalbuf;
|
struct statfs statfsbuf, totalbuf;
|
||||||
struct maxwidths maxwidths;
|
struct maxwidths maxwidths;
|
||||||
struct statfs *mntbuf;
|
struct statfs *mntbuf;
|
||||||
|
#ifdef MOUNT_CHAR_DEVS
|
||||||
|
struct iovec *iov = NULL;
|
||||||
|
#endif
|
||||||
const char *fstype;
|
const char *fstype;
|
||||||
#ifdef MOUNT_CHAR_DEVS
|
#ifdef MOUNT_CHAR_DEVS
|
||||||
char *mntpath;
|
char *mntpath;
|
||||||
|
char errmsg[255] = {0};
|
||||||
#endif
|
#endif
|
||||||
char *mntpt;
|
char *mntpt;
|
||||||
const char **vfslist;
|
const char **vfslist;
|
||||||
int i, mntsize;
|
int i, mntsize;
|
||||||
int ch, rv;
|
int ch, rv;
|
||||||
|
#ifdef MOUNT_CHAR_DEVS
|
||||||
|
int iovlen = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
fstype = "ufs";
|
fstype = "ufs";
|
||||||
(void)setlocale(LC_ALL, "");
|
(void)setlocale(LC_ALL, "");
|
||||||
@ -251,9 +261,23 @@ main(int argc, char *argv[])
|
|||||||
free(mntpath);
|
free(mntpath);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (mount(fstype, mntpt, MNT_RDONLY|MNT_NOEXEC,
|
if (iov != NULL)
|
||||||
&mdev) != 0) {
|
free_iovec(&iov, &iovlen);
|
||||||
xo_warn("%s", *argv);
|
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;
|
rv = 1;
|
||||||
(void)rmdir(mntpt);
|
(void)rmdir(mntpt);
|
||||||
free(mntpath);
|
free(mntpath);
|
||||||
|
Loading…
Reference in New Issue
Block a user