From c7a96884eb10997286233527fcd4dcaa64d72853 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Thu, 6 Feb 2014 16:42:26 +0100 Subject: fsck: don't return error if fsck. does not exist The error message is expected for "really wanted" set of filesystems (extN, ..), otherwise it does not make sense for filesystems like btrfs or xfs. Reported-by: Tom Gundersen Signed-off-by: Karel Zak --- disk-utils/fsck.c | 74 +++++++++++++++++++++++++++++++------------------------ 1 file changed, 42 insertions(+), 32 deletions(-) (limited to 'disk-utils/fsck.c') diff --git a/disk-utils/fsck.c b/disk-utils/fsck.c index 308413458..caeb6381c 100644 --- a/disk-utils/fsck.c +++ b/disk-utils/fsck.c @@ -79,9 +79,7 @@ static const char *really_wanted[] = { "ext4dev", "jfs", "reiserfs", - "xiafs", - "xfs", - NULL + "xiafs" }; /* @@ -167,6 +165,19 @@ static int string_to_int(const char *s) return (int) l; } +/* Do we really really want to check this fs? */ +static int fs_check_required(const char *type) +{ + size_t i; + + for(i = 0; i < ARRAY_SIZE(really_wanted); i++) { + if (strcmp(type, really_wanted[i]) == 0) + return 1; + } + + return 0; +} + static int is_mounted(struct libmnt_fs *fs) { int rc; @@ -549,17 +560,17 @@ static void print_stats(struct fsck_instance *inst) * Execute a particular fsck program, and link it into the list of * child processes we are waiting for. */ -static int execute(const char *type, struct libmnt_fs *fs, int interactive) +static int execute(const char *progname, const char *progpath, + const char *type, struct libmnt_fs *fs, int interactive) { - char *s, *argv[80], prog[80]; + char *argv[80]; int argc, i; struct fsck_instance *inst, *p; pid_t pid; inst = xcalloc(1, sizeof(*inst)); - sprintf(prog, "fsck.%s", type); - argv[0] = xstrdup(prog); + argv[0] = xstrdup(progname); argc = 1; for (i=0; i pid = pid; - inst->prog = xstrdup(prog); + inst->prog = xstrdup(progname); inst->type = xstrdup(type); gettimeofday(&inst->start_time, NULL); inst->next = NULL; @@ -826,6 +830,7 @@ static int wait_many(int flags) */ static int fsck_device(struct libmnt_fs *fs, int interactive) { + char progname[80], *progpath; const char *type; int retval; @@ -842,15 +847,27 @@ static int fsck_device(struct libmnt_fs *fs, int interactive) else type = DEFAULT_FSTYPE; + sprintf(progname, "fsck.%s", type); + progpath = find_fsck(progname); + if (progpath == NULL) { + if (fs_check_required(type)) { + retval = ENOENT; + goto err; + } + return 0; + } + num_running++; - retval = execute(type, fs, interactive); + retval = execute(progname, progpath, type, fs, interactive); if (retval) { - warnx(_("error %d while executing fsck.%s for %s"), - retval, type, fs_get_device(fs)); num_running--; - return FSCK_EX_ERROR; + goto err; } return 0; +err: + warnx(_("error %d (%m) while executing fsck.%s for %s"), + retval, type, fs_get_device(fs)); + return FSCK_EX_ERROR; } @@ -1018,8 +1035,7 @@ static int fs_ignored_type(struct libmnt_fs *fs) /* Check if we should ignore this filesystem. */ static int ignore(struct libmnt_fs *fs) { - const char **ip, *type; - int wanted = 0; + const char *type; /* * If the pass number is 0, ignore it. @@ -1074,16 +1090,11 @@ static int ignore(struct libmnt_fs *fs) if (fs_ignored_type(fs)) return 1; - /* Do we really really want to check this fs? */ - for(ip = really_wanted; *ip; ip++) - if (strcmp(type, *ip) == 0) { - wanted = 1; - break; - } + /* See if the program is available. */ if (find_fsck(type) == NULL) { - if (wanted) + if (fs_check_required(type)) warnx(_("cannot check %s: fsck.%s not found"), fs_get_device(fs), type); return 1; @@ -1561,7 +1572,6 @@ int main(int argc, char *argv[]) fs = add_dummy_fs(devices[i]); else if (fs_ignored_type(fs)) continue; - if (ignore_mounted && is_mounted(fs)) continue; status |= fsck_device(fs, interactive); -- cgit v1.2.3-55-g7522