Document -p (preen) option. If there are no filesystems specified on the

command line, get them from /etc/fstab when we are preening.
This commit is contained in:
christos 1996-09-11 20:35:14 +00:00
parent 2842b1a353
commit 74d9e3de3f
2 changed files with 70 additions and 13 deletions

View File

@ -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 ,

View File

@ -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 <stdlib.h>
@ -42,6 +42,7 @@ static char rcsid[] = "$NetBSD: main.c,v 1.2 1996/05/25 17:09:47 ws Exp $";
#include <ctype.h>
#include <stdio.h>
#include <unistd.h>
#include <fstab.h>
#include <errno.h>
#if __STDC__
#include <stdarg.h>
@ -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);
}