diff options
author | obrien <obrien@FreeBSD.org> | 2009-01-30 18:33:05 +0000 |
---|---|---|
committer | obrien <obrien@FreeBSD.org> | 2009-01-30 18:33:05 +0000 |
commit | 7d88cc57bfb464896ea2e3fd2b0cffe6d6ea7ecd (patch) | |
tree | 65f596e651497e62a137531d7771a73ad6ee6ac8 /sbin/fsck_ffs | |
parent | f5f831de53b881b68dd4aa49b41c1ea7c73d4c6a (diff) | |
download | FreeBSD-src-7d88cc57bfb464896ea2e3fd2b0cffe6d6ea7ecd.zip FreeBSD-src-7d88cc57bfb464896ea2e3fd2b0cffe6d6ea7ecd.tar.gz |
Add the '-C' "check clean" flag. If the FS is marked clean, skip file
system checking. However, if the file system is not clean, perform a
full fsck.
Reviewed by: delphij
Obtained from: Juniper Networks
Diffstat (limited to 'sbin/fsck_ffs')
-rw-r--r-- | sbin/fsck_ffs/fsck.h | 1 | ||||
-rw-r--r-- | sbin/fsck_ffs/fsck_ffs.8 | 16 | ||||
-rw-r--r-- | sbin/fsck_ffs/main.c | 14 | ||||
-rw-r--r-- | sbin/fsck_ffs/setup.c | 4 |
4 files changed, 24 insertions, 11 deletions
diff --git a/sbin/fsck_ffs/fsck.h b/sbin/fsck_ffs/fsck.h index fd2ed3d..76cf23c 100644 --- a/sbin/fsck_ffs/fsck.h +++ b/sbin/fsck_ffs/fsck.h @@ -271,6 +271,7 @@ int bkgrdflag; /* use a snapshot to run on an active system */ int bflag; /* location of alternate super block */ int debug; /* output debugging info */ char damagedflag; /* run in damaged mode */ +char ckclean; /* only do work if not cleanly unmounted */ int cvtlevel; /* convert to newer file system format */ int bkgrdcheck; /* determine if background check is possible */ int bkgrdsumadj; /* whether the kernel have ability to adjust superblock summary */ diff --git a/sbin/fsck_ffs/fsck_ffs.8 b/sbin/fsck_ffs/fsck_ffs.8 index a264f21..b27269a 100644 --- a/sbin/fsck_ffs/fsck_ffs.8 +++ b/sbin/fsck_ffs/fsck_ffs.8 @@ -29,7 +29,7 @@ .\" @(#)fsck.8 8.4 (Berkeley) 5/9/95 .\" $FreeBSD$ .\" -.Dd January 20, 2009 +.Dd January 25, 2009 .Dt FSCK_FFS 8 .Os .Sh NAME @@ -46,9 +46,9 @@ .Ar ... .Sh DESCRIPTION The specified disk partitions and/or file systems are checked. -In "preen" mode the clean flag of each file system's superblock is examined -and only those file systems that -are not marked clean are checked. +In "preen" or "check clean" mode the clean flag of each file system's +superblock is examined and only those file systems that are not marked clean +are checked. File systems are marked clean when they are unmounted, when they have been mounted read-only, or when .Nm @@ -175,6 +175,14 @@ Use the block specified immediately after the flag as the super block for the file system. An alternate super block is usually located at block 32 for UFS1, and block 160 for UFS2. +.It Fl C +Check if file system was dismouted cleanly. +If so, skip file system checks (like "preen"). +However, if the file system was not cleanly dismounted, do full checks, +is if +.Nm +was invoked without +.Fl C . .It Fl c Convert the file system to the specified level. Note that the level of a file system can only be raised. diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c index ac4a2a0..2fdd248 100644 --- a/sbin/fsck_ffs/main.c +++ b/sbin/fsck_ffs/main.c @@ -82,7 +82,7 @@ main(int argc, char *argv[]) sync(); skipclean = 1; damagedflag = 0; - while ((ch = getopt(argc, argv, "b:Bc:dDfFm:npy")) != -1) { + while ((ch = getopt(argc, argv, "b:Bc:CdDfFm:npy")) != -1) { switch (ch) { case 'b': skipclean = 0; @@ -132,6 +132,10 @@ main(int argc, char *argv[]) case 'p': preen++; + /*FALLTHROUGH*/ + + case 'C': + ckclean++; break; case 'y': @@ -151,7 +155,7 @@ main(int argc, char *argv[]) if (signal(SIGINT, SIG_IGN) != SIG_IGN) (void)signal(SIGINT, catch); - if (preen) + if (ckclean) (void)signal(SIGQUIT, catchquit); signal(SIGINFO, infohandler); if (bkgrdflag) { @@ -215,7 +219,7 @@ checkfilesys(char *filesys) errmsg[0] = '\0'; cdevname = filesys; - if (debug && preen) + if (debug && ckclean) pwarn("starting\n"); /* * Make best effort to get the disk name. Check first to see @@ -250,7 +254,7 @@ checkfilesys(char *filesys) exit(7); /* Filesystem clean, report it now */ exit(0); } - if (preen && skipclean) { + if (ckclean && skipclean) { /* * If file system is gjournaled, check it here. */ @@ -301,7 +305,7 @@ checkfilesys(char *filesys) "CANNOT RUN IN BACKGROUND\n"); } if ((sblock.fs_flags & FS_UNCLEAN) == 0 && - skipclean && preen) { + skipclean && ckclean) { /* * file system is clean; * skip snapshot and report it clean diff --git a/sbin/fsck_ffs/setup.c b/sbin/fsck_ffs/setup.c index f6b37a3..1628ffb 100644 --- a/sbin/fsck_ffs/setup.c +++ b/sbin/fsck_ffs/setup.c @@ -65,7 +65,7 @@ static struct disklabel *getdisklabel(char *s, int fd); /* * Read in a superblock finding an alternate if necessary. * Return 1 if successful, 0 if unsuccessful, -1 if file system - * is already clean (preen mode only). + * is already clean (ckclean and preen mode only). */ int setup(char *dev) @@ -201,7 +201,7 @@ setup(char *dev) pwarn("USING ALTERNATE SUPERBLOCK AT %d\n", bflag); bflag = 0; } - if (skipclean && preen && sblock.fs_clean) { + if (skipclean && ckclean && sblock.fs_clean) { pwarn("FILE SYSTEM CLEAN; SKIPPING CHECKS\n"); return (-1); } |