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[] =
45 int alwaysno; /* assume "no" for all questions */
46 int alwaysyes; /* assume "yes" for all questions */
47 int preen; /* set when preening */
48 int rdonly; /* device is opened read only (supersedes above) */
49 int skipclean; /* skip clean file systems if preening */
51 static void usage(void) __dead2;
57 fprintf(stderr, "%s\n%s\n",
58 "usage: fsck_msdosfs -p [-f] filesystem ...",
59 " fsck_msdosfs [-ny] filesystem ...");
64 main(int argc, char **argv)
70 while ((ch = getopt(argc, argv, "CfFnpy")) != -1) {
72 case 'C': /* for fsck_ffs compatibility */
79 * We can never run in the background. We must exit
80 * silently with a nonzero exit code so that fsck(8)
81 * can probe our support for -F. The exit code
82 * doesn't really matter, but we use an unusual one
83 * in case someone tries -F directly. The -F flag
84 * is intentionally left out of the usage message.
89 alwaysyes = preen = 0;
98 alwaysyes = alwaysno = 0;
112 while (--argc >= 0) {
113 setcdevname(*argv, preen);
114 erg = checkfilesys(*argv++);
125 ask(int def, const char *fmt, ...)
141 vsnprintf(prompt, sizeof(prompt), fmt, ap);
142 if (alwaysyes || rdonly) {
143 printf("%s? %s\n", prompt, rdonly ? "no" : "yes");
147 printf("%s? [yn] ", prompt);
150 while (c != '\n' && getchar() != '\n')
153 } while (c != 'y' && c != 'Y' && c != 'n' && c != 'N');
154 return c == 'y' || c == 'Y';