summaryrefslogtreecommitdiffstats
path: root/sbin
diff options
context:
space:
mode:
authordg <dg@FreeBSD.org>1994-08-20 16:56:36 +0000
committerdg <dg@FreeBSD.org>1994-08-20 16:56:36 +0000
commitd138b7abb90e6f1b90daccd31358d4b825010882 (patch)
tree3ac1ca61e320553a32d2b2489ccf685bedcb0bea /sbin
parentf817326b2eacf649d2b0d53d60ff2d4b6fd74577 (diff)
downloadFreeBSD-src-d138b7abb90e6f1b90daccd31358d4b825010882.zip
FreeBSD-src-d138b7abb90e6f1b90daccd31358d4b825010882.tar.gz
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.
Diffstat (limited to 'sbin')
-rw-r--r--sbin/fsck/fsck.87
-rw-r--r--sbin/fsck/fsck.h1
-rw-r--r--sbin/fsck/main.c22
-rw-r--r--sbin/fsck_ffs/fsck.h1
-rw-r--r--sbin/fsck_ffs/fsck_ffs.87
-rw-r--r--sbin/fsck_ffs/main.c22
-rw-r--r--sbin/fsck_ifs/fsck.h1
-rw-r--r--sbin/fsck_ifs/fsck_ifs.87
-rw-r--r--sbin/fsck_ifs/main.c22
9 files changed, 84 insertions, 6 deletions
diff --git a/sbin/fsck/fsck.8 b/sbin/fsck/fsck.8
index cf8c499..94e31ef 100644
--- a/sbin/fsck/fsck.8
+++ b/sbin/fsck/fsck.8
@@ -40,6 +40,7 @@
.Sh SYNOPSIS
.Nm fsck
.Fl p
+.Op Fl f
.Op Fl m Ar mode
.Nm fsck
.Op Fl b Ar block#
@@ -72,6 +73,12 @@ The disk drive containing each filesystem is inferred from the longest prefix
of the device name that ends in a digit; the remaining characters are assumed
to be the partition designator.
.Pp
+The clean flag of each filesystem's superblock is examined and only those filesystems that
+are not marked clean are checked. If the
+.Fl f
+option is specified, the filesystems
+will be checked regardless of the state of their clean flag.
+.Pp
The kernel takes care that only a restricted class of innocuous filesystem
inconsistencies can happen unless hardware or software failures intervene.
These are limited to the following:
diff --git a/sbin/fsck/fsck.h b/sbin/fsck/fsck.h
index 7fa831f..0a49e4c 100644
--- a/sbin/fsck/fsck.h
+++ b/sbin/fsck/fsck.h
@@ -164,6 +164,7 @@ long numdirs, listmax, inplast;
char *cdevname; /* name of device being checked */
long dev_bsize; /* computed value of DEV_BSIZE */
long secsize; /* actual disk sector size */
+char fflag; /* force fs check (ignore clean flag) */
char nflag; /* assume a no response */
char yflag; /* assume a yes response */
int bflag; /* location of alternate super block */
diff --git a/sbin/fsck/main.c b/sbin/fsck/main.c
index 2e69715..f2dba1c 100644
--- a/sbin/fsck/main.c
+++ b/sbin/fsck/main.c
@@ -43,6 +43,7 @@ static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/23/94";
#include <sys/param.h>
#include <sys/time.h>
+#include <sys/proc.h>
#include <sys/mount.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
@@ -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();
}
diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h
index 7fa831f..0a49e4c 100644
--- a/sbin/fsck_ffs/fsck.h
+++ b/sbin/fsck_ffs/fsck.h
@@ -164,6 +164,7 @@ long numdirs, listmax, inplast;
char *cdevname; /* name of device being checked */
long dev_bsize; /* computed value of DEV_BSIZE */
long secsize; /* actual disk sector size */
+char fflag; /* force fs check (ignore clean flag) */
char nflag; /* assume a no response */
char yflag; /* assume a yes response */
int bflag; /* location of alternate super block */
diff --git a/sbin/fsck_ffs/fsck_ffs.8 b/sbin/fsck_ffs/fsck_ffs.8
index cf8c499..94e31ef 100644
--- a/sbin/fsck_ffs/fsck_ffs.8
+++ b/sbin/fsck_ffs/fsck_ffs.8
@@ -40,6 +40,7 @@
.Sh SYNOPSIS
.Nm fsck
.Fl p
+.Op Fl f
.Op Fl m Ar mode
.Nm fsck
.Op Fl b Ar block#
@@ -72,6 +73,12 @@ The disk drive containing each filesystem is inferred from the longest prefix
of the device name that ends in a digit; the remaining characters are assumed
to be the partition designator.
.Pp
+The clean flag of each filesystem's superblock is examined and only those filesystems that
+are not marked clean are checked. If the
+.Fl f
+option is specified, the filesystems
+will be checked regardless of the state of their clean flag.
+.Pp
The kernel takes care that only a restricted class of innocuous filesystem
inconsistencies can happen unless hardware or software failures intervene.
These are limited to the following:
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 <sys/param.h>
#include <sys/time.h>
+#include <sys/proc.h>
#include <sys/mount.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
@@ -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();
}
diff --git a/sbin/fsck_ifs/fsck.h b/sbin/fsck_ifs/fsck.h
index 7fa831f..0a49e4c 100644
--- a/sbin/fsck_ifs/fsck.h
+++ b/sbin/fsck_ifs/fsck.h
@@ -164,6 +164,7 @@ long numdirs, listmax, inplast;
char *cdevname; /* name of device being checked */
long dev_bsize; /* computed value of DEV_BSIZE */
long secsize; /* actual disk sector size */
+char fflag; /* force fs check (ignore clean flag) */
char nflag; /* assume a no response */
char yflag; /* assume a yes response */
int bflag; /* location of alternate super block */
diff --git a/sbin/fsck_ifs/fsck_ifs.8 b/sbin/fsck_ifs/fsck_ifs.8
index cf8c499..94e31ef 100644
--- a/sbin/fsck_ifs/fsck_ifs.8
+++ b/sbin/fsck_ifs/fsck_ifs.8
@@ -40,6 +40,7 @@
.Sh SYNOPSIS
.Nm fsck
.Fl p
+.Op Fl f
.Op Fl m Ar mode
.Nm fsck
.Op Fl b Ar block#
@@ -72,6 +73,12 @@ The disk drive containing each filesystem is inferred from the longest prefix
of the device name that ends in a digit; the remaining characters are assumed
to be the partition designator.
.Pp
+The clean flag of each filesystem's superblock is examined and only those filesystems that
+are not marked clean are checked. If the
+.Fl f
+option is specified, the filesystems
+will be checked regardless of the state of their clean flag.
+.Pp
The kernel takes care that only a restricted class of innocuous filesystem
inconsistencies can happen unless hardware or software failures intervene.
These are limited to the following:
diff --git a/sbin/fsck_ifs/main.c b/sbin/fsck_ifs/main.c
index 2e69715..f2dba1c 100644
--- a/sbin/fsck_ifs/main.c
+++ b/sbin/fsck_ifs/main.c
@@ -43,6 +43,7 @@ static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/23/94";
#include <sys/param.h>
#include <sys/time.h>
+#include <sys/proc.h>
#include <sys/mount.h>
#include <ufs/ufs/dinode.h>
#include <ufs/ffs/fs.h>
@@ -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();
}
OpenPOWER on IntegriCloud