From fd4c6d5d2b997a80f6ac479e795d74d75cf4146a Mon Sep 17 00:00:00 2001 From: deraadt Date: Wed, 14 Oct 2015 14:33:45 +0000 Subject: [PATCH] Only accept one filesystem/device as argument for checking. Few people will be calling these directly, and not for the multiple filesystem case. fsck(8) is generally the parent and will handle things. ok semarie; this change will also help a goal jsing has --- sbin/fsck_ext2fs/fsck_ext2fs.8 | 16 ++++++++-------- sbin/fsck_ext2fs/main.c | 9 ++++----- sbin/fsck_ffs/fsck_ffs.8 | 18 +++++++++--------- sbin/fsck_ffs/main.c | 20 ++++++++++++++------ sbin/fsck_msdos/fsck_msdos.8 | 14 +++++++------- sbin/fsck_msdos/main.c | 16 +++++----------- 6 files changed, 47 insertions(+), 46 deletions(-) diff --git a/sbin/fsck_ext2fs/fsck_ext2fs.8 b/sbin/fsck_ext2fs/fsck_ext2fs.8 index 71cfd1a3fe3..012b0fd1f95 100644 --- a/sbin/fsck_ext2fs/fsck_ext2fs.8 +++ b/sbin/fsck_ext2fs/fsck_ext2fs.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: fsck_ext2fs.8,v 1.17 2015/07/27 18:46:19 jmc Exp $ +.\" $OpenBSD: fsck_ext2fs.8,v 1.18 2015/10/14 14:33:45 deraadt Exp $ .\" $NetBSD: fsck_ext2fs.8,v 1.1 1997/06/11 11:21:48 bouyer Exp $ .\" .\" Copyright (c) 1997 Manuel Bouyer. @@ -31,7 +31,7 @@ .\" .\" @(#)fsck.8 8.3 (Berkeley) 11/29/94 .\" -.Dd $Mdocdate: July 27 2015 $ +.Dd $Mdocdate: October 14 2015 $ .Dt FSCK_EXT2FS 8 .Os .Sh NAME @@ -42,11 +42,11 @@ .Op Fl dfnpy .Op Fl b Ar block# .Op Fl m Ar mode -.Ar filesystem ... +.Ar filesystem .Sh DESCRIPTION .Nm -performs interactive file system consistency checks and repairs for each of -the file systems specified. +performs interactive file system consistency checks and repairs +the filesystem specified. It is normally invoked from .Xr fsck 8 . .Pp @@ -93,7 +93,7 @@ Without the .Fl p option, .Nm -audits and interactively repairs inconsistent conditions for file systems. +audits and interactively repairs inconsistent conditions for the filesystem. If the file system is inconsistent, the operator is prompted for concurrence before each correction is attempted. It should be noted that some of the corrective actions which are not @@ -123,7 +123,7 @@ Block 8193 is usually an alternate super block. .It Fl d Print debugging output. .It Fl f -Force checking of file systems. +Force checking of the filesystem. Normally, if a file system is cleanly unmounted, the kernel will set a .Dq clean flag in the file system superblock and @@ -150,7 +150,7 @@ response to all questions asked by except for .Dq CONTINUE? , which is assumed to be affirmative. -File systems will not be opened for writing. +The filesystem will not be opened for writing. This is the default for file systems to be checked that are concurrently mounted writable. .It Fl p diff --git a/sbin/fsck_ext2fs/main.c b/sbin/fsck_ext2fs/main.c index a4c3e2baa20..90406108f7b 100644 --- a/sbin/fsck_ext2fs/main.c +++ b/sbin/fsck_ext2fs/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.22 2015/02/07 02:09:13 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.23 2015/10/14 14:33:45 deraadt Exp $ */ /* $NetBSD: main.c,v 1.1 1997/06/11 11:21:50 bouyer Exp $ */ /* @@ -111,7 +111,7 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; - if (!argc) + if (argc != 1) usage(); if (signal(SIGINT, SIG_IGN) != SIG_IGN) @@ -119,8 +119,7 @@ main(int argc, char *argv[]) if (preen) (void)signal(SIGQUIT, catchquit); - while (argc-- > 0) - (void)checkfilesys(blockcheck(*argv++), 0, 0L, 0); + (void)checkfilesys(blockcheck(*argv), 0, 0L, 0); if (returntosingle) ret = 2; @@ -303,7 +302,7 @@ usage(void) extern char *__progname; (void) fprintf(stderr, - "usage: %s [-dfnpy] [-b block#] [-m mode] filesystem ...\n", + "usage: %s [-dfnpy] [-b block#] [-m mode] filesystem\n", __progname); exit(1); } diff --git a/sbin/fsck_ffs/fsck_ffs.8 b/sbin/fsck_ffs/fsck_ffs.8 index f42bf4eb1d9..28d8287e028 100644 --- a/sbin/fsck_ffs/fsck_ffs.8 +++ b/sbin/fsck_ffs/fsck_ffs.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: fsck_ffs.8,v 1.24 2015/07/27 18:46:19 jmc Exp $ +.\" $OpenBSD: fsck_ffs.8,v 1.25 2015/10/14 14:33:45 deraadt Exp $ .\" $NetBSD: fsck_ffs.8,v 1.12 1996/09/23 16:18:34 christos Exp $ .\" .\" Copyright (c) 1980, 1989, 1991, 1993 @@ -30,7 +30,7 @@ .\" .\" @(#)fsck.8 8.3 (Berkeley) 11/29/94 .\" -.Dd $Mdocdate: July 27 2015 $ +.Dd $Mdocdate: October 14 2015 $ .Dt FSCK_FFS 8 .Os .Sh NAME @@ -42,10 +42,10 @@ .Op Fl b Ar block# .Op Fl c Ar level .Op Fl m Ar mode -.Ar filesystem ... +.Ar filesystem .Sh DESCRIPTION .Nm -performs interactive file system consistency checks and repairs for each +performs interactive file system consistency checks and repairs the file system specified. It is normally invoked from .Xr fsck 8 . @@ -104,7 +104,7 @@ Without the .Fl p option, .Nm -audits and interactively repairs inconsistent conditions for file systems. +audits and interactively repairs inconsistent conditions for the filesystem. If the file system is inconsistent, the operator is prompted for concurrence before each correction is attempted. It should be noted that some of the corrective actions which are not @@ -165,7 +165,7 @@ If is equal to one, delete any existing segment maps. .El .It Fl f -Force checking of file systems. +Force checking of the filesystem. Normally, if a file system is cleanly unmounted, the kernel will set a .Dq clean flag in the file system superblock and @@ -192,14 +192,14 @@ response to all questions asked by except for .Dq CONTINUE? , which is assumed to be affirmative. -File systems will not be opened for writing. +The filesystem will not be opened for writing. This is the default for file systems to be checked that are concurrently mounted writable. .It Fl p Enter preen mode: .Nm -will check the file systems on the -special (raw) devices listed on the command line +will check the filesystem on the +special (raw) device listed on the command line and will make minor repairs without human intervention. Any major problems will cause diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c index 63bd1feeea2..611da7fb61c 100644 --- a/sbin/fsck_ffs/main.c +++ b/sbin/fsck_ffs/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.44 2015/02/07 02:09:13 deraadt Exp $ */ +/* $OpenBSD: main.c,v 1.45 2015/10/14 14:33:45 deraadt Exp $ */ /* $NetBSD: main.c,v 1.22 1996/10/11 20:15:48 thorpej Exp $ */ /* @@ -53,6 +53,13 @@ int main(int, char *[]); extern char *__progname; +void +usage(void) +{ + fprintf(stderr, "usage: %s [-fnpy] [-b block#] [-c level] " + "[-m mode] filesystem\n", __progname); + exit(1); +} int main(int argc, char *argv[]) { @@ -109,21 +116,22 @@ main(int argc, char *argv[]) break; default: - errexit("usage: %s [-fnpy] [-b block#] [-c level] " - "[-m mode] filesystem ...\n", __progname); + usage(); } } argc -= optind; argv += optind; + + if (argc != 1) + usage(); + if (signal(SIGINT, SIG_IGN) != SIG_IGN) (void)signal(SIGINT, catch); if (preen) (void)signal(SIGQUIT, catchquit); (void)signal(SIGINFO, catchinfo); - if (argc) - while (argc-- > 0) - (void)checkfilesys(blockcheck(*argv++), 0, 0L, 0); + (void)checkfilesys(blockcheck(*argv), 0, 0L, 0); if (returntosingle) ret = 2; diff --git a/sbin/fsck_msdos/fsck_msdos.8 b/sbin/fsck_msdos/fsck_msdos.8 index edb547d630c..b0e89a8113c 100644 --- a/sbin/fsck_msdos/fsck_msdos.8 +++ b/sbin/fsck_msdos/fsck_msdos.8 @@ -1,4 +1,4 @@ -.\" $OpenBSD: fsck_msdos.8,v 1.15 2015/07/27 18:46:19 jmc Exp $ +.\" $OpenBSD: fsck_msdos.8,v 1.16 2015/10/14 14:33:45 deraadt Exp $ .\" $NetBSD: fsck_msdos.8,v 1.4 1996/10/17 20:41:24 cgd Exp $ .\" .\" Copyright (C) 1995 Wolfgang Solfrank @@ -25,7 +25,7 @@ .\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" .\" -.Dd $Mdocdate: July 27 2015 $ +.Dd $Mdocdate: October 14 2015 $ .Dt FSCK_MSDOS 8 .Os .Sh NAME @@ -34,7 +34,7 @@ .Sh SYNOPSIS .Nm fsck_msdos .Op Fl fnpy -.Ar filesystem ... +.Ar filesystem .Sh DESCRIPTION The .Nm @@ -43,7 +43,7 @@ utility verifies and repairs file systems (more commonly known as .Tn DOS file systems). -It checks the specified file systems and tries to repair all +It checks the specified filesystem and tries to repair all detected inconsistencies, requesting confirmation before making any changes. .Pp @@ -51,7 +51,7 @@ If the .Fl p flag is given, .Nm -preens the specified file systems. +preens the specified filesystem. It is normally started this way by .Xr fsck 8 run from @@ -81,11 +81,11 @@ response to all questions asked by except for .Dq CONTINUE? , which is assumed to be affirmative. -File systems will not be opened for writing. +The filesystem will not be opened for writing. This is the default for file systems to be checked that are concurrently mounted writable. .It Fl p -Preen the specified file systems. +Preen the specified filesystem. .It Fl y Causes .Nm diff --git a/sbin/fsck_msdos/main.c b/sbin/fsck_msdos/main.c index be75cb6c764..acd61846b22 100644 --- a/sbin/fsck_msdos/main.c +++ b/sbin/fsck_msdos/main.c @@ -1,4 +1,4 @@ -/* $OpenBSD: main.c,v 1.20 2015/09/27 16:56:06 guenther Exp $ */ +/* $OpenBSD: main.c,v 1.21 2015/10/14 14:33:45 deraadt Exp $ */ /* $NetBSD: main.c,v 1.8 1996/10/17 20:29:53 cgd Exp $ */ /* @@ -48,13 +48,12 @@ int main(int, char **); static void usage(void) { - errexit("usage: fsck_msdos [-fnpy] filesystem ...\n"); + errexit("usage: fsck_msdos [-fnpy] filesystem\n"); } int main(int argc, char *argv[]) { - int ret = 0, erg; int ch; while ((ch = getopt(argc, argv, "pynf")) != -1) { @@ -86,16 +85,11 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; - if (!argc) + if (argc != 1) usage(); - while (argc-- > 0) { - setcdevname(*argv, NULL, preen); - erg = checkfilesys(blockcheck(*argv++)); - if (erg > ret) - ret = erg; - } - exit(ret); + setcdevname(*argv, NULL, preen); + exit (checkfilesys(blockcheck(*argv))); } int -- 2.20.1