Module Name: src Committed By: christos Date: Thu Apr 9 14:44:38 UTC 2020
Modified Files: src/sbin/tunefs: tunefs.c Log Message: Refresh the superblock in memory if changing a mounted partition. To generate a diff of this commit: cvs rdiff -u -r1.50 -r1.51 src/sbin/tunefs/tunefs.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sbin/tunefs/tunefs.c diff -u src/sbin/tunefs/tunefs.c:1.50 src/sbin/tunefs/tunefs.c:1.51 --- src/sbin/tunefs/tunefs.c:1.50 Thu Apr 11 21:14:37 2019 +++ src/sbin/tunefs/tunefs.c Thu Apr 9 10:44:38 2020 @@ -1,4 +1,4 @@ -/* $NetBSD: tunefs.c,v 1.50 2019/04/12 01:14:37 pgoyette Exp $ */ +/* $NetBSD: tunefs.c,v 1.51 2020/04/09 14:44:38 christos Exp $ */ /* * Copyright (c) 1983, 1993 @@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1983, 19 #if 0 static char sccsid[] = "@(#)tunefs.c 8.3 (Berkeley) 5/3/95"; #else -__RCSID("$NetBSD: tunefs.c,v 1.50 2019/04/12 01:14:37 pgoyette Exp $"); +__RCSID("$NetBSD: tunefs.c,v 1.51 2020/04/09 14:44:38 christos Exp $"); #endif #endif /* not lint */ @@ -47,10 +47,12 @@ __RCSID("$NetBSD: tunefs.c,v 1.50 2019/0 * tunefs: change layout parameters to an existing file system. */ #include <sys/param.h> +#include <sys/statvfs.h> #include <ufs/ffs/fs.h> #include <ufs/ffs/ffs_extern.h> #include <ufs/ufs/ufs_wapbl.h> +#include <ufs/ufs/ufsmount.h> #include <ufs/ufs/quota2.h> #include <machine/bswap.h> @@ -103,9 +105,10 @@ main(int argc, char *argv[]) const char *special, *chg[2]; char device[MAXPATHLEN]; int maxbpg, minfree, optim, secsize; - int avgfilesize, avgfpdir; + int avgfilesize, avgfpdir, active; long long logfilesize; int secshift, fsbtodb; + struct statvfs sfs; Aflag = Fflag = Nflag = 0; maxbpg = minfree = optim = secsize = -1; @@ -203,6 +206,7 @@ main(int argc, char *argv[]) fi = openpartition(special, openflags, device, sizeof(device)); special = device; } + active = fstatvfs(fi, &sfs) != -1; if (fi == -1) err(1, "%s", special); getsb(&sblock, special); @@ -365,6 +369,18 @@ main(int argc, char *argv[]) /* write superblock to original coordinates (use old dev_bsize!) */ bwrite(sblockloc, buf.data, SBLOCKSIZE, special); + if (active) { + struct ufs_args args; + args.fspec = sfs.f_mntfromname; + if (mount(MOUNT_FFS, sfs.f_mntonname, sfs.f_flag | MNT_UPDATE, + &args, sizeof args) == -1) + warn("mount"); + else + printf("%s: mount of %s on %s updated\n", + getprogname(), sfs.f_mntfromname, sfs.f_mntonname); + } + + /* correct dev_bsize from possibly changed superblock data */ dev_bsize = sblock.fs_fsize / FFS_FSBTODB(&sblock, 1);