]> err.no Git - util-linux/commitdiff
blkid: Refuse to create a device structure for a non-existent device
authorTheodore Ts'o <tytso@mit.edu>
Mon, 8 Dec 2008 14:34:28 +0000 (15:34 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 11 Feb 2009 22:21:50 +0000 (23:21 +0100)
Fix blkid_get_dev() so it will never return a device structure if the
device file doesn't exist.

[kzak@redhat.com: port from e2fsprogs to util-linux-ng tree]

Addresses-Debian-Bug: #502541
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Signed-off-by: Karel Zak <kzak@redhat.com>
libs/blkid/src/devname.c

index a9e01cd44007b6367596ab6c56dfa4fae3d81090..101055d859ea5c412b5cbeb368d30d090762749f 100644 (file)
@@ -65,6 +65,8 @@ blkid_dev blkid_get_dev(blkid_cache cache, const char *devname, int flags)
        }
 
        if (!dev && (flags & BLKID_DEV_CREATE)) {
+               if (access(devname, F_OK) < 0)
+                       return NULL;
                dev = blkid_new_dev();
                if (!dev)
                        return NULL;