diff options
author | Stanislav Brabec | 2015-05-27 15:12:08 +0200 |
---|---|---|
committer | Karel Zak | 2015-05-28 10:27:20 +0200 |
commit | 759b120d85c30ec6ab80097c251677b022c5a03c (patch) | |
tree | df154e7b72c222b67b3bfc6bcd275fdff7e82ea5 /lib | |
parent | libfdisk: Use predictable /dev/mapper partition names for /dev/dm-N (diff) | |
download | kernel-qcow2-util-linux-759b120d85c30ec6ab80097c251677b022c5a03c.tar.gz kernel-qcow2-util-linux-759b120d85c30ec6ab80097c251677b022c5a03c.tar.xz kernel-qcow2-util-linux-759b120d85c30ec6ab80097c251677b022c5a03c.zip |
lib/sysfs: Fix /dev to /sys node name translation
d0dc6c1 introduced translation of /sys names to /dev names, as required
by the kernel linux/drivers/base/core.c: device_get_devnode(). But there
are other places of code that use /dev names in /sys. They need reverse
translation from '/' to '!'.
For example, fdisk -l returns empty list since a22c6eb for device nodes
in subdirectories (used e. g. by cciss driver).
Introduce yet another helper sysfs_dev_name_to_devname() and use it where
appropriate.
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/sysfs.c | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/lib/sysfs.c b/lib/sysfs.c index 8417d2d76..34a520758 100644 --- a/lib/sysfs.c +++ b/lib/sysfs.c @@ -74,10 +74,14 @@ dev_t sysfs_devname_to_devno(const char *name, const char *parent) } else if (!dev) { /* - * Create path to /sys/block/<name>/dev + * Create path to /sys/block/<sysname>/dev */ + char sysname[PATH_MAX]; + + strncpy(sysname, name, sizeof(sysname)); + sysfs_dev_name_to_devname(sysname); int len = snprintf(buf, sizeof(buf), - _PATH_SYS_BLOCK "/%s/dev", name); + _PATH_SYS_BLOCK "/%s/dev", sysname); if (len < 0 || (size_t) len + 1 > sizeof(buf)) return 0; path = buf; |