]> err.no Git - util-linux/commitdiff
fsck: returns proper code on exec() error
authorKarel Zak <kzak@redhat.com>
Mon, 27 Dec 2010 21:30:24 +0000 (22:30 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 27 Dec 2010 21:31:36 +0000 (22:31 +0100)
# fsck -t foo /dev/sda1; echo $?
fsck: fsck.foo: not found
/sbin/fsck: Error 2 while executing fsck.foo for /dev/sda1
0

new version:

# fsck -t foo /dev/sda1; echo $?
fsck: fsck.foo: not found
fsck: Error 2 while executing fsck.foo for /dev/sda1
8

Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=619139
Signed-off-by: Karel Zak <kzak@redhat.com>
fsck/fsck.c

index 6a58d7bf3d8b91a57a45dd518ff560a2b04180df..87f8210f6f361d9db9c1f82bef189b6a99714eb9 100644 (file)
@@ -778,7 +778,7 @@ static int wait_many(int flags)
  * If the type isn't specified by the user, then use either the type
  * specified in /etc/fstab, or DEFAULT_FSTYPE.
  */
-static void fsck_device(struct fs_info *fs, int interactive)
+static int fsck_device(struct fs_info *fs, int interactive)
 {
        const char *type;
        int retval;
@@ -800,7 +800,9 @@ static void fsck_device(struct fs_info *fs, int interactive)
                fprintf(stderr, _("%s: Error %d while executing fsck.%s "
                        "for %s\n"), progname, retval, type, fs->device);
                num_running--;
+               return EXIT_ERROR;
        }
+       return 0;
 }
 
 
@@ -1128,7 +1130,7 @@ static int check_all(NOARGS)
                if (fs) {
                        if (!skip_root && !ignore(fs) &&
                            !(ignore_mounted && is_mounted(fs->device))) {
-                               fsck_device(fs, 1);
+                               status |= fsck_device(fs, 1);
                                status |= wait_many(FLAG_WAIT_ALL);
                                if (status > EXIT_NONDESTRUCT)
                                        return status;
@@ -1179,7 +1181,7 @@ static int check_all(NOARGS)
                        /*
                         * Spawn off the fsck process
                         */
-                       fsck_device(fs, serialize);
+                       status |= fsck_device(fs, serialize);
                        fs->flags |= FLAG_DONE;
 
                        /*
@@ -1467,7 +1469,7 @@ int main(int argc, char *argv[])
                }
                if (ignore_mounted && is_mounted(fs->device))
                        continue;
-               fsck_device(fs, interactive);
+               status |= fsck_device(fs, interactive);
                if (serialize ||
                    (max_running && (num_running >= max_running))) {
                        struct fsck_instance *inst;