summaryrefslogtreecommitdiffstats
path: root/sbin/fsck/fsutil.c
diff options
context:
space:
mode:
authormckusick <mckusick@FreeBSD.org>2001-04-25 07:18:22 +0000
committermckusick <mckusick@FreeBSD.org>2001-04-25 07:18:22 +0000
commit658667dbfa808d24e7cd28a50dd1031de174ffab (patch)
tree8b7cc28748b2821869d1bc86f404e697d860b70e /sbin/fsck/fsutil.c
parentcdc83afc7f1e444c4646840f48592b7ff524fbea (diff)
downloadFreeBSD-src-658667dbfa808d24e7cd28a50dd1031de174ffab.zip
FreeBSD-src-658667dbfa808d24e7cd28a50dd1031de174ffab.tar.gz
Add support for running foreground (-F) and background (-B) checks.
Traditionally, fsck is invoked before the filesystems are mounted and all checks are done to completion at that time. If background checking is available, fsck is invoked twice. It is first invoked at the traditional time, before the filesystems are mounted, with the -F flag to do checking on all the filesystems that cannot do background checking. It is then invoked a second time, after the system has completed going multiuser, with the -B flag to do checking on all the filesystems that can do background checking. Unlike the foreground checking, the background checking is started asynchonously so that other system activity can proceed even on the filesystems that are being checked. At the moment, only the fast filesystem supports background checking. To be able to do background checking, a filesystem must have been running with soft updates, not have been marked as needing a foreground check, and be mounted and writable when the background check is to be done (i.e., not listed as `noauto' in /etc/fstab). These changes are the final piece needed to support background filesystem checking. They will not have any effect until you update your /etc/rc to invoke fsck in its new mode of operation. I am still playing around with exactly what those changes should be and should be committing them later this week.
Diffstat (limited to 'sbin/fsck/fsutil.c')
-rw-r--r--sbin/fsck/fsutil.c45
1 files changed, 44 insertions, 1 deletions
diff --git a/sbin/fsck/fsutil.c b/sbin/fsck/fsutil.c
index f83c936..a7a89aa 100644
--- a/sbin/fsck/fsutil.c
+++ b/sbin/fsck/fsutil.c
@@ -51,9 +51,11 @@ __RCSID("$NetBSD: fsutil.c,v 1.7 1998/07/30 17:41:03 thorpej Exp $");
#include <errno.h>
#include <fstab.h>
#include <err.h>
+#include <paths.h>
-#include <sys/types.h>
+#include <sys/param.h>
#include <sys/stat.h>
+#include <sys/mount.h>
#include "fsutil.h"
@@ -263,6 +265,47 @@ devcheck(origname)
return (origname);
}
+/*
+ * Get the mount point information for name.
+ */
+struct statfs *
+getmntpt(name)
+ const char *name;
+{
+ struct stat devstat, mntdevstat;
+ char device[sizeof(_PATH_DEV) - 1 + MNAMELEN];
+ char *devname;
+ struct statfs *mntbuf, *statfsp;
+ int i, mntsize, isdev;
+
+ if (stat(name, &devstat) != 0)
+ return (NULL);
+ if (S_ISCHR(devstat.st_mode) || S_ISBLK(devstat.st_mode))
+ isdev = 1;
+ else
+ isdev = 0;
+ mntsize = getmntinfo(&mntbuf, MNT_NOWAIT);
+ for (i = 0; i < mntsize; i++) {
+ statfsp = &mntbuf[i];
+ devname = statfsp->f_mntfromname;
+ if (*devname != '/') {
+ strcpy(device, _PATH_DEV);
+ strcat(device, devname);
+ strcpy(statfsp->f_mntfromname, device);
+ }
+ if (isdev == 0) {
+ if (strcmp(name, statfsp->f_mntonname))
+ continue;
+ return (statfsp);
+ }
+ if (stat(devname, &mntdevstat) == 0 &&
+ mntdevstat.st_rdev == devstat.st_rdev)
+ return (statfsp);
+ }
+ statfsp = NULL;
+ return (statfsp);
+}
+
#if 0
/*
* XXX this code is from NetBSD, but fails in FreeBSD because we
OpenPOWER on IntegriCloud