]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fsck: retire stat(3) when access(3) does better job
authorSami Kerola <kerolasa@iki.fi>
Sat, 31 Oct 2015 19:21:15 +0000 (19:21 +0000)
committerKarel Zak <kzak@redhat.com>
Mon, 9 Nov 2015 08:56:14 +0000 (09:56 +0100)
The stat(3) and access(3) are in this case almost interchangeable, so choose
the lightweight function with additional advantage checking the file is
executable.

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
disk-utils/fsck.c

index ff504aa1da5fa3552595585d35a8a28469b7a6fe..5be2b44d7d3646b57e246f26522ac0c187c15bae 100644 (file)
@@ -547,14 +547,13 @@ static char *find_fsck(const char *type)
        const char *tpl;
        static char prog[256];
        char *p = xstrdup(fsck_path);
-       struct stat st;
 
        /* Are we looking for a program or just a type? */
        tpl = (strncmp(type, "fsck.", 5) ? "%s/fsck.%s" : "%s/%s");
 
        for(s = strtok(p, ":"); s; s = strtok(NULL, ":")) {
                sprintf(prog, tpl, s, type);
-               if (stat(prog, &st) == 0)
+               if (access(prog, X_OK) == 0)
                        break;
        }
        free(p);