summaryrefslogtreecommitdiffstats
path: root/disk-utils
diff options
context:
space:
mode:
authorKarel Zak2018-02-19 13:05:45 +0100
committerKarel Zak2018-02-19 13:05:45 +0100
commitac528367815bb48b9d1385d25e5fbf2d32d3020c (patch)
treec6e79d1cf072dc7703264c6a3b0a568ced59b7b5 /disk-utils
parentlsblk: document LSBLK_DEBUG= (diff)
downloadkernel-qcow2-util-linux-ac528367815bb48b9d1385d25e5fbf2d32d3020c.tar.gz
kernel-qcow2-util-linux-ac528367815bb48b9d1385d25e5fbf2d32d3020c.tar.xz
kernel-qcow2-util-linux-ac528367815bb48b9d1385d25e5fbf2d32d3020c.zip
fsck: cleanup find_fsck()
* remove static variable * return 0 or 1 * optionally return allocated path to the program Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils')
-rw-r--r--disk-utils/fsck.c20
1 files changed, 14 insertions, 6 deletions
diff --git a/disk-utils/fsck.c b/disk-utils/fsck.c
index 354f1309d..3afc88600 100644
--- a/disk-utils/fsck.c
+++ b/disk-utils/fsck.c
@@ -540,12 +540,13 @@ static struct libmnt_fs *lookup(char *path)
}
/* Find fsck program for a given fs type. */
-static char *find_fsck(const char *type)
+static int find_fsck(const char *type, char **progpath)
{
char *s;
const char *tpl;
- static char *prog = NULL;
+ char *prog = NULL;
char *p = xstrdup(fsck_path);
+ int rc;
/* Are we looking for a program or just a type? */
tpl = (strncmp(type, "fsck.", 5) ? "%s/fsck.%s" : "%s/%s");
@@ -559,7 +560,14 @@ static char *find_fsck(const char *type)
}
free(p);
- return prog;
+ rc = prog ? 1 : 0;
+
+ if (progpath)
+ *progpath = prog;
+ else
+ free(prog);
+
+ return rc;
}
static int progress_active(void)
@@ -905,8 +913,8 @@ static int fsck_device(struct libmnt_fs *fs, int interactive)
type = DEFAULT_FSTYPE;
xasprintf(&progname, "fsck.%s", type);
- progpath = find_fsck(progname);
- if (progpath == NULL) {
+
+ if (!find_fsck(progname, &progpath)) {
free(progname);
if (fs_check_required(type)) {
retval = ENOENT;
@@ -1153,7 +1161,7 @@ static int ignore(struct libmnt_fs *fs)
/* See if the <fsck.fs> program is available. */
- if (find_fsck(type) == NULL) {
+ if (!find_fsck(type, NULL)) {
if (fs_check_required(type))
warnx(_("cannot check %s: fsck.%s not found"),
fs_get_device(fs), type);