diff --git a/sbin/tunefs/Makefile b/sbin/tunefs/Makefile index a62d2f428e79..7f903b2ef21a 100644 --- a/sbin/tunefs/Makefile +++ b/sbin/tunefs/Makefile @@ -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 diff --git a/sbin/tunefs/tunefs.c b/sbin/tunefs/tunefs.c index b03cdde7b65c..93ce2c1f7aa3 100644 --- a/sbin/tunefs/tunefs.c +++ b/sbin/tunefs/tunefs.c @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -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);