Add a -q (quiet) option to print nothing for clean filesystems.

Support in fsck_ffs and stub in fsck_xxx.
Push a few more messages through pwarn() instead of printf() to ensure
disk name is shown.
This commit is contained in:
dsl 2003-10-20 12:04:38 +00:00
parent 60e31ba365
commit e69ce3e4bf
11 changed files with 102 additions and 75 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: fsck.8,v 1.28 2003/02/25 10:34:55 wiz Exp $
.\" $NetBSD: fsck.8,v 1.29 2003/10/20 12:04:38 dsl Exp $
.\"
.\" Copyright (c) 1996 Christos Zoulas. All rights reserved.
.\"
@ -27,7 +27,7 @@
.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
.\"
.Dd June 18, 2001
.Dd October 20, 2003
.Dt FSCK 8
.Os
.Sh NAME
@ -35,7 +35,7 @@
.Nd file system consistency check and interactive repair
.Sh SYNOPSIS
.Nm
.Op Fl dfnpvy
.Op Fl dfnpqvy
.Op Fl l Ar maxparallel
.Op Fl t Ar fstype
.Op Fl T Ar fstype:fsoptions
@ -101,6 +101,8 @@ to exit with a non-zero
.Xr exit 3
code, so as to alert any invoking program or script that human
intervention is required.
.It Fl q
Quiet mode, do not output any messages for clean filesystems.
.It Fl t Ar fstype
Invoke
.Nm

View File

@ -1,4 +1,4 @@
/* $NetBSD: fsck.c,v 1.30 2003/08/07 10:04:15 agc Exp $ */
/* $NetBSD: fsck.c,v 1.31 2003/10/20 12:04:38 dsl Exp $ */
/*
* Copyright (c) 1980, 1989, 1993, 1994
@ -71,7 +71,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: fsck.c,v 1.30 2003/08/07 10:04:15 agc Exp $");
__RCSID("$NetBSD: fsck.c,v 1.31 2003/10/20 12:04:38 dsl Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -139,37 +139,34 @@ main(int argc, char *argv[])
TAILQ_INIT(&selhead);
TAILQ_INIT(&opthead);
while ((i = getopt(argc, argv, "dvpfnyl:t:T:")) != -1)
while ((i = getopt(argc, argv, "dfl:npqT:t:vy")) != -1) {
switch (i) {
case 'd':
flags |= CHECK_DEBUG;
continue;
case 'f':
flags |= CHECK_FORCE;
break;
case 'v':
flags |= CHECK_VERBOSE;
case 'n':
break;
case 'p':
case 'f':
if (i == 'p')
flags |= CHECK_PREEN;
else
flags |= CHECK_FORCE;
/*FALLTHROUGH*/
case 'n':
case 'y':
globopt[1] = i;
catopt(&options, globopt);
flags |= CHECK_PREEN;
break;
case 'q':
break;
case 'l':
maxrun = atoi(optarg);
break;
continue;
case 'T':
if (*optarg)
addoption(optarg);
break;
continue;
case 't':
if (TAILQ_FIRST(&selhead) != NULL)
@ -177,6 +174,13 @@ main(int argc, char *argv[])
maketypelist(optarg);
vfstype = optarg;
continue;
case 'v':
flags |= CHECK_VERBOSE;
continue;
case 'y':
break;
case '?':
@ -185,6 +189,11 @@ main(int argc, char *argv[])
/* NOTREACHED */
}
/* Pass option to fsck_xxxfs */
globopt[1] = i;
catopt(&options, globopt);
}
argc -= optind;
argv += optind;
@ -556,7 +565,7 @@ static void
usage(void)
{
static const char common[] =
"[-dfnpvy] [-T fstype:fsoptions] [-t fstype]";
"[-dfnpqvy] [-T fstype:fsoptions] [-t fstype]";
(void)fprintf(stderr, "Usage: %s %s [special|node]...\n",
getprogname(), common);

View File

@ -1,4 +1,4 @@
/* $NetBSD: fsutil.c,v 1.13 2003/08/07 10:04:16 agc Exp $ */
/* $NetBSD: fsutil.c,v 1.14 2003/10/20 12:04:38 dsl Exp $ */
/*
* Copyright (c) 1990, 1993
@ -31,7 +31,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: fsutil.c,v 1.13 2003/08/07 10:04:16 agc Exp $");
__RCSID("$NetBSD: fsutil.c,v 1.14 2003/10/20 12:04:38 dsl Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -52,6 +52,7 @@ __RCSID("$NetBSD: fsutil.c,v 1.13 2003/08/07 10:04:16 agc Exp $");
static const char *dev = NULL;
static int hot = 0;
static int preen = 0;
int quiet;
void
setcdevname(const char *cd, int pr)
@ -92,7 +93,11 @@ vmsg(int fatal, const char *fmt, va_list ap)
{
if (!fatal && preen)
(void) printf("%s: ", dev);
(void)printf("%s: ", dev);
if (quiet && !preen) {
(void)printf("** %s (vmsg)\n", dev);
quiet = 0;
}
(void) vprintf(fmt, ap);

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.13 2003/10/05 17:48:49 bouyer Exp $ */
/* $NetBSD: main.c,v 1.14 2003/10/20 12:04:38 dsl Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@ -69,7 +69,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1986, 1993\n\
#if 0
static char sccsid[] = "@(#)main.c 8.2 (Berkeley) 1/23/94";
#else
__RCSID("$NetBSD: main.c,v 1.13 2003/10/05 17:48:49 bouyer Exp $");
__RCSID("$NetBSD: main.c,v 1.14 2003/10/20 12:04:38 dsl Exp $");
#endif
#endif /* not lint */
@ -109,7 +109,7 @@ main(argc, argv)
sync();
skipclean = 1;
while ((ch = getopt(argc, argv, "b:c:dfm:npy")) != -1) {
while ((ch = getopt(argc, argv, "b:c:dfm:npqy")) != -1) {
switch (ch) {
case 'b':
skipclean = 0;
@ -141,6 +141,9 @@ main(argc, argv)
preen++;
break;
case 'q': /* Quiet not implemented */
break;
case 'y':
yflag++;
nflag = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: fsck.h,v 1.35 2003/08/07 10:04:19 agc Exp $ */
/* $NetBSD: fsck.h,v 1.36 2003/10/20 12:04:38 dsl Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@ -240,6 +240,7 @@ int doinglevel2; /* converting to new inode format */
int newinofmt; /* filesystem has new inode format */
char usedsoftdep; /* just fix soft dependency inconsistencies */
int preen; /* just fix normal inconsistencies */
int quiet; /* Don't print anything if clean */
int forceimage; /* file system is an image file */
int doswap; /* convert byte order */
int needswap; /* need to convert byte order in memory */
@ -255,7 +256,7 @@ int fsreadfd; /* file descriptor for reading file system */
int fswritefd; /* file descriptor for writing file system */
int rerun; /* rerun fsck. Only used in non-preen mode */
char resolved; /* cleared if unresolved changes => not clean */
int isappleufs; /* filesystem is Apple UFS */
int isappleufs; /* filesystem is Apple UFS */
daddr_t maxfsblock; /* number of blocks in the file system */
char *blockmap; /* ptr to primary blk allocation map */

View File

@ -1,4 +1,4 @@
.\" $NetBSD: fsck_ffs.8,v 1.33 2003/08/07 10:04:20 agc Exp $
.\" $NetBSD: fsck_ffs.8,v 1.34 2003/10/20 12:04:38 dsl Exp $
.\"
.\" Copyright (c) 1980, 1989, 1991, 1993
.\" The Regents of the University of California. All rights reserved.
@ -29,7 +29,7 @@
.\"
.\" @(#)fsck.8 8.3 (Berkeley) 11/29/94
.\"
.Dd May 6, 2001
.Dd October 20, 2003
.Dt FSCK_FFS 8
.Os
.Sh NAME
@ -37,17 +37,12 @@
.Nd Fast File System consistency check and interactive repair
.Sh SYNOPSIS
.Nm
.Op Fl a
.Op Fl adFfpq
.Op Fl B Ar byte order
.Op Fl b Ar block#
.Op Fl c Ar level
.Op Fl d
.Op Fl F
.Op Fl f
.Op Fl m Ar mode
.Op Fl p
.Op Fl y
.Op Fl n
.Op Fl y | n
.Ar filesystem ...
.Sh DESCRIPTION
.Nm
@ -230,6 +225,8 @@ which is assumed to be affirmative;
do not open the file system for writing.
.It Fl p
Specify ``preen'' mode, described above.
.It Fl q
Quiet mode, do not output any messages for clean filesystems.
.It Fl y
Assume a yes response to all questions asked by
.Nm ;

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.46 2003/08/07 10:04:20 agc Exp $ */
/* $NetBSD: main.c,v 1.47 2003/10/20 12:04:38 dsl Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@ -39,7 +39,7 @@ __COPYRIGHT("@(#) Copyright (c) 1980, 1986, 1993\n\
#if 0
static char sccsid[] = "@(#)main.c 8.6 (Berkeley) 5/14/95";
#else
__RCSID("$NetBSD: main.c,v 1.46 2003/08/07 10:04:20 agc Exp $");
__RCSID("$NetBSD: main.c,v 1.47 2003/10/20 12:04:38 dsl Exp $");
#endif
#endif /* not lint */
@ -94,7 +94,7 @@ main(argc, argv)
forceimage = 0;
endian = 0;
isappleufs = 0;
while ((ch = getopt(argc, argv, "aB:b:c:dFfm:npy")) != -1) {
while ((ch = getopt(argc, argv, "aB:b:c:dFfm:npqy")) != -1) {
switch (ch) {
case 'a':
isappleufs = 1;
@ -147,6 +147,10 @@ main(argc, argv)
preen++;
break;
case 'q':
quiet++;
break;
case 'y':
yflag++;
nflag = 0;
@ -241,10 +245,10 @@ checkfilesys(filesys, mntpt, auxdata, child)
* 1: scan inodes tallying blocks used
*/
if (preen == 0) {
printf("** Last Mounted on %s\n", sblock->fs_fsmnt);
pwarn("** Last Mounted on %s\n", sblock->fs_fsmnt);
if (hotroot())
printf("** Root file system\n");
printf("** Phase 1 - Check Blocks and Sizes\n");
pwarn("** Root file system\n");
pwarn("** Phase 1 - Check Blocks and Sizes\n");
}
pass1();
@ -256,7 +260,7 @@ checkfilesys(filesys, mntpt, auxdata, child)
pfatal("INTERNAL ERROR: dups with -p\n");
if (usedsoftdep)
pfatal("INTERNAL ERROR: dups with softdep\n");
printf("** Phase 1b - Rescan For More DUPS\n");
pwarn("** Phase 1b - Rescan For More DUPS\n");
pass1b();
}
@ -264,28 +268,28 @@ checkfilesys(filesys, mntpt, auxdata, child)
* 2: traverse directories from root to mark all connected directories
*/
if (preen == 0)
printf("** Phase 2 - Check Pathnames\n");
pwarn("** Phase 2 - Check Pathnames\n");
pass2();
/*
* 3: scan inodes looking for disconnected directories
*/
if (preen == 0)
printf("** Phase 3 - Check Connectivity\n");
pwarn("** Phase 3 - Check Connectivity\n");
pass3();
/*
* 4: scan inodes looking for disconnected files; check reference counts
*/
if (preen == 0)
printf("** Phase 4 - Check Reference Counts\n");
pwarn("** Phase 4 - Check Reference Counts\n");
pass4();
/*
* 5: check and repair resource counts in cylinder groups
*/
if (preen == 0)
printf("** Phase 5 - Check Cyl groups\n");
pwarn("** Phase 5 - Check Cyl groups\n");
pass5();
/*
@ -362,9 +366,9 @@ checkfilesys(filesys, mntpt, auxdata, child)
if (!fsmodified)
return (0);
if (!preen)
printf("\n***** FILE SYSTEM WAS MODIFIED *****\n");
pwarn("\n***** FILE SYSTEM WAS MODIFIED *****\n");
if (rerun)
printf("\n***** PLEASE RERUN FSCK *****\n");
pwarn("\n***** PLEASE RERUN FSCK *****\n");
if (hotroot()) {
struct statfs stfs_buf;
/*
@ -387,7 +391,7 @@ checkfilesys(filesys, mntpt, auxdata, child)
}
}
if (!preen)
printf("\n***** REBOOT NOW *****\n");
pwarn("\n***** REBOOT NOW *****\n");
sync();
return (4);
}
@ -399,7 +403,7 @@ usage()
{
(void) fprintf(stderr,
"Usage: %s [-dFfnpy] [-B be|le] [-b block] [-c level] [-m mode]"
"Usage: %s [-dFfnpqy] [-B be|le] [-b block] [-c level] [-m mode]"
" filesystem ...\n",
getprogname());
exit(1);

View File

@ -1,4 +1,4 @@
/* $NetBSD: setup.c,v 1.62 2003/08/07 10:04:21 agc Exp $ */
/* $NetBSD: setup.c,v 1.63 2003/10/20 12:04:38 dsl Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)setup.c 8.10 (Berkeley) 5/9/95";
#else
__RCSID("$NetBSD: setup.c,v 1.62 2003/08/07 10:04:21 agc Exp $");
__RCSID("$NetBSD: setup.c,v 1.63 2003/10/20 12:04:38 dsl Exp $");
#endif
#endif /* not lint */
@ -107,16 +107,15 @@ setup(dev)
printf("Can't open %s: %s\n", dev, strerror(errno));
return (0);
}
if (preen == 0)
printf("** %s", dev);
if (nflag || (fswritefd = open(dev, O_WRONLY)) < 0) {
fswritefd = -1;
if (preen)
pfatal("NO WRITE ACCESS");
printf(" (NO WRITE)");
}
if (preen == 0)
printf("\n");
printf("** %s (NO WRITE)\n", dev);
quiet = 0;
} else
if (!preen && !quiet)
printf("** %s\n", dev);
fsmodified = 0;
lfdir = 0;
initbarea(&sblk);
@ -170,8 +169,9 @@ setup(dev)
}
if (sblock->fs_clean & FS_ISCLEAN) {
if (doskipclean) {
pwarn("%sile system is clean; not checking\n",
preen ? "f" : "** F");
if (!quiet)
pwarn("%sile system is clean; not checking\n",
preen ? "f" : "** F");
return (-1);
}
if (!preen && !doswap)
@ -381,14 +381,14 @@ setup(dev)
bmapsize = roundup(howmany(maxfsblock, NBBY), sizeof(int16_t));
blockmap = calloc((unsigned)bmapsize, sizeof (char));
if (blockmap == NULL) {
printf("cannot alloc %u bytes for blockmap\n",
pwarn("cannot alloc %u bytes for blockmap\n",
(unsigned)bmapsize);
goto badsblabel;
}
inostathead = calloc((unsigned)(sblock->fs_ncg),
sizeof(struct inostatlist));
if (inostathead == NULL) {
printf("cannot alloc %u bytes for inostathead\n",
pwarn("cannot alloc %u bytes for inostathead\n",
(unsigned)(sizeof(struct inostatlist) * (sblock->fs_ncg)));
goto badsblabel;
}
@ -411,13 +411,13 @@ setup(dev)
inphead = (struct inoinfo **)calloc((unsigned)numdirs,
sizeof(struct inoinfo *));
if (inpsort == NULL || inphead == NULL) {
printf("cannot alloc %u bytes for inphead\n",
pwarn("cannot alloc %u bytes for inphead\n",
(unsigned)(numdirs * sizeof(struct inoinfo *)));
goto badsblabel;
}
cgrp = malloc(sblock->fs_cgsize);
if (cgrp == NULL) {
printf("cannot alloc %u bytes for cylinder group\n",
pwarn("cannot alloc %u bytes for cylinder group\n",
sblock->fs_cgsize);
goto badsblabel;
}
@ -641,7 +641,7 @@ readsb(listerr)
pfatal("INTERNAL ERROR: unknown endian");
}
if (needswap)
printf("** Swapped byte order\n");
pwarn("** Swapped byte order\n");
/* swap SB byte order if asked */
if (doswap)
ffs_sb_swap(sblk.b_un.b_fs, sblk.b_un.b_fs);

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.15 2003/08/07 10:04:23 agc Exp $ */
/* $NetBSD: main.c,v 1.16 2003/10/20 12:04:38 dsl Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@ -64,7 +64,7 @@ main(int argc, char **argv)
{
int ch;
int ret = 0;
char *optstring = "b:dfi:m:npy";
char *optstring = "b:dfi:m:npqy";
sync();
skipclean = 1;
@ -106,6 +106,9 @@ main(int argc, char **argv)
preen++;
break;
case 'q': /* Quiet not implemented */
break;
case 'y':
yflag++;
nflag = 0;

View File

@ -1,4 +1,4 @@
/* $NetBSD: utilities.c,v 1.15 2003/08/07 10:04:24 agc Exp $ */
/* $NetBSD: utilities.c,v 1.16 2003/10/20 12:04:38 dsl Exp $ */
/*
* Copyright (c) 1980, 1986, 1993
@ -92,7 +92,7 @@ reply(char *question)
if (preen)
err(1, "INTERNAL ERROR: GOT TO reply()");
persevere = !strcmp(question, "CONTINUE");
printf("\n");
pwarn("\n");
if (!persevere && nflag) {
printf("%s? no\n\n", question);
return (0);

View File

@ -1,4 +1,4 @@
/* $NetBSD: main.c,v 1.13 2002/05/25 23:45:13 wiz Exp $ */
/* $NetBSD: main.c,v 1.14 2003/10/20 12:04:38 dsl Exp $ */
/*
* Copyright (C) 1995 Wolfgang Solfrank
@ -35,7 +35,7 @@
#include <sys/cdefs.h>
#ifndef lint
__RCSID("$NetBSD: main.c,v 1.13 2002/05/25 23:45:13 wiz Exp $");
__RCSID("$NetBSD: main.c,v 1.14 2003/10/20 12:04:38 dsl Exp $");
#endif /* not lint */
#include <stdlib.h>
@ -71,7 +71,7 @@ main(argc, argv)
int ret = 0, erg;
int ch;
while ((ch = getopt(argc, argv, "pynf")) != -1) {
while ((ch = getopt(argc, argv, "pqynf")) != -1) {
switch (ch) {
case 'f':
/*
@ -93,6 +93,9 @@ main(argc, argv)
alwaysyes = alwaysno = 0;
break;
case 'q': /* quite not implemented */
break;
default:
usage();
break;