2 * Copyright (C) 1995 Wolfgang Solfrank
3 * Copyright (c) 1995 Martin Husemann
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Martin Husemann
16 * and Wolfgang Solfrank.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
22 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
23 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
24 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
26 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
27 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
28 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
29 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
30 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include <sys/cdefs.h>
36 __RCSID("$NetBSD: main.c,v 1.10 1997/10/01 02:18:14 enami Exp $");
37 static const char rcsid[] =
52 int alwaysno; /* assume "no" for all questions */
53 int alwaysyes; /* assume "yes" for all questions */
54 int preen; /* set when preening */
55 int rdonly; /* device is opened read only (supersedes above) */
56 int skipclean; /* skip clean file systems if preening */
58 static void usage(void) __dead2;
64 fprintf(stderr, "%s\n%s\n",
65 "usage: fsck_msdosfs -p [-f] filesystem ...",
66 " fsck_msdosfs [-ny] filesystem ...");
71 main(int argc, char **argv)
77 while ((ch = getopt(argc, argv, "fFnpy")) != -1) {
84 * We can never run in the background. We must exit
85 * silently with a nonzero exit code so that fsck(8)
86 * can probe our support for -F. The exit code
87 * doesn't really matter, but we use an unusual one
88 * in case someone tries -F directly. The -F flag
89 * is intentionally left out of the usage message.
94 alwaysyes = preen = 0;
103 alwaysyes = alwaysno = 0;
117 while (--argc >= 0) {
118 setcdevname(*argv, preen);
119 erg = checkfilesys(*argv++);
130 ask(int def, const char *fmt, ...)
146 vsnprintf(prompt, sizeof(prompt), fmt, ap);
147 if (alwaysyes || rdonly) {
148 printf("%s? %s\n", prompt, rdonly ? "no" : "yes");
152 printf("%s? [yn] ", prompt);
155 while (c != '\n' && getchar() != '\n')
158 } while (c != 'y' && c != 'Y' && c != 'n' && c != 'N');
159 return c == 'y' || c == 'Y';