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
This commit is contained in:
parent
74f13fb3b6
commit
111a52201c
@ -29,7 +29,7 @@
|
|||||||
.\"
|
.\"
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd April 25, 2001
|
.Dd January 25, 2009
|
||||||
.Dt FSCK 8
|
.Dt FSCK 8
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -37,7 +37,7 @@
|
|||||||
.Nd file system consistency check and interactive repair
|
.Nd file system consistency check and interactive repair
|
||||||
.Sh SYNOPSIS
|
.Sh SYNOPSIS
|
||||||
.Nm
|
.Nm
|
||||||
.Op Fl dfnpvy
|
.Op Fl Cdfnpvy
|
||||||
.Op Fl B | F
|
.Op Fl B | F
|
||||||
.Op Fl T Ar fstype : Ns Ar fsoptions
|
.Op Fl T Ar fstype : Ns Ar fsoptions
|
||||||
.Op Fl t Ar fstype
|
.Op Fl t Ar fstype
|
||||||
@ -112,6 +112,11 @@ to be the partition and slice designators.
|
|||||||
.Pp
|
.Pp
|
||||||
The options are as follows:
|
The options are as follows:
|
||||||
.Bl -tag -width indent
|
.Bl -tag -width indent
|
||||||
|
.It Fl C
|
||||||
|
Check if the
|
||||||
|
.Dq clean
|
||||||
|
flag is set in the superblock and skip file system checks if file system was
|
||||||
|
properly dismounted and marked clean.
|
||||||
.It Fl d
|
.It Fl d
|
||||||
Debugging mode.
|
Debugging mode.
|
||||||
Just print the commands without executing them.
|
Just print the commands without executing them.
|
||||||
|
@ -103,7 +103,7 @@ main(int argc, char *argv[])
|
|||||||
TAILQ_INIT(&selhead);
|
TAILQ_INIT(&selhead);
|
||||||
TAILQ_INIT(&opthead);
|
TAILQ_INIT(&opthead);
|
||||||
|
|
||||||
while ((i = getopt(argc, argv, "BdvpfFnyl:t:T:")) != -1)
|
while ((i = getopt(argc, argv, "BCdvpfFnyl:t:T:")) != -1)
|
||||||
switch (i) {
|
switch (i) {
|
||||||
case 'B':
|
case 'B':
|
||||||
if (flags & CHECK_BACKGRD)
|
if (flags & CHECK_BACKGRD)
|
||||||
@ -128,6 +128,9 @@ main(int argc, char *argv[])
|
|||||||
case 'p':
|
case 'p':
|
||||||
flags |= CHECK_PREEN;
|
flags |= CHECK_PREEN;
|
||||||
/*FALLTHROUGH*/
|
/*FALLTHROUGH*/
|
||||||
|
case 'C':
|
||||||
|
flags |= CHECK_CLEAN;
|
||||||
|
/*FALLTHROUGH*/
|
||||||
case 'n':
|
case 'n':
|
||||||
case 'y':
|
case 'y':
|
||||||
globopt[1] = i;
|
globopt[1] = i;
|
||||||
@ -566,7 +569,7 @@ static void
|
|||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
static const char common[] =
|
static const char common[] =
|
||||||
"[-dfnpvy] [-B | -F] [-T fstype:fsoptions] [-t fstype]";
|
"[-Cdfnpvy] [-B | -F] [-T fstype:fsoptions] [-t fstype]";
|
||||||
|
|
||||||
(void)fprintf(stderr, "usage: %s %s [special | node] ...\n",
|
(void)fprintf(stderr, "usage: %s %s [special | node] ...\n",
|
||||||
getprogname(), common);
|
getprogname(), common);
|
||||||
|
@ -48,6 +48,7 @@ char *estrdup(const char *);
|
|||||||
#define CHECK_DEBUG 0x0004
|
#define CHECK_DEBUG 0x0004
|
||||||
#define CHECK_BACKGRD 0x0008
|
#define CHECK_BACKGRD 0x0008
|
||||||
#define DO_BACKGRD 0x0010
|
#define DO_BACKGRD 0x0010
|
||||||
|
#define CHECK_CLEAN 0x0020
|
||||||
|
|
||||||
struct fstab;
|
struct fstab;
|
||||||
int checkfstab(int, int (*)(struct fstab *),
|
int checkfstab(int, int (*)(struct fstab *),
|
||||||
|
@ -271,6 +271,7 @@ int bkgrdflag; /* use a snapshot to run on an active system */
|
|||||||
int bflag; /* location of alternate super block */
|
int bflag; /* location of alternate super block */
|
||||||
int debug; /* output debugging info */
|
int debug; /* output debugging info */
|
||||||
char damagedflag; /* run in damaged mode */
|
char damagedflag; /* run in damaged mode */
|
||||||
|
char ckclean; /* only do work if not cleanly unmounted */
|
||||||
int cvtlevel; /* convert to newer file system format */
|
int cvtlevel; /* convert to newer file system format */
|
||||||
int bkgrdcheck; /* determine if background check is possible */
|
int bkgrdcheck; /* determine if background check is possible */
|
||||||
int bkgrdsumadj; /* whether the kernel have ability to adjust superblock summary */
|
int bkgrdsumadj; /* whether the kernel have ability to adjust superblock summary */
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
.\" @(#)fsck.8 8.4 (Berkeley) 5/9/95
|
.\" @(#)fsck.8 8.4 (Berkeley) 5/9/95
|
||||||
.\" $FreeBSD$
|
.\" $FreeBSD$
|
||||||
.\"
|
.\"
|
||||||
.Dd January 20, 2009
|
.Dd January 25, 2009
|
||||||
.Dt FSCK_FFS 8
|
.Dt FSCK_FFS 8
|
||||||
.Os
|
.Os
|
||||||
.Sh NAME
|
.Sh NAME
|
||||||
@ -46,9 +46,9 @@
|
|||||||
.Ar ...
|
.Ar ...
|
||||||
.Sh DESCRIPTION
|
.Sh DESCRIPTION
|
||||||
The specified disk partitions and/or file systems are checked.
|
The specified disk partitions and/or file systems are checked.
|
||||||
In "preen" mode the clean flag of each file system's superblock is examined
|
In "preen" or "check clean" mode the clean flag of each file system's
|
||||||
and only those file systems that
|
superblock is examined and only those file systems that are not marked clean
|
||||||
are not marked clean are checked.
|
are checked.
|
||||||
File systems are marked clean when they are unmounted,
|
File systems are marked clean when they are unmounted,
|
||||||
when they have been mounted read-only, or when
|
when they have been mounted read-only, or when
|
||||||
.Nm
|
.Nm
|
||||||
@ -175,6 +175,14 @@ Use the block specified immediately after the flag as
|
|||||||
the super block for the file system.
|
the super block for the file system.
|
||||||
An alternate super block is usually located at block 32 for UFS1,
|
An alternate super block is usually located at block 32 for UFS1,
|
||||||
and block 160 for UFS2.
|
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
|
.It Fl c
|
||||||
Convert the file system to the specified level.
|
Convert the file system to the specified level.
|
||||||
Note that the level of a file system can only be raised.
|
Note that the level of a file system can only be raised.
|
||||||
|
@ -82,7 +82,7 @@ main(int argc, char *argv[])
|
|||||||
sync();
|
sync();
|
||||||
skipclean = 1;
|
skipclean = 1;
|
||||||
damagedflag = 0;
|
damagedflag = 0;
|
||||||
while ((ch = getopt(argc, argv, "b:Bc:dDfFm:npy")) != -1) {
|
while ((ch = getopt(argc, argv, "b:Bc:CdDfFm:npy")) != -1) {
|
||||||
switch (ch) {
|
switch (ch) {
|
||||||
case 'b':
|
case 'b':
|
||||||
skipclean = 0;
|
skipclean = 0;
|
||||||
@ -132,6 +132,10 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
case 'p':
|
case 'p':
|
||||||
preen++;
|
preen++;
|
||||||
|
/*FALLTHROUGH*/
|
||||||
|
|
||||||
|
case 'C':
|
||||||
|
ckclean++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'y':
|
case 'y':
|
||||||
@ -151,7 +155,7 @@ main(int argc, char *argv[])
|
|||||||
|
|
||||||
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
|
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
|
||||||
(void)signal(SIGINT, catch);
|
(void)signal(SIGINT, catch);
|
||||||
if (preen)
|
if (ckclean)
|
||||||
(void)signal(SIGQUIT, catchquit);
|
(void)signal(SIGQUIT, catchquit);
|
||||||
signal(SIGINFO, infohandler);
|
signal(SIGINFO, infohandler);
|
||||||
if (bkgrdflag) {
|
if (bkgrdflag) {
|
||||||
@ -215,7 +219,7 @@ checkfilesys(char *filesys)
|
|||||||
errmsg[0] = '\0';
|
errmsg[0] = '\0';
|
||||||
|
|
||||||
cdevname = filesys;
|
cdevname = filesys;
|
||||||
if (debug && preen)
|
if (debug && ckclean)
|
||||||
pwarn("starting\n");
|
pwarn("starting\n");
|
||||||
/*
|
/*
|
||||||
* Make best effort to get the disk name. Check first to see
|
* 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(7); /* Filesystem clean, report it now */
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
if (preen && skipclean) {
|
if (ckclean && skipclean) {
|
||||||
/*
|
/*
|
||||||
* If file system is gjournaled, check it here.
|
* If file system is gjournaled, check it here.
|
||||||
*/
|
*/
|
||||||
@ -301,7 +305,7 @@ checkfilesys(char *filesys)
|
|||||||
"CANNOT RUN IN BACKGROUND\n");
|
"CANNOT RUN IN BACKGROUND\n");
|
||||||
}
|
}
|
||||||
if ((sblock.fs_flags & FS_UNCLEAN) == 0 &&
|
if ((sblock.fs_flags & FS_UNCLEAN) == 0 &&
|
||||||
skipclean && preen) {
|
skipclean && ckclean) {
|
||||||
/*
|
/*
|
||||||
* file system is clean;
|
* file system is clean;
|
||||||
* skip snapshot and report it clean
|
* skip snapshot and report it clean
|
||||||
|
@ -65,7 +65,7 @@ static struct disklabel *getdisklabel(char *s, int fd);
|
|||||||
/*
|
/*
|
||||||
* Read in a superblock finding an alternate if necessary.
|
* Read in a superblock finding an alternate if necessary.
|
||||||
* Return 1 if successful, 0 if unsuccessful, -1 if file system
|
* 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
|
int
|
||||||
setup(char *dev)
|
setup(char *dev)
|
||||||
@ -201,7 +201,7 @@ setup(char *dev)
|
|||||||
pwarn("USING ALTERNATE SUPERBLOCK AT %d\n", bflag);
|
pwarn("USING ALTERNATE SUPERBLOCK AT %d\n", bflag);
|
||||||
bflag = 0;
|
bflag = 0;
|
||||||
}
|
}
|
||||||
if (skipclean && preen && sblock.fs_clean) {
|
if (skipclean && ckclean && sblock.fs_clean) {
|
||||||
pwarn("FILE SYSTEM CLEAN; SKIPPING CHECKS\n");
|
pwarn("FILE SYSTEM CLEAN; SKIPPING CHECKS\n");
|
||||||
return (-1);
|
return (-1);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user