1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-27 11:55:06 +00:00

Convert tunefs use to nmount(2)

Reviewed by:	jhb, emaste
Sponsored by:	DARPA, AFRL
Differential Revision:	https://reviews.freebsd.org/D8822
This commit is contained in:
Brooks Davis 2016-12-22 00:35:12 +00:00
parent 716911af3e
commit 98acad147a
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=310382
2 changed files with 19 additions and 5 deletions

View File

@ -3,9 +3,14 @@
PACKAGE=runtime
PROG= tunefs
SRCS= tunefs.c getmntopts.c
LIBADD= ufs
MAN= tunefs.8
MOUNT= ${SRCTOP}/sbin/mount
CFLAGS+= -I${MOUNT}
.PATH: ${MOUNT}
WARNS= 3
.include <bsd.prog.mk>

View File

@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$");
#include <fcntl.h>
#include <fstab.h>
#include <libufs.h>
#include <mntopts.h>
#include <paths.h>
#include <stdio.h>
#include <stdlib.h>
@ -93,9 +94,11 @@ main(int argc, char *argv[])
int kvalue, Lflag, lflag, mflag, mvalue, Nflag, nflag, oflag, ovalue;
int pflag, sflag, svalue, Svalue, tflag;
int ch, found_arg, i;
int iovlen = 0;
const char *chg[2];
struct ufs_args args;
struct statfs stfs;
struct iovec *iov = NULL;
char errmsg[255] = {0};
if (argc < 3)
usage();
@ -556,10 +559,16 @@ main(int argc, char *argv[])
goto err;
ufs_disk_close(&disk);
if (active) {
bzero(&args, sizeof(args));
if (mount("ufs", on,
stfs.f_flags | MNT_UPDATE | MNT_RELOAD, &args) < 0)
err(9, "%s: reload", special);
build_iovec_argf(&iov, &iovlen, "fstype", "ufs");
build_iovec_argf(&iov, &iovlen, "fspath", "%s", on);
build_iovec(&iov, &iovlen, "errmsg", errmsg, sizeof(errmsg));
if (nmount(iov, iovlen,
stfs.f_flags | MNT_UPDATE | MNT_RELOAD) < 0) {
if (errmsg[0])
err(9, "%s: reload: %s", special, errmsg);
else
err(9, "%s: reload", special);
}
warnx("file system reloaded");
}
exit(0);