aboutsummaryrefslogtreecommitdiff
path: root/sbin/tunefs/tunefs.c
diff options
context:
space:
mode:
authorKirk McKusick <mckusick@FreeBSD.org>2023-01-15 18:20:48 +0000
committerKirk McKusick <mckusick@FreeBSD.org>2023-01-15 18:21:31 +0000
commit906c312bbf7493ccbcce883936d67e5c66a9c3c2 (patch)
treef1d828c6169838298f1b0ccd16fe0558f01f2f07 /sbin/tunefs/tunefs.c
parent6468b6b23e08d9bd02c8cb74ec0ff389ed74c3bb (diff)
downloadsrc-906c312bbf7493ccbcce883936d67e5c66a9c3c2.tar.gz
src-906c312bbf7493ccbcce883936d67e5c66a9c3c2.zip
Document the mntopts(3) functions.
The mntopts(3) functions support operations associated with a mount point. The main purpose of this commit is to document the mntopts(3) functions that now appear in 18 utilities in the base system. See mntopts(3) for the documentation details. The getmntopts() function appeared in 4.4BSD. The build_iovec(), build_iovec_argf(), free_iovec(), checkpath(), and rmslashes() functions were added with nmount(8) in FreeBSD 5.0. The getmntpoint() and chkdoreload() functions are being added in this commit. These functions should be in a library but for historic reasons are in a file in the sources for the mount(8) program. Thus, to access them the following lines need to be added to the Makefile of the program wanting to use them: SRCS+= getmntopts.c MOUNT= ${SRCTOP}/sbin/mount CFLAGS+= -I${MOUNT} .PATH: ${MOUNT} Once these changes have been MFC'ed to 13 they may be made into a library. Reviewed by: kib, gbe MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D37907
Diffstat (limited to 'sbin/tunefs/tunefs.c')
-rw-r--r--sbin/tunefs/tunefs.c33
1 files changed, 5 insertions, 28 deletions
diff --git a/sbin/tunefs/tunefs.c b/sbin/tunefs/tunefs.c
index 11956f946ff5..2355a2a3e33b 100644
--- a/sbin/tunefs/tunefs.c
+++ b/sbin/tunefs/tunefs.c
@@ -91,18 +91,14 @@ main(int argc, char *argv[])
{
const char *avalue, *jvalue, *Jvalue, *Lvalue, *lvalue, *Nvalue, *nvalue;
const char *tvalue;
- const char *special, *on;
+ const char *special;
const char *name;
- int active;
+ char *diskname;
int Aflag, aflag, eflag, evalue, fflag, fvalue, jflag, Jflag, kflag;
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 statfs stfs;
- struct iovec *iov = NULL;
- char errmsg[255] = {0};
if (argc < 3)
usage();
@@ -110,7 +106,6 @@ main(int argc, char *argv[])
lflag = mflag = Nflag = nflag = oflag = pflag = sflag = tflag = 0;
avalue = jvalue = Jvalue = Lvalue = lvalue = Nvalue = nvalue = NULL;
evalue = fvalue = mvalue = ovalue = svalue = Svalue = 0;
- active = 0;
found_arg = 0; /* At least one arg is required. */
while ((ch = getopt(argc, argv, "Aa:e:f:j:J:k:L:l:m:N:n:o:ps:S:t:"))
!= -1)
@@ -309,7 +304,7 @@ main(int argc, char *argv[])
if (found_arg == 0 || argc != 1)
usage();
- on = special = argv[0];
+ special = argv[0];
if (ufs_disk_fillout(&disk, special) == -1)
goto err;
/*
@@ -319,13 +314,6 @@ main(int argc, char *argv[])
(sblock.fs_flags & (FS_UNCLEAN | FS_NEEDSFSCK)) != 0) &&
(found_arg > 1 || !pflag))
errx(1, "%s is not clean - run fsck.\n", special);
- if (disk.d_name != special) {
- if (statfs(special, &stfs) != 0)
- warn("Can't stat %s", special);
- if (strcmp(special, stfs.f_mntonname) == 0)
- active = 1;
- }
-
if (pflag) {
printfs();
exit(0);
@@ -570,20 +558,9 @@ main(int argc, char *argv[])
if (sbwrite(&disk, Aflag) == -1)
goto err;
+ diskname = strdup(disk.d_name);
ufs_disk_close(&disk);
- if (active) {
- 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");
- }
+ chkdoreload(getmntpoint(diskname), warnx);
exit(0);
err:
if (disk.d_error != NULL)