Ignore:
Timestamp:
Feb 25, 2011, 9:26:54 PM (13 years ago)
Author:
Bruno Cornec
Message:
  • Update mindi-busybox to 1.18.3 to avoid problems with the tar command which is now failing on recent versions with busybox 1.7.3
File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2.2.9/mindi-busybox/e2fsprogs/fsck.c

    r1765 r2725  
    2121 *      2001, 2002, 2003, 2004, 2005 by  Theodore Ts'o.
    2222 *
    23  * %Begin-Header%
    24  * This file may be redistributed under the terms of the GNU Public
    25  * License.
    26  * %End-Header%
     23 * Licensed under GPLv2, see file LICENSE in this source tree.
    2724 */
    2825
     
    4037#include "libbb.h"
    4138
     39/* "progress indicator" code is somewhat buggy and ext[23] specific.
     40 * We should be filesystem agnostic. IOW: there should be a well-defined
     41 * API for fsck.something, NOT ad-hoc hacks in generic fsck. */
     42#define DO_PROGRESS_INDICATOR 0
     43
     44/* fsck 1.41.4 (27-Jan-2009) manpage says:
     45 * 0   - No errors
     46 * 1   - File system errors corrected
     47 * 2   - System should be rebooted
     48 * 4   - File system errors left uncorrected
     49 * 8   - Operational error
     50 * 16  - Usage or syntax error
     51 * 32  - Fsck canceled by user request
     52 * 128 - Shared library error
     53 */
    4254#define EXIT_OK          0
    4355#define EXIT_NONDESTRUCT 1
     
    5163 * Internal structure for mount table entries.
    5264 */
    53 
    5465struct fs_info {
    5566    struct fs_info *next;
     
    5869    char    *type;
    5970    char    *opts;
    60     int freq;
    6171    int passno;
    6272    int flags;
     
    7282    int pid;
    7383    int flags;
    74     int exit_status;
     84#if DO_PROGRESS_INDICATOR
    7585    time_t  start_time;
     86#endif
    7687    char    *prog;
    77     char    *type;
    7888    char    *device;
    7989    char    *base_device; /* /dev/hda for /dev/hdaN etc */
     
    103113#define BASE_MD "/dev/md"
    104114
    105 static char **devices;
    106115static char **args;
    107 static int num_devices;
    108116static int num_args;
    109117static int verbose;
     
    116124static smallint fs_type_negated;
    117125
    118 static volatile smallint cancel_requested;
    119 static smallint doall;
    120126static smallint noexecute;
    121127static smallint serialize;
    122128static smallint skip_root;
    123129/* static smallint like_mount; */
    124 static smallint notitle;
    125130static smallint parallel_root;
    126131static smallint force_all_parallel;
    127132
    128 /* "progress indicator" code is somewhat buggy and ext[23] specific.
    129  * We should be filesystem agnostic. IOW: there should be a well-defined
    130  * API for fsck.something, NOT ad-hoc hacks in generic fsck. */
    131 #define DO_PROGRESS_INDICATOR 0
    132133#if DO_PROGRESS_INDICATOR
    133134static smallint progress;
     
    169170    int len;
    170171#endif
    171     cp = str = xstrdup(device);
    172 
    173     /* Skip over /dev/; if it's not present, give up. */
    174     if (strncmp(cp, "/dev/", 5) != 0)
     172    str = xstrdup(device);
     173
     174    /* Skip over "/dev/"; if it's not present, give up */
     175    cp = skip_dev_pfx(str);
     176    if (cp == str)
    175177        goto errout;
    176     cp += 5;
    177178
    178179    /*
     
    274275static struct fs_info *create_fs_device(const char *device, const char *mntpnt,
    275276                    const char *type, const char *opts,
    276                     int freq, int passno)
     277                    int passno)
    277278{
    278279    struct fs_info *fs;
     
    281282    fs->device = xstrdup(device);
    282283    fs->mountpt = xstrdup(mntpnt);
     284    if (strchr(type, ','))
     285        type = (char *)"auto";
    283286    fs->type = xstrdup(type);
    284287    fs->opts = xstrdup(opts ? opts : "");
    285     fs->freq = freq;
    286     fs->passno = passno;
     288    fs->passno = passno < 0 ? 1 : passno;
    287289    /*fs->flags = 0; */
    288290    /*fs->next = NULL; */
     
    297299}
    298300
    299 static void strip_line(char *line)
    300 {
    301     char *p = line + strlen(line) - 1;
    302 
    303     while (*line) {
    304         if (*p != '\n' && *p != '\r')
    305             break;
    306         *p-- = '\0';
    307     }
    308 }
    309 
    310 static char *parse_word(char **buf)
    311 {
    312     char *word, *next;
    313 
    314     word = *buf;
    315     if (*word == '\0')
    316         return NULL;
    317 
    318     word = skip_whitespace(word);
    319     next = skip_non_whitespace(word);
    320     if (*next)
    321         *next++ = '\0';
    322     *buf = next;
    323     return word;
    324 }
    325 
    326 static void parse_escape(char *word)
    327 {
    328     char *q, c;
    329     const char *p;
    330 
    331     if (!word)
    332         return;
    333 
    334     for (p = q = word; *p; q++) {
    335         c = *p++;
    336         if (c != '\\') {
    337             *q = c;
    338         } else {
    339             *q = bb_process_escape_sequence(&p);
    340         }
    341     }
    342     *q = '\0';
    343 }
    344 
    345 static int parse_fstab_line(char *line, struct fs_info **ret_fs)
    346 {
    347     char *device, *mntpnt, *type, *opts, *freq, *passno, *cp;
    348     struct fs_info *fs;
    349 
    350     *ret_fs = 0;
    351     strip_line(line);
    352     cp = strchr(line, '#');
    353     if (cp)
    354         *cp = '\0'; /* Ignore everything after the comment char */
    355     cp = line;
    356 
    357     device = parse_word(&cp);
    358     if (!device) return 0; /* Allow blank lines */
    359     mntpnt = parse_word(&cp);
    360     type = parse_word(&cp);
    361     opts = parse_word(&cp);
    362     freq = parse_word(&cp);
    363     passno = parse_word(&cp);
    364 
    365     if (!mntpnt || !type)
    366         return -1;
    367 
    368     parse_escape(device);
    369     parse_escape(mntpnt);
    370     parse_escape(type);
    371     parse_escape(opts);
    372     parse_escape(freq);
    373     parse_escape(passno);
    374 
    375     if (strchr(type, ','))
    376         type = NULL;
    377 
    378     fs = create_fs_device(device, mntpnt, type ? type : "auto", opts,
    379                 freq ? atoi(freq) : -1,
    380                 passno ? atoi(passno) : -1);
    381     *ret_fs = fs;
    382     return 0;
    383 }
    384 
    385301/* Load the filesystem database from /etc/fstab */
    386302static void load_fs_info(const char *filename)
    387303{
    388     FILE *f;
    389     int lineno = 0;
    390     int old_fstab = 1;
     304    FILE *fstab;
     305    struct mntent mte;
    391306    struct fs_info *fs;
    392307
    393     f = fopen_or_warn(filename, "r");
    394     if (f == NULL) {
     308    fstab = setmntent(filename, "r");
     309    if (!fstab) {
     310        bb_perror_msg("can't read '%s'", filename);
    395311        return;
    396312    }
    397     while (1) {
    398         int r;
    399         char *buf = xmalloc_getline(f);
    400         if (!buf) break;
    401         r = parse_fstab_line(buf, &fs);
    402         free(buf);
    403         lineno++;
    404         if (r < 0) {
    405             bb_error_msg("WARNING: bad format "
    406                 "on line %d of %s", lineno, filename);
    407             continue;
    408         }
    409         if (!fs)
    410             continue;
    411         if (fs->passno < 0)
    412             fs->passno = 0;
    413         else
    414             old_fstab = 0;
    415     }
    416     fclose(f);
    417 
    418     if (old_fstab) {
    419         fputs("\007"
    420 "WARNING: Your /etc/fstab does not contain the fsck passno field.\n"
    421 "I will kludge around things for you, but you should fix\n"
    422 "your /etc/fstab file as soon as you can.\n\n", stderr);
    423         for (fs = filesys_info; fs; fs = fs->next) {
    424             fs->passno = 1;
    425         }
    426     }
     313
     314    // Loop through entries
     315    while (getmntent_r(fstab, &mte, bb_common_bufsiz1, COMMON_BUFSIZE)) {
     316        //bb_info_msg("CREATE[%s][%s][%s][%s][%d]", mte.mnt_fsname, mte.mnt_dir,
     317        //  mte.mnt_type, mte.mnt_opts,
     318        //  mte.mnt_passno);
     319        fs = create_fs_device(mte.mnt_fsname, mte.mnt_dir,
     320            mte.mnt_type, mte.mnt_opts,
     321            mte.mnt_passno);
     322    }
     323    endmntent(fstab);
    427324}
    428325
     
    461358 * Send a signal to all outstanding fsck child processes
    462359 */
    463 static void kill_all_if_cancel_requested(void)
     360static void kill_all_if_got_signal(void)
    464361{
    465362    static smallint kill_sent;
     
    467364    struct fsck_instance *inst;
    468365
    469     if (!cancel_requested || kill_sent)
     366    if (!bb_got_signal || kill_sent)
    470367        return;
    471368
     
    480377/*
    481378 * Wait for one child process to exit; when it does, unlink it from
    482  * the list of executing child processes, and return it.
    483  */
    484 static struct fsck_instance *wait_one(int flags)
     379 * the list of executing child processes, free, and return its exit status.
     380 * If there is no exited child, return -1.
     381 */
     382static int wait_one(int flags)
    485383{
    486384    int status;
     
    490388
    491389    if (!instance_list)
    492         return NULL;
    493 
    494     if (noexecute) {
    495         inst = instance_list;
    496         prev = NULL;
    497 #ifdef RANDOM_DEBUG
    498         while (inst->next && (random() & 1)) {
    499             prev = inst;
    500             inst = inst->next;
    501         }
    502 #endif
    503         inst->exit_status = 0;
    504         goto ret_inst;
    505     }
    506 
    507     inst = prev = NULL; /* for gcc */
    508     do {
     390        return -1;
     391    /* if (noexecute) { already returned -1; } */
     392
     393    while (1) {
    509394        pid = waitpid(-1, &status, flags);
    510         kill_all_if_cancel_requested();
    511         if (pid == 0 && (flags & WNOHANG))
    512             return NULL;
     395        kill_all_if_got_signal();
     396        if (pid == 0) /* flags == WNOHANG and no children exited */
     397            return -1;
    513398        if (pid < 0) {
    514             if (errno == EINTR || errno == EAGAIN)
     399            if (errno == EINTR)
    515400                continue;
    516             if (errno == ECHILD) {
    517                 bb_error_msg("wait: no more child process?!?");
    518                 return NULL;
     401            if (errno == ECHILD) { /* paranoia */
     402                bb_error_msg("wait: no more children");
     403                return -1;
    519404            }
    520405            bb_perror_msg("wait");
     
    523408        prev = NULL;
    524409        inst = instance_list;
    525         while (inst) {
     410        do {
    526411            if (inst->pid == pid)
    527                 break;
     412                goto child_died;
    528413            prev = inst;
    529414            inst = inst->next;
    530         }
    531     } while (!inst);
     415        } while (inst);
     416    }
     417 child_died:
    532418
    533419    if (WIFEXITED(status))
     
    537423        status = EXIT_UNCORRECTED;
    538424        if (sig != SIGINT) {
    539             printf("Warning... %s %s exited "
    540                 "with signal %d\n",
     425            printf("Warning: %s %s terminated "
     426                "by signal %d\n",
    541427                inst->prog, inst->device, sig);
    542428            status = EXIT_ERROR;
     
    547433        status = EXIT_ERROR;
    548434    }
    549     inst->exit_status = status;
    550435
    551436#if DO_PROGRESS_INDICATOR
     
    576461#endif
    577462
    578  ret_inst:
    579463    if (prev)
    580464        prev->next = inst->next;
     
    583467    if (verbose > 1)
    584468        printf("Finished with %s (exit status %d)\n",
    585                inst->device, inst->exit_status);
     469               inst->device, status);
    586470    num_running--;
    587     return inst;
    588 }
    589 
    590 #define FLAG_WAIT_ALL           0
    591 #define FLAG_WAIT_ATLEAST_ONE   1
     471    free_instance(inst);
     472
     473    return status;
     474}
     475
    592476/*
    593477 * Wait until all executing child processes have exited; return the
    594478 * logical OR of all of their exit code values.
    595479 */
     480#define FLAG_WAIT_ALL           0
     481#define FLAG_WAIT_ATLEAST_ONE   WNOHANG
    596482static int wait_many(int flags)
    597483{
    598     struct fsck_instance *inst;
     484    int exit_status;
    599485    int global_status = 0;
    600486    int wait_flags = 0;
    601487
    602     while ((inst = wait_one(wait_flags))) {
    603         global_status |= inst->exit_status;
    604         free_instance(inst);
    605 #ifdef RANDOM_DEBUG
    606         if (noexecute && (flags & WNOHANG) && !(random() % 3))
    607             break;
    608 #endif
    609         if (flags & FLAG_WAIT_ATLEAST_ONE)
    610             wait_flags = WNOHANG;
     488    while ((exit_status = wait_one(wait_flags)) != -1) {
     489        global_status |= exit_status;
     490        wait_flags |= flags;
    611491    }
    612492    return global_status;
     
    617497 * child processes we are waiting for.
    618498 */
    619 static void execute(const char *type, const char *device, const char *mntpt,
    620         int interactive)
    621 {
    622     char *argv[num_args + 4]; /* see count below: */
    623     int argc;
     499static void execute(const char *type, const char *device,
     500        const char *mntpt /*, int interactive */)
     501{
    624502    int i;
    625503    struct fsck_instance *inst;
    626504    pid_t pid;
    627505
    628     inst = xzalloc(sizeof(*inst));
    629 
    630     argv[0] = xasprintf("fsck.%s", type); /* 1 */
    631     for (i = 0; i < num_args; i++)
    632         argv[i+1] = args[i]; /* num_args */
    633     argc = num_args + 1;
     506    args[0] = xasprintf("fsck.%s", type);
    634507
    635508#if DO_PROGRESS_INDICATOR
     
    638511         || strcmp(type, "ext3") == 0
    639512        ) {
    640             argv[argc++] = xasprintf("-C%d", progress_fd); /* 1 */
     513            args[XXX] = xasprintf("-C%d", progress_fd); /* 1 */
    641514            inst->flags |= FLAG_PROGRESS;
    642515        }
     
    644517#endif
    645518
    646     argv[argc++] = xstrdup(device); /* 1 */
    647     argv[argc] = NULL; /* 1 */
     519    args[num_args - 2] = (char*)device;
     520    /* args[num_args - 1] = NULL; - already is */
    648521
    649522    if (verbose || noexecute) {
    650         printf("[%s (%d) -- %s]", argv[0], num_running,
     523        printf("[%s (%d) -- %s]", args[0], num_running,
    651524                    mntpt ? mntpt : device);
    652         for (i = 0; i < argc; i++)
    653             printf(" %s", argv[i]);
    654         puts("");
     525        for (i = 0; args[i]; i++)
     526            printf(" %s", args[i]);
     527        bb_putchar('\n');
    655528    }
    656529
     
    658531    pid = -1;
    659532    if (!noexecute) {
    660         pid = spawn(argv);
     533        pid = spawn(args);
    661534        if (pid < 0)
    662             bb_perror_msg("%s", argv[0]);
    663     }
    664 
    665     for (i = num_args+1; i < argc; i++)
    666         free(argv[i]);
    667 
     535            bb_simple_perror_msg(args[0]);
     536    }
     537
     538#if DO_PROGRESS_INDICATOR
     539    free(args[XXX]);
     540#endif
     541
     542    /* No child, so don't record an instance */
     543    if (pid <= 0) {
     544        free(args[0]);
     545        return;
     546    }
     547
     548    inst = xzalloc(sizeof(*inst));
    668549    inst->pid = pid;
    669     inst->prog = argv[0];
    670     inst->type = xstrdup(type);
     550    inst->prog = args[0];
    671551    inst->device = xstrdup(device);
    672552    inst->base_device = base_device(device);
     553#if DO_PROGRESS_INDICATOR
    673554    inst->start_time = time(NULL);
     555#endif
    674556
    675557    /* Add to the list of running fsck's.
     
    689571 * specified in /etc/fstab, or "auto".
    690572 */
    691 static void fsck_device(struct fs_info *fs, int interactive)
     573static void fsck_device(struct fs_info *fs /*, int interactive */)
    692574{
    693575    const char *type;
     
    716598
    717599    num_running++;
    718     execute(type, fs->device, fs->mountpt, interactive);
     600    execute(type, fs->device, fs->mountpt /*, interactive */);
    719601}
    720602
     
    868750     * filesystem types (done as a side-effect of calling ignore()).
    869751     */
    870     for (fs = filesys_info; fs; fs = fs->next) {
     752    for (fs = filesys_info; fs; fs = fs->next)
    871753        if (ignore(fs))
    872754            fs->flags |= FLAG_DONE;
    873     }
    874755
    875756    /*
     
    878759    if (!parallel_root) {
    879760        for (fs = filesys_info; fs; fs = fs->next) {
    880             if (LONE_CHAR(fs->mountpt, '/'))
    881                 break;
    882         }
    883         if (fs) {
    884             if (!skip_root && !ignore(fs)) {
    885                 fsck_device(fs, 1);
    886                 status |= wait_many(FLAG_WAIT_ALL);
    887                 if (status > EXIT_NONDESTRUCT)
    888                     return status;
     761            if (LONE_CHAR(fs->mountpt, '/')) {
     762                if (!skip_root && !ignore(fs)) {
     763                    fsck_device(fs /*, 1*/);
     764                    status |= wait_many(FLAG_WAIT_ALL);
     765                    if (status > EXIT_NONDESTRUCT)
     766                        return status;
     767                }
     768                fs->flags |= FLAG_DONE;
     769                break;
    889770            }
    890             fs->flags |= FLAG_DONE;
    891771        }
    892772    }
    893773    /*
    894      * This is for the bone-headed user who enters the root
    895      * filesystem twice.  Skip root will skip all root entries.
     774     * This is for the bone-headed user who has root
     775     * filesystem listed twice.
     776     * "Skip root" will skip _all_ root entries.
    896777     */
    897778    if (skip_root)
     
    907788
    908789        for (fs = filesys_info; fs; fs = fs->next) {
    909             if (cancel_requested)
     790            if (bb_got_signal)
    910791                break;
    911792            if (fs->flags & FLAG_DONE)
     
    913794            /*
    914795             * If the filesystem's pass number is higher
    915              * than the current pass number, then we don't
     796             * than the current pass number, then we didn't
    916797             * do it yet.
    917798             */
     
    932813             * Spawn off the fsck process
    933814             */
    934             fsck_device(fs, serialize);
     815            fsck_device(fs /*, serialize*/);
    935816            fs->flags |= FLAG_DONE;
    936817
     
    947828            }
    948829        }
    949         if (cancel_requested)
     830        if (bb_got_signal)
    950831            break;
    951832        if (verbose > 1)
     
    960841            not_done_yet = 1;
    961842    }
    962     kill_all_if_cancel_requested();
     843    kill_all_if_got_signal();
    963844    status |= wait_many(FLAG_WAIT_ATLEAST_ONE);
    964845    return status;
     
    976857    smallint negate;
    977858
    978     if (fs_type) {
    979         s = fs_type;
    980         while ((s = strchr(s, ','))) {
    981             num++;
    982             s++;
    983         }
     859    s = fs_type;
     860    while ((s = strchr(s, ','))) {
     861        num++;
     862        s++;
    984863    }
    985864
     
    987866    fs_type_flag = xzalloc(num * sizeof(fs_type_flag[0]));
    988867    fs_type_negated = -1; /* not yet known is it negated or not */
    989 
    990     if (!fs_type)
    991         return;
    992868
    993869    num = 0;
     
    1028904}
    1029905
    1030 static void parse_args(int argc, char **argv)
    1031 {
    1032     int i, j;
    1033     char *arg, *tmp;
    1034     char *options = NULL;
    1035     int optpos = 0;
    1036     int opts_for_fsck = 0;
    1037 
    1038     /* in bss, so already zeroed
     906static char **new_args(void)
     907{
     908    args = xrealloc_vector(args, 2, num_args);
     909    return &args[num_args++];
     910}
     911
     912int fsck_main(int argc, char **argv) MAIN_EXTERNALLY_VISIBLE;
     913int fsck_main(int argc UNUSED_PARAM, char **argv)
     914{
     915    int i, status;
     916    /*int interactive;*/
     917    struct fs_info *fs;
     918    const char *fstab;
     919    char *tmp;
     920    char **devices;
     921    int num_devices;
     922    smallint opts_for_fsck;
     923    smallint doall;
     924    smallint notitle;
     925
     926    /* we want wait() to be interruptible */
     927    signal_no_SA_RESTART_empty_mask(SIGINT, record_signo);
     928    signal_no_SA_RESTART_empty_mask(SIGTERM, record_signo);
     929
     930    setbuf(stdout, NULL);
     931
     932    opts_for_fsck = doall = notitle = 0;
     933    devices = NULL;
    1039934    num_devices = 0;
    1040     num_args = 0;
    1041     instance_list = NULL;
    1042     */
    1043 
    1044 /* TODO: getopt32 */
    1045     for (i = 1; i < argc; i++) {
    1046         arg = argv[i];
     935    new_args(); /* args[0] = NULL, will be replaced by fsck.<type> */
     936    /* instance_list = NULL; - in bss, so already zeroed */
     937
     938    while (*++argv) {
     939        int j;
     940        int optpos;
     941        char *options;
     942        char *arg = *argv;
    1047943
    1048944        /* "/dev/blk" or "/path" or "UUID=xxx" or "LABEL=xxx" */
     
    1051947// "/path", "UUID=xxx" or "LABEL=xxx" into block device name
    1052948// ("UUID=xxx"/"LABEL=xxx" can probably shifted to fsck.auto duties)
    1053             devices = xrealloc(devices, (num_devices+1) * sizeof(devices[0]));
    1054             devices[num_devices++] = xstrdup(arg);
     949            devices = xrealloc_vector(devices, 2, num_devices);
     950            devices[num_devices++] = arg;
    1055951            continue;
    1056952        }
    1057953
    1058954        if (arg[0] != '-' || opts_for_fsck) {
    1059             args = xrealloc(args, (num_args+1) * sizeof(args[0]));
    1060             args[num_args++] = xstrdup(arg);
     955            *new_args() = arg;
    1061956            continue;
    1062957        }
    1063958
     959        if (LONE_CHAR(arg + 1, '-')) { /* "--" ? */
     960            opts_for_fsck = 1;
     961            continue;
     962        }
     963
     964        optpos = 0;
     965        options = NULL;
    1064966        for (j = 1; arg[j]; j++) {
    1065             if (opts_for_fsck) {
    1066                 optpos++;
    1067                 /* one extra for '\0' */
    1068                 options = xrealloc(options, optpos + 2);
    1069                 options[optpos] = arg[j];
    1070                 continue;
    1071             }
    1072967            switch (arg[j]) {
    1073968            case 'A':
     
    1078973                progress = 1;
    1079974                if (arg[++j]) { /* -Cn */
    1080                     progress_fd = xatoi_u(&arg[j]);
     975                    progress_fd = xatoi_positive(&arg[j]);
    1081976                    goto next_arg;
    1082977                }
    1083978                /* -C n */
    1084                 progress_fd = xatoi_u(argv[++i]);
     979                if (!*++argv)
     980                    bb_show_usage();
     981                progress_fd = xatoi_positive(*argv);
    1085982                goto next_arg;
    1086983#endif
     
    11111008                if (arg[++j])
    11121009                    tmp = &arg[j];
    1113                 else if (++i < argc)
    1114                     tmp = argv[i];
     1010                else if (*++argv)
     1011                    tmp = *argv;
    11151012                else
    11161013                    bb_show_usage();
     
    11181015                compile_fs_type(fstype);
    11191016                goto next_arg;
    1120             case '-':
    1121                 opts_for_fsck++;
    1122                 break;
    11231017            case '?':
    11241018                bb_show_usage();
     
    11361030            options[0] = '-';
    11371031            options[optpos + 1] = '\0';
    1138             args = xrealloc(args, (num_args+1) * sizeof(args[0]));
    1139             args[num_args++] = options;
    1140             optpos = 0;
    1141             options = NULL;
     1032            *new_args() = options;
    11421033        }
    11431034    }
     
    11471038    if (tmp)
    11481039        max_running = xatoi(tmp);
    1149 }
    1150 
    1151 static void signal_cancel(int sig ATTRIBUTE_UNUSED)
    1152 {
    1153     cancel_requested = 1;
    1154 }
    1155 
    1156 int fsck_main(int argc, char **argv);
    1157 int fsck_main(int argc, char **argv)
    1158 {
    1159     int i, status = 0;
    1160     int interactive;
    1161     const char *fstab;
    1162     struct fs_info *fs;
    1163     struct sigaction sa;
    1164 
    1165     memset(&sa, 0, sizeof(sa));
    1166     sa.sa_handler = signal_cancel;
    1167     sigaction(SIGINT, &sa, 0);
    1168     sigaction(SIGTERM, &sa, 0);
    1169 
    1170     setbuf(stdout, NULL);
    1171 
    1172     parse_args(argc, argv);
     1040    new_args(); /* args[num_args - 2] will be replaced by <device> */
     1041    new_args(); /* args[num_args - 1] is the last, NULL element */
    11731042
    11741043    if (!notitle)
     
    11821051    load_fs_info(fstab);
    11831052
    1184     interactive = (num_devices == 1) | serialize;
    1185 
    1186     /* If -A was specified ("check all"), do that! */
     1053    /*interactive = (num_devices == 1) | serialize;*/
     1054
     1055    if (num_devices == 0)
     1056        /*interactive =*/ serialize = doall = 1;
    11871057    if (doall)
    11881058        return check_all();
    11891059
    1190     if (num_devices == 0) {
    1191         serialize = 1;
    1192         interactive = 1;
    1193         return check_all();
    1194     }
    1195 
     1060    status = 0;
    11961061    for (i = 0; i < num_devices; i++) {
    1197         if (cancel_requested) {
    1198             kill_all_if_cancel_requested();
     1062        if (bb_got_signal) {
     1063            kill_all_if_got_signal();
    11991064            break;
    12001065        }
     
    12021067        fs = lookup(devices[i]);
    12031068        if (!fs)
    1204             fs = create_fs_device(devices[i], 0, "auto", 0, -1, -1);
    1205         fsck_device(fs, interactive);
     1069            fs = create_fs_device(devices[i], "", "auto", NULL, -1);
     1070        fsck_device(fs /*, interactive */);
    12061071
    12071072        if (serialize
    12081073         || (max_running && (num_running >= max_running))
    12091074        ) {
    1210             struct fsck_instance *inst;
    1211 
    1212             inst = wait_one(0);
    1213             if (inst) {
    1214                 status |= inst->exit_status;
    1215                 free_instance(inst);
    1216             }
     1075            int exit_status = wait_one(0);
     1076            if (exit_status >= 0)
     1077                status |= exit_status;
    12171078            if (verbose > 1)
    12181079                puts("----------------------------------");
Note: See TracChangeset for help on using the changeset viewer.