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.
14 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
15 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
16 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
17 * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
18 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
19 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
20 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
21 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 #include <sys/cdefs.h>
29 __RCSID("$NetBSD: main.c,v 1.10 1997/10/01 02:18:14 enami Exp $");
30 static const char rcsid[] =
44 int alwaysno; /* assume "no" for all questions */
45 int alwaysyes; /* assume "yes" for all questions */
46 int preen; /* set when preening */
47 int rdonly; /* device is opened read only (supersedes above) */
48 int skipclean; /* skip clean file systems if preening */
50 static void usage(void) __dead2;
56 fprintf(stderr, "%s\n%s\n",
57 "usage: fsck_msdosfs -p [-f] filesystem ...",
58 " fsck_msdosfs [-ny] filesystem ...");
63 main(int argc, char **argv)
69 while ((ch = getopt(argc, argv, "CfFnpy")) != -1) {
71 case 'C': /* for fsck_ffs compatibility */
78 * We can never run in the background. We must exit
79 * silently with a nonzero exit code so that fsck(8)
80 * can probe our support for -F. The exit code
81 * doesn't really matter, but we use an unusual one
82 * in case someone tries -F directly. The -F flag
83 * is intentionally left out of the usage message.
88 alwaysyes = preen = 0;
97 alwaysyes = alwaysno = 0;
111 while (--argc >= 0) {
112 setcdevname(*argv, preen);
113 erg = checkfilesys(*argv++);
124 ask(int def, const char *fmt, ...)
140 vsnprintf(prompt, sizeof(prompt), fmt, ap);
141 if (alwaysyes || rdonly) {
142 printf("%s? %s\n", prompt, rdonly ? "no" : "yes");
146 printf("%s? [yn] ", prompt);
149 while (c != '\n' && getchar() != '\n')
152 } while (c != 'y' && c != 'Y' && c != 'n' && c != 'N');
153 return c == 'y' || c == 'Y';