From d138b7abb90e6f1b90daccd31358d4b825010882 Mon Sep 17 00:00:00 2001 From: dg Date: Sat, 20 Aug 1994 16:56:36 +0000 Subject: Added filesystem clean bit support. This only affects fsck during a preen (-p), and in that case the filesystem is skipped if it is clean. A new flag "-f" for 'force' has been added which basically gives back the old behavior of checking all the filesystems all the time. This very closely models the behavior of SunOS and Ultrix. --- sbin/fsck_ffs/main.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) (limited to 'sbin/fsck_ffs/main.c') diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c index 2e69715..f2dba1c 100644 --- a/sbin/fsck_ffs/main.c +++ b/sbin/fsck_ffs/main.c @@ -43,6 +43,7 @@ static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/23/94"; #include #include +#include #include #include #include @@ -67,7 +68,7 @@ main(argc, argv) extern int optind; sync(); - while ((ch = getopt(argc, argv, "dpnNyYb:c:l:m:")) != EOF) { + while ((ch = getopt(argc, argv, "dfpnNyYb:c:l:m:")) != EOF) { switch (ch) { case 'p': preen++; @@ -86,6 +87,10 @@ main(argc, argv) debug++; break; + case 'f': + fflag++; + break; + case 'l': maxrun = argtoi('l', "number", optarg, 10); break; @@ -182,6 +187,18 @@ checkfilesys(filesys, mntpt, auxdata, child) pfatal("CAN'T CHECK FILE SYSTEM."); return (0); } + + if (preen && sblock.fs_clean && !fflag) { + pwarn("clean, %ld free ", sblock.fs_cstotal.cs_nffree + + sblock.fs_frag * sblock.fs_cstotal.cs_nbfree); + printf("(%ld frags, %ld blocks, %.1f%% fragmentation)\n", + sblock.fs_cstotal.cs_nffree, + sblock.fs_cstotal.cs_nbfree, + (float)(sblock.fs_cstotal.cs_nffree * 100) / + sblock.fs_dsize); + return(0); + } + /* * 1: scan inodes tallying blocks used */ @@ -268,7 +285,8 @@ checkfilesys(filesys, mntpt, auxdata, child) duplist = (struct dups *)0; muldup = (struct dups *)0; inocleanup(); - if (fsmodified) { + if (fsmodified || (!sblock.fs_clean && preen && !nflag && !hotroot)) { + sblock.fs_clean = 1; (void)time(&sblock.fs_time); sbdirty(); } -- cgit v1.1