]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
lib/sysfs: fix sysfs_devname_to_devno for dm partitions
authorPeter Rajnoha <prajnoha@redhat.com>
Thu, 20 Sep 2012 07:39:57 +0000 (09:39 +0200)
committerKarel Zak <kzak@redhat.com>
Fri, 21 Sep 2012 10:21:30 +0000 (12:21 +0200)
Partitions mapped by device-mapper are not like real partitions where
there's a /sys/block/<parent>/<name>/dev sysfs path. We need to look
at /sys/block/<name>/dev like we do for any other non-partition devices.
The mapped partition is not found otherwise.

For example, this bug shows up in lsblk while specifying a device
on command line while that device is a dm mapping over a partition:
$lsblk
NAME             MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
sda                8:0    0  128M  0 disk
`-test (dm-0)    253:0    0  128M  0 dm
  `-test1 (dm-1) 253:1    0  127M  0 part

Before this patch:
$lsblk /dev/mapper/test1
lsblk: dm-1: unknown device name

With this patch:
$lsblk /dev/mapper/test1
NAME         MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
test1 (dm-1) 253:1    0  127M  0 part

lib/sysfs.c

index d1eccb585cc900710e30544ed74fd39d0339d2c5..1384acda6110cb08618e7d9ce17677b5151fa88e 100644 (file)
@@ -58,7 +58,7 @@ dev_t sysfs_devname_to_devno(const char *name, const char *parent)
                        name += 5;      /* unaccesible, or not node in /dev */
        }
 
-       if (!dev && parent) {
+       if (!dev && parent && strncmp("dm-", name, 3)) {
                /*
                 * Create path to /sys/block/<parent>/<name>/dev
                 */