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 /include/sysfs.h | |
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 'include/sysfs.h')
-rw-r--r-- | include/sysfs.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/include/sysfs.h b/include/sysfs.h index 4564124df..6b08bbed5 100644 --- a/include/sysfs.h +++ b/include/sysfs.h @@ -98,7 +98,7 @@ extern int sysfs_scsi_path_contains(struct sysfs_cxt *cxt, const char *pattern); * Linux kernel linux/drivers/base/core.c: device_get_devnode() * defines a replacement of '!' in the /sys device name by '/' in the * /dev device name. This helper replaces all ocurrences of '!' in - * @name by '/'. + * @name by '/' to convert from /sys to /dev. */ static inline void sysfs_devname_to_dev_name (char *name) { @@ -109,4 +109,22 @@ static inline void sysfs_devname_to_dev_name (char *name) c[0] = '/'; } +/** + * sysfs_dev_name_to_devname: + * @name: devname to be converted in place + * + * Linux kernel linux/drivers/base/core.c: device_get_devnode() + * defines a replacement of '!' in the /sys device name by '/' in the + * /dev device name. This helper replaces all ocurrences of '/' in + * @name by '!' to convert from /dev to /sys. + */ +static inline void sysfs_dev_name_to_devname (char *name) +{ + char *c; + + if (name) + while ((c = strchr(name, '/'))) + c[0] = '!'; +} + #endif /* UTIL_LINUX_SYSFS_H */ |