From: Peter Rajnoha Date: Thu, 20 Sep 2012 07:39:57 +0000 (+0200) Subject: lib/sysfs: fix sysfs_devname_to_devno for dm partitions X-Git-Tag: v2.23-rc1~685 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=857db7f53c03ca363de50682a4958ae9f1f77391;p=thirdparty%2Futil-linux.git lib/sysfs: fix sysfs_devname_to_devno for dm partitions Partitions mapped by device-mapper are not like real partitions where there's a /sys/block///dev sysfs path. We need to look at /sys/block//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 --- diff --git a/lib/sysfs.c b/lib/sysfs.c index d1eccb585c..1384acda61 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -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///dev */