1 /* vi: set sw=4 ts=4: */
3 * pfsck --- A generic, parallelizing front-end for the fsck program.
4 * It will automatically try to run fsck programs in parallel if the
5 * devices are on separate spindles. It is based on the same ideas as
6 * the generic front end for fsck by David Engel and Fred van Kempen,
7 * but it has been completely rewritten from scratch to support
10 * Written by Theodore Ts'o, <tytso@mit.edu>
12 * Miquel van Smoorenburg (miquels@drinkel.ow.org) 20-Oct-1994:
13 * o Changed -t fstype to behave like with mount when -A (all file
14 * systems) or -M (like mount) is specified.
15 * o fsck looks if it can find the fsck.type program to decide
16 * if it should ignore the fs type. This way more fsck programs
17 * can be added without changing this front-end.
18 * o -R flag skip root file system.
20 * Copyright (C) 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000,
21 * 2001, 2002, 2003, 2004, 2005 by Theodore Ts'o.
23 * Licensed under GPLv2, see file LICENSE in this source tree.
26 #include <sys/types.h>
42 #include "blkid/blkid.h"
49 #define _PATH_MNTTAB "/etc/fstab"
56 #ifndef DEFAULT_FSTYPE
57 #define DEFAULT_FSTYPE "ext2"
60 #define MAX_DEVICES 32
64 * Internal structure for mount tabel entries.
79 #define FLAG_PROGRESS 2
82 * Structure to allow exit codes to be stored
84 struct fsck_instance
{
93 struct fsck_instance
*next
;
99 * Return the "base device" given a particular device; this is used to
100 * assure that we only fsck one partition on a particular drive at any
101 * one time. Otherwise, the disk heads will be seeking all over the
102 * place. If the base device cannot be determined, return NULL.
104 * The base_device() function returns an allocated string which must
110 #ifdef CONFIG_FEATURE_DEVFS
112 * Required for the uber-silly devfs /dev/ide/host1/bus2/target3/lun3
115 static const char *const devfs_hier
[] = {
116 "host", "bus", "target", "lun", 0
120 static char *base_device(const char *device
)
123 #ifdef CONFIG_FEATURE_DEVFS
124 const char *const *hier
;
129 cp
= str
= xstrdup(device
);
131 /* Skip over /dev/; if it's not present, give up. */
132 if (strncmp(cp
, "/dev/", 5) != 0)
137 * For md devices, we treat them all as if they were all
138 * on one disk, since we don't know how to parallelize them.
140 if (cp
[0] == 'm' && cp
[1] == 'd') {
145 /* Handle DAC 960 devices */
146 if (strncmp(cp
, "rd/", 3) == 0) {
148 if (cp
[0] != 'c' || cp
[2] != 'd' ||
149 !isdigit(cp
[1]) || !isdigit(cp
[3]))
155 /* Now let's handle /dev/hd* and /dev/sd* devices.... */
156 if ((cp
[0] == 'h' || cp
[0] == 's') && (cp
[1] == 'd')) {
158 /* If there's a single number after /dev/hd, skip it */
161 /* What follows must be an alpha char, or give up */
168 #ifdef CONFIG_FEATURE_DEVFS
169 /* Now let's handle devfs (ugh) names */
171 if (strncmp(cp
, "ide/", 4) == 0)
173 if (strncmp(cp
, "scsi/", 5) == 0)
178 * Now we proceed down the expected devfs hierarchy.
179 * i.e., .../host1/bus2/target3/lun4/...
180 * If we don't find the expected token, followed by
181 * some number of digits at each level, abort.
183 for (hier
= devfs_hier
; *hier
; hier
++) {
185 if (strncmp(cp
, *hier
, len
) != 0)
188 while (*cp
!= '/' && *cp
!= 0) {
199 /* Now handle devfs /dev/disc or /dev/disk names */
201 if (strncmp(cp
, "discs/", 6) == 0)
203 else if (strncmp(cp
, "disks/", 6) == 0)
207 if (strncmp(cp
, disk
, 4) != 0)
210 while (*cp
!= '/' && *cp
!= 0) {
226 static const char *const ignored_types
[] = {
238 static const char *const really_wanted
[] = {
249 #define BASE_MD "/dev/md"
252 * Global variables for options
254 static char *devices
[MAX_DEVICES
];
255 static char *args
[MAX_ARGS
];
256 static int num_devices
, num_args
;
260 static int noexecute
;
261 static int serialize
;
262 static int skip_root
;
263 static int like_mount
;
265 static int parallel_root
;
267 static int progress_fd
;
268 static int force_all_parallel
;
269 static int num_running
;
270 static int max_running
;
271 static volatile int cancel_requested
;
272 static int kill_sent
;
274 static struct fs_info
*filesys_info
, *filesys_last
;
275 static struct fsck_instance
*instance_list
;
276 static char *fsck_path
;
277 static blkid_cache cache
;
279 static char *string_copy(const char *s
)
289 static int string_to_int(const char *s
)
294 l
= strtol(s
, &p
, 0);
295 if (*p
|| l
== LONG_MIN
|| l
== LONG_MAX
|| l
< 0 || l
> INT_MAX
)
301 static char *skip_over_blank(char *cp
)
303 while (*cp
&& isspace(*cp
))
308 static char *skip_over_word(char *cp
)
310 while (*cp
&& !isspace(*cp
))
315 static void strip_line(char *line
)
320 p
= line
+ strlen(line
) - 1;
321 if ((*p
== '\n') || (*p
== '\r'))
328 static char *parse_word(char **buf
)
336 word
= skip_over_blank(word
);
337 next
= skip_over_word(word
);
344 static void parse_escape(char *word
)
352 strcpy_and_process_escape_sequences(word
, word
);
355 static void free_instance(struct fsck_instance
*i
)
362 free(i
->base_device
);
366 static struct fs_info
*create_fs_device(const char *device
, const char *mntpnt
,
367 const char *type
, const char *opts
,
368 int freq
, int passno
)
372 fs
= xmalloc(sizeof(struct fs_info
));
374 fs
->device
= string_copy(device
);
375 fs
->mountpt
= string_copy(mntpnt
);
376 fs
->type
= string_copy(type
);
377 fs
->opts
= string_copy(opts
? opts
: "");
386 filesys_last
->next
= fs
;
394 static int parse_fstab_line(char *line
, struct fs_info
**ret_fs
)
396 char *dev
, *device
, *mntpnt
, *type
, *opts
, *freq
, *passno
, *cp
;
401 if ((cp
= strchr(line
, '#')))
402 *cp
= 0; /* Ignore everything after the comment char */
405 device
= parse_word(&cp
);
406 mntpnt
= parse_word(&cp
);
407 type
= parse_word(&cp
);
408 opts
= parse_word(&cp
);
409 freq
= parse_word(&cp
);
410 passno
= parse_word(&cp
);
413 return 0; /* Allow blank lines */
415 if (!mntpnt
|| !type
)
418 parse_escape(device
);
419 parse_escape(mntpnt
);
423 parse_escape(passno
);
425 dev
= blkid_get_devname(cache
, device
, NULL
);
429 if (strchr(type
, ','))
432 fs
= create_fs_device(device
, mntpnt
, type
? type
: "auto", opts
,
433 freq
? atoi(freq
) : -1,
434 passno
? atoi(passno
) : -1);
444 static void interpret_type(struct fs_info
*fs
)
448 if (strcmp(fs
->type
, "auto") != 0)
450 t
= blkid_get_tag_value(cache
, "TYPE", fs
->device
);
458 * Load the filesystem database from /etc/fstab
460 static void load_fs_info(const char *filename
)
468 if ((f
= fopen_or_warn(filename
, "r")) == NULL
) {
473 if (!fgets(buf
, sizeof(buf
), f
))
475 buf
[sizeof(buf
)-1] = 0;
476 if (parse_fstab_line(buf
, &fs
) < 0) {
477 bb_error_msg("WARNING: bad format "
478 "on line %d of %s\n", lineno
, filename
);
493 "WARNING: Your /etc/fstab does not contain the fsck passno\n"
494 " field. I will kludge around things for you, but you\n"
495 " should fix your /etc/fstab file as soon as you can.\n\n", stderr
);
497 for (fs
= filesys_info
; fs
; fs
= fs
->next
) {
503 /* Lookup filesys in /etc/fstab and return the corresponding entry. */
504 static struct fs_info
*lookup(char *filesys
)
508 /* No filesys name given. */
512 for (fs
= filesys_info
; fs
; fs
= fs
->next
) {
513 if (!strcmp(filesys
, fs
->device
) ||
514 (fs
->mountpt
&& !strcmp(filesys
, fs
->mountpt
)))
521 /* Find fsck program for a given fs type. */
522 static char *find_fsck(char *type
)
526 char *p
= string_copy(fsck_path
);
529 /* Are we looking for a program or just a type? */
530 tpl
= (strncmp(type
, "fsck.", 5) ? "%s/fsck.%s" : "%s/%s");
532 for (s
= strtok(p
, ":"); s
; s
= strtok(NULL
, ":")) {
533 s
= xasprintf(tpl
, s
, type
);
534 if (stat(s
, &st
) == 0) break;
541 static int progress_active(void)
543 struct fsck_instance
*inst
;
545 for (inst
= instance_list
; inst
; inst
= inst
->next
) {
546 if (inst
->flags
& FLAG_DONE
)
548 if (inst
->flags
& FLAG_PROGRESS
)
555 * Execute a particular fsck program, and link it into the list of
556 * child processes we are waiting for.
558 static int execute(const char *type
, const char *device
, const char *mntpt
,
564 struct fsck_instance
*inst
, *p
;
567 inst
= xzalloc(sizeof(struct fsck_instance
));
569 prog
= xasprintf("fsck.%s", type
);
573 for (i
=0; i
<num_args
; i
++)
574 argv
[argc
++] = string_copy(args
[i
]);
576 if (progress
&& !progress_active()) {
577 if ((strcmp(type
, "ext2") == 0) ||
578 (strcmp(type
, "ext3") == 0)) {
580 snprintf(tmp
, 80, "-C%d", progress_fd
);
581 argv
[argc
++] = string_copy(tmp
);
582 inst
->flags
|= FLAG_PROGRESS
;
586 argv
[argc
++] = string_copy(device
);
591 bb_error_msg("%s: not found", prog
);
595 if (verbose
|| noexecute
) {
596 printf("[%s (%d) -- %s] ", s
, num_running
,
597 mntpt
? mntpt
: device
);
598 for (i
=0; i
< argc
; i
++)
599 printf("%s ", argv
[i
]);
603 /* Fork and execute the correct program. */
606 else if ((pid
= fork()) < 0) {
609 } else if (pid
== 0) {
612 (void) execv(s
, argv
);
613 bb_simple_perror_msg_and_die(argv
[0]);
616 for (i
= 1; i
< argc
; i
++)
622 inst
->type
= string_copy(type
);
623 inst
->device
= string_copy(device
);
624 inst
->base_device
= base_device(device
);
625 inst
->start_time
= time(0);
629 * Find the end of the list, so we add the instance on at the end.
631 for (p
= instance_list
; p
&& p
->next
; p
= p
->next
);
636 instance_list
= inst
;
642 * Send a signal to all outstanding fsck child processes
644 static int kill_all(int signum
)
646 struct fsck_instance
*inst
;
649 for (inst
= instance_list
; inst
; inst
= inst
->next
) {
650 if (inst
->flags
& FLAG_DONE
)
652 kill(inst
->pid
, signum
);
659 * Wait for one child process to exit; when it does, unlink it from
660 * the list of executing child processes, and return it.
662 static struct fsck_instance
*wait_one(int flags
)
666 struct fsck_instance
*inst
, *inst2
, *prev
;
673 inst
= instance_list
;
676 while (inst
->next
&& (random() & 1)) {
681 inst
->exit_status
= 0;
686 * gcc -Wall fails saving throw against stupidity
687 * (inst and prev are thought to be uninitialized variables)
692 pid
= waitpid(-1, &status
, flags
);
693 if (cancel_requested
&& !kill_sent
) {
697 if ((pid
== 0) && (flags
& WNOHANG
))
700 if ((errno
== EINTR
) || (errno
== EAGAIN
))
702 if (errno
== ECHILD
) {
703 bb_error_msg("wait: no more child process?!?");
709 for (prev
= 0, inst
= instance_list
;
711 prev
= inst
, inst
= inst
->next
) {
712 if (inst
->pid
== pid
)
717 if (WIFEXITED(status
))
718 status
= WEXITSTATUS(status
);
719 else if (WIFSIGNALED(status
)) {
720 sig
= WTERMSIG(status
);
722 status
= EXIT_UNCORRECTED
;
724 printf("Warning... %s for device %s exited "
726 inst
->prog
, inst
->device
, sig
);
730 printf("%s %s: status is %x, should never happen.\n",
731 inst
->prog
, inst
->device
, status
);
734 inst
->exit_status
= status
;
735 if (progress
&& (inst
->flags
& FLAG_PROGRESS
) &&
736 !progress_active()) {
737 for (inst2
= instance_list
; inst2
; inst2
= inst2
->next
) {
738 if (inst2
->flags
& FLAG_DONE
)
740 if (strcmp(inst2
->type
, "ext2") &&
741 strcmp(inst2
->type
, "ext3"))
744 * If we've just started the fsck, wait a tiny
745 * bit before sending the kill, to give it
746 * time to set up the signal handler
748 if (inst2
->start_time
< time(0)+2) {
751 kill(inst2
->pid
, SIGUSR1
);
755 kill(inst2
->pid
, SIGUSR1
);
756 inst2
->flags
|= FLAG_PROGRESS
;
762 prev
->next
= inst
->next
;
764 instance_list
= inst
->next
;
766 printf("Finished with %s (exit status %d)\n",
767 inst
->device
, inst
->exit_status
);
772 #define FLAG_WAIT_ALL 0
773 #define FLAG_WAIT_ATLEAST_ONE 1
775 * Wait until all executing child processes have exited; return the
776 * logical OR of all of their exit code values.
778 static int wait_many(int flags
)
780 struct fsck_instance
*inst
;
781 int global_status
= 0;
784 while ((inst
= wait_one(wait_flags
))) {
785 global_status
|= inst
->exit_status
;
788 if (noexecute
&& (flags
& WNOHANG
) && !(random() % 3))
791 if (flags
& FLAG_WAIT_ATLEAST_ONE
)
792 wait_flags
= WNOHANG
;
794 return global_status
;
798 * Run the fsck program on a particular device
800 * If the type is specified using -t, and it isn't prefixed with "no"
801 * (as in "noext2") and only one filesystem type is specified, then
802 * use that type regardless of what is specified in /etc/fstab.
804 * If the type isn't specified by the user, then use either the type
805 * specified in /etc/fstab, or DEFAULT_FSTYPE.
807 static void fsck_device(struct fs_info
*fs
, int interactive
)
814 if (strcmp(fs
->type
, "auto") != 0)
816 else if (fstype
&& strncmp(fstype
, "no", 2) &&
817 strncmp(fstype
, "opts=", 5) && strncmp(fstype
, "loop", 4) &&
818 !strchr(fstype
, ','))
821 type
= DEFAULT_FSTYPE
;
824 retval
= execute(type
, fs
->device
, fs
->mountpt
, interactive
);
826 bb_error_msg("error %d while executing fsck.%s for %s",
827 retval
, type
, fs
->device
);
834 * Deal with the fsck -t argument.
836 struct fs_type_compile
{
842 #define FS_TYPE_NORMAL 0
843 #define FS_TYPE_OPT 1
844 #define FS_TYPE_NEGOPT 2
846 static const char fs_type_syntax_error
[] =
847 "Either all or none of the filesystem types passed to -t must be prefixed\n"
850 static void compile_fs_type(char *fs_type
, struct fs_type_compile
*cmp
)
854 int negate
, first_negate
= 1;
857 for (cp
=fs_type
; *cp
; cp
++) {
863 cmp
->list
= xzalloc(num
* sizeof(char *));
864 cmp
->type
= xzalloc(num
* sizeof(int));
870 list
= string_copy(fs_type
);
872 s
= strtok(list
, ",");
875 if (strncmp(s
, "no", 2) == 0) {
878 } else if (*s
== '!') {
882 if (strcmp(s
, "loop") == 0)
883 /* loop is really short-hand for opts=loop */
884 goto loop_special_case
;
885 else if (strncmp(s
, "opts=", 5) == 0) {
888 cmp
->type
[num
] = negate
? FS_TYPE_NEGOPT
: FS_TYPE_OPT
;
891 cmp
->negate
= negate
;
894 if ((negate
&& !cmp
->negate
) ||
895 (!negate
&& cmp
->negate
)) {
896 bb_error_msg_and_die("%s", fs_type_syntax_error
);
899 cmp
->list
[num
++] = string_copy(s
);
900 s
= strtok(NULL
, ",");
906 * This function returns true if a particular option appears in a
907 * comma-delimited options list
909 static int opt_in_list(char *opt
, char *optlist
)
915 list
= string_copy(optlist
);
917 s
= strtok(list
, ",");
919 if (strcmp(s
, opt
) == 0) {
923 s
= strtok(NULL
, ",");
929 /* See if the filesystem matches the criteria given by the -t option */
930 static int fs_match(struct fs_info
*fs
, struct fs_type_compile
*cmp
)
932 int n
, ret
= 0, checked_type
= 0;
935 if (cmp
->list
== 0 || cmp
->list
[0] == 0)
938 for (n
=0; (cp
= cmp
->list
[n
]); n
++) {
939 switch (cmp
->type
[n
]) {
942 if (strcmp(cp
, fs
->type
) == 0) {
947 if (opt_in_list(cp
, fs
->opts
))
951 if (!opt_in_list(cp
, fs
->opts
))
956 if (checked_type
== 0)
958 return (cmp
->negate
? !ret
: ret
);
961 /* Check if we should ignore this filesystem. */
962 static int ignore(struct fs_info
*fs
)
968 * If the pass number is 0, ignore it.
976 * If a specific fstype is specified, and it doesn't match,
979 if (!fs_match(fs
, &fs_type_compiled
)) return 1;
981 /* Are we ignoring this type? */
982 if (index_in_str_array(ignored_types
, fs
->type
) >= 0)
985 /* Do we really really want to check this fs? */
986 wanted
= index_in_str_array(really_wanted
, fs
->type
) >= 0;
988 /* See if the <fsck.fs> program is available. */
989 s
= find_fsck(fs
->type
);
992 bb_error_msg("can't check %s: fsck.%s not found",
993 fs
->device
, fs
->type
);
998 /* We can and want to check this file system type. */
1003 * Returns TRUE if a partition on the same disk is already being
1006 static int device_already_active(char *device
)
1008 struct fsck_instance
*inst
;
1011 if (force_all_parallel
)
1015 /* Don't check a soft raid disk with any other disk */
1016 if (instance_list
&&
1017 (!strncmp(instance_list
->device
, BASE_MD
, sizeof(BASE_MD
)-1) ||
1018 !strncmp(device
, BASE_MD
, sizeof(BASE_MD
)-1)))
1022 base
= base_device(device
);
1024 * If we don't know the base device, assume that the device is
1025 * already active if there are any fsck instances running.
1028 return (instance_list
!= 0);
1029 for (inst
= instance_list
; inst
; inst
= inst
->next
) {
1030 if (!inst
->base_device
|| !strcmp(base
, inst
->base_device
)) {
1039 /* Check all file systems, using the /etc/fstab table. */
1040 static int check_all(void)
1042 struct fs_info
*fs
= NULL
;
1043 int status
= EXIT_OK
;
1044 int not_done_yet
= 1;
1049 fputs("Checking all file systems.\n", stdout
);
1052 * Do an initial scan over the filesystem; mark filesystems
1053 * which should be ignored as done, and resolve any "auto"
1054 * filesystem types (done as a side-effect of calling ignore()).
1056 for (fs
= filesys_info
; fs
; fs
= fs
->next
) {
1058 fs
->flags
|= FLAG_DONE
;
1062 * Find and check the root filesystem.
1064 if (!parallel_root
) {
1065 for (fs
= filesys_info
; fs
; fs
= fs
->next
) {
1066 if (LONE_CHAR(fs
->mountpt
, '/'))
1070 if (!skip_root
&& !ignore(fs
)) {
1072 status
|= wait_many(FLAG_WAIT_ALL
);
1073 if (status
> EXIT_NONDESTRUCT
)
1076 fs
->flags
|= FLAG_DONE
;
1080 * This is for the bone-headed user who enters the root
1081 * filesystem twice. Skip root will skep all root entries.
1084 for (fs
= filesys_info
; fs
; fs
= fs
->next
)
1085 if (LONE_CHAR(fs
->mountpt
, '/'))
1086 fs
->flags
|= FLAG_DONE
;
1088 while (not_done_yet
) {
1092 for (fs
= filesys_info
; fs
; fs
= fs
->next
) {
1093 if (cancel_requested
)
1095 if (fs
->flags
& FLAG_DONE
)
1098 * If the filesystem's pass number is higher
1099 * than the current pass number, then we don't
1102 if (fs
->passno
> passno
) {
1107 * If a filesystem on a particular device has
1108 * already been spawned, then we need to defer
1109 * this to another pass.
1111 if (device_already_active(fs
->device
)) {
1116 * Spawn off the fsck process
1118 fsck_device(fs
, serialize
);
1119 fs
->flags
|= FLAG_DONE
;
1122 * Only do one filesystem at a time, or if we
1123 * have a limit on the number of fsck's extant
1124 * at one time, apply that limit.
1127 (max_running
&& (num_running
>= max_running
))) {
1132 if (cancel_requested
)
1135 printf("--waiting-- (pass %d)\n", passno
);
1136 status
|= wait_many(pass_done
? FLAG_WAIT_ALL
:
1137 FLAG_WAIT_ATLEAST_ONE
);
1140 printf("----------------------------------\n");
1145 if (cancel_requested
&& !kill_sent
) {
1149 status
|= wait_many(FLAG_WAIT_ATLEAST_ONE
);
1153 static void signal_cancel(int sig
FSCK_ATTR((unused
)))
1158 static void PRS(int argc
, char **argv
)
1161 char *arg
, *dev
, *tmp
= NULL
;
1164 int opts_for_fsck
= 0;
1165 struct sigaction sa
;
1168 * Set up signal action
1170 memset(&sa
, 0, sizeof(struct sigaction
));
1171 sa
.sa_handler
= signal_cancel
;
1172 sigaction(SIGINT
, &sa
, 0);
1173 sigaction(SIGTERM
, &sa
, 0);
1179 for (i
=1; i
< argc
; i
++) {
1183 if ((arg
[0] == '/' && !opts_for_fsck
) || strchr(arg
, '=')) {
1184 if (num_devices
>= MAX_DEVICES
) {
1185 bb_error_msg_and_die("too many devices");
1187 dev
= blkid_get_devname(cache
, arg
, NULL
);
1188 if (!dev
&& strchr(arg
, '=')) {
1190 * Check to see if we failed because
1191 * /proc/partitions isn't found.
1193 if (access("/proc/partitions", R_OK
) < 0) {
1194 bb_perror_msg_and_die("can't open /proc/partitions "
1195 "(is /proc mounted?)");
1198 * Check to see if this is because
1199 * we're not running as root
1202 bb_error_msg_and_die(
1203 "must be root to scan for matching filesystems: %s\n", arg
);
1205 bb_error_msg_and_die(
1206 "can't find matching filesystem: %s", arg
);
1208 devices
[num_devices
++] = dev
? dev
: string_copy(arg
);
1211 if (arg
[0] != '-' || opts_for_fsck
) {
1212 if (num_args
>= MAX_ARGS
) {
1213 bb_error_msg_and_die("too many arguments");
1215 args
[num_args
++] = string_copy(arg
);
1218 for (j
=1; arg
[j
]; j
++) {
1219 if (opts_for_fsck
) {
1220 options
[++opt
] = arg
[j
];
1230 progress_fd
= string_to_int(arg
+j
+1);
1231 if (progress_fd
< 0)
1235 } else if ((i
+1) < argc
1236 && argv
[i
+1][0] != '-') {
1237 progress_fd
= string_to_int(argv
[i
]);
1238 if (progress_fd
< 0)
1273 else if ((i
+1) < argc
)
1277 fstype
= string_copy(tmp
);
1278 compile_fs_type(fstype
, &fs_type_compiled
);
1287 options
[++opt
] = arg
[j
];
1294 options
[++opt
] = '\0';
1295 if (num_args
>= MAX_ARGS
) {
1296 bb_error_msg("too many arguments");
1298 args
[num_args
++] = string_copy(options
);
1302 if (getenv("FSCK_FORCE_ALL_PARALLEL"))
1303 force_all_parallel
++;
1304 if ((tmp
= getenv("FSCK_MAX_INST")))
1305 max_running
= atoi(tmp
);
1308 int fsck_main(int argc
, char **argv
) MAIN_EXTERNALLY_VISIBLE
;
1309 int fsck_main(int argc
, char **argv
)
1312 int interactive
= 0;
1316 setvbuf(stdout
, NULL
, _IONBF
, BUFSIZ
);
1317 setvbuf(stderr
, NULL
, _IONBF
, BUFSIZ
);
1319 blkid_get_cache(&cache
, NULL
);
1323 printf("fsck %s (%s)\n", E2FSPROGS_VERSION
, E2FSPROGS_DATE
);
1325 fstab
= getenv("FSTAB_FILE");
1327 fstab
= _PATH_MNTTAB
;
1328 load_fs_info(fstab
);
1330 fsck_path
= e2fs_set_sbin_path();
1332 if ((num_devices
== 1) || (serialize
))
1335 /* If -A was specified ("check all"), do that! */
1339 if (num_devices
== 0) {
1344 for (i
= 0; i
< num_devices
; i
++) {
1345 if (cancel_requested
) {
1352 fs
= lookup(devices
[i
]);
1354 fs
= create_fs_device(devices
[i
], 0, "auto",
1359 fsck_device(fs
, interactive
);
1361 (max_running
&& (num_running
>= max_running
))) {
1362 struct fsck_instance
*inst
;
1366 status
|= inst
->exit_status
;
1367 free_instance(inst
);
1370 printf("----------------------------------\n");
1373 status
|= wait_many(FLAG_WAIT_ALL
);
1374 blkid_put_cache(cache
);