Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sbin/tunefs Refresh the superblock in memory if changing a m...
details: https://anonhg.NetBSD.org/src/rev/259c63794a9b
branches: trunk
changeset: 970979:259c63794a9b
user: christos <christos%NetBSD.org@localhost>
date: Thu Apr 09 14:44:38 2020 +0000
description:
Refresh the superblock in memory if changing a mounted partition.
diffstat:
sbin/tunefs/tunefs.c | 22 +++++++++++++++++++---
1 files changed, 19 insertions(+), 3 deletions(-)
diffs (70 lines):
diff -r 87b23c22609e -r 259c63794a9b sbin/tunefs/tunefs.c
--- a/sbin/tunefs/tunefs.c Thu Apr 09 14:39:10 2020 +0000
+++ b/sbin/tunefs/tunefs.c Thu Apr 09 14:44:38 2020 +0000
@@ -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 @@
#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 @@
* 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 @@
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 @@
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 @@
/* 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);
Home |
Main Index |
Thread Index |
Old Index