]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/canonicalize: don't use /dev/mapper/<name> if the node does not exist
authorKarel Zak <kzak@redhat.com>
Wed, 3 Apr 2013 11:32:39 +0000 (13:32 +0200)
committerKarel Zak <kzak@redhat.com>
Wed, 3 Apr 2013 11:32:39 +0000 (13:32 +0200)
Signed-off-by: Karel Zak <kzak@redhat.com>
lib/canonicalize.c

index 1e8aff4f2b3fa9f631c54551a3484418dcf6dbd8..b70acd18c63b61d40a7fd07fad92349d606b966a 100644 (file)
@@ -159,7 +159,9 @@ canonicalize_dm_name(const char *ptname)
        if (fgets(name, sizeof(name), f) && (sz = strlen(name)) > 1) {
                name[sz - 1] = '\0';
                snprintf(path, sizeof(path), "/dev/mapper/%s", name);
-               res = strdup(path);
+
+               if (access(path, F_OK) == 0)
+                       res = strdup(path);
        }
        fclose(f);
        return res;