diff --git a/sbin/fsck_msdos/fsck_msdos.8 b/sbin/fsck_msdos/fsck_msdos.8 index 127c4554316a..755b7d3b87ac 100644 --- a/sbin/fsck_msdos/fsck_msdos.8 +++ b/sbin/fsck_msdos/fsck_msdos.8 @@ -1,4 +1,4 @@ -.\" $NetBSD: fsck_msdos.8,v 1.1 1996/05/14 17:39:35 ws Exp $ +.\" $NetBSD: fsck_msdos.8,v 1.2 1996/09/11 20:35:15 christos Exp $ .\" .\" Copyright (C) 1995 Wolfgang Solfrank .\" Copyright (c) 1995 Martin Husemann @@ -40,8 +40,8 @@ .Sh SYNOPSIS .Nm fsck_msdos .Fl p -.Ar filesystem -.Ar ... +.Op filesystem +.Op ... .Nm fsck_msdos .Op Fl y .Op Fl n @@ -67,6 +67,15 @@ Options are: assume yes as answer to all questions. .It Em -n assume no as answer to all questions. +.It Em -p +preen filesystems. If no filesystems are specified on the command line, +then all the filesystems from the +.Xr fstab 5 +file with +type msdos and +an +.Xr fsck 8 +pass number greater than zero will be checked. .El .Sh SEE ALSO .Xr fsck 8 , diff --git a/sbin/fsck_msdos/main.c b/sbin/fsck_msdos/main.c index bc35c4afbea6..6175b72788f5 100644 --- a/sbin/fsck_msdos/main.c +++ b/sbin/fsck_msdos/main.c @@ -1,4 +1,4 @@ -/* $NetBSD: main.c,v 1.2 1996/05/25 17:09:47 ws Exp $ */ +/* $NetBSD: main.c,v 1.3 1996/09/11 20:35:14 christos Exp $ */ /* * Copyright (C) 1995 Wolfgang Solfrank @@ -34,7 +34,7 @@ #ifndef lint -static char rcsid[] = "$NetBSD: main.c,v 1.2 1996/05/25 17:09:47 ws Exp $"; +static char rcsid[] = "$NetBSD: main.c,v 1.3 1996/09/11 20:35:14 christos Exp $"; #endif /* not lint */ #include @@ -42,6 +42,7 @@ static char rcsid[] = "$NetBSD: main.c,v 1.2 1996/05/25 17:09:47 ws Exp $"; #include #include #include +#include #include #if __STDC__ #include @@ -57,6 +58,8 @@ int preen; /* set when preening */ int rdonly; /* device is opened read only (supersedes above) */ char *fname; /* filesystem currently checked */ + +static char *rawname __P((const char *)); static void usage() @@ -97,15 +100,43 @@ main(argc, argv) argc -= optind; argv += optind; - if (!argc) - usage(); - - while (argc-- > 0) { - erg = checkfilesys(fname = *argv++); - if (erg > ret) - ret = erg; +#define BADTYPE(type) \ + (strcmp(type, FSTAB_RO) && \ + strcmp(type, FSTAB_RW) && strcmp(type, FSTAB_RQ)) + + if (argc == 0) { + struct fstab *fs; + + if (!preen) + usage(); + + while ((fs = getfsent()) != NULL) { + + if (fs->fs_passno == 0) + continue; + + if (BADTYPE(fs->fs_type)) + continue; + + if (strcmp(fs->fs_vfstype, "msdos")) + continue; + + erg = checkfilesys(fname = rawname(fs->fs_spec)); + + if (erg > ret) + ret = erg; + } + } - exit(ret); + else { + while (argc-- > 0) { + erg = checkfilesys(fname = *argv++); + if (erg > ret) + ret = erg; + } + } + + return ret; } /*VARARGS*/ @@ -230,3 +261,20 @@ ask(def, fmt, va_alist) } while (c != 'y' && c != 'Y' && c != 'n' && c != 'N'); return c == 'y' || c == 'Y'; } + +static char * +rawname(name) + const char *name; +{ + static char rawbuf[32]; + char *dp; + + if ((dp = strrchr(name, '/')) == 0) + return (0); + *dp = 0; + (void)strcpy(rawbuf, name); + *dp = '/'; + (void)strcat(rawbuf, "/r"); + (void)strcat(rawbuf, &dp[1]); + return (rawbuf); +}