diff options
author | Stanislav Brabec | 2015-05-25 18:21:36 +0200 |
---|---|---|
committer | Karel Zak | 2015-05-26 11:42:38 +0200 |
commit | d0dc6c17c5025639a7beef8d52792932fd8da0fc (patch) | |
tree | 8d2e8ae96e6cf1447fb790851baa3769d02a1738 /include/sysfs.h | |
parent | hwclock: don't allow non-root access (diff) | |
download | kernel-qcow2-util-linux-d0dc6c17c5025639a7beef8d52792932fd8da0fc.tar.gz kernel-qcow2-util-linux-d0dc6c17c5025639a7beef8d52792932fd8da0fc.tar.xz kernel-qcow2-util-linux-d0dc6c17c5025639a7beef8d52792932fd8da0fc.zip |
Fix /sys to /dev node name translation
linux/drivers/base/core.c: device_get_devnode() defines a translation of
'!' in sysfs nodes to '/' in /dev nodes. The same translation has to be
done to properly support device nodes with slash (e. g. device nodes of
cciss driver and several other drivers).
Introduce new helper sysfs_devname_to_devno() and use it where
appropriate.
Fixes for example lsblk -f on devices using cciss driver.
Signed-off-by: Stanislav Brabec <sbrabec@suse.cz>
Diffstat (limited to 'include/sysfs.h')
-rw-r--r-- | include/sysfs.h | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/include/sysfs.h b/include/sysfs.h index 1de624aad..4564124df 100644 --- a/include/sysfs.h +++ b/include/sysfs.h @@ -91,4 +91,22 @@ extern int sysfs_scsi_host_is(struct sysfs_cxt *cxt, const char *type); extern int sysfs_scsi_has_attribute(struct sysfs_cxt *cxt, const char *attr); extern int sysfs_scsi_path_contains(struct sysfs_cxt *cxt, const char *pattern); +/** + * sysfs_devname_to_dev_name: + * @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 '/'. + */ +static inline void sysfs_devname_to_dev_name (char *name) +{ + char *c; + + if (name) + while ((c = strchr(name, '!'))) + c[0] = '/'; +} + #endif /* UTIL_LINUX_SYSFS_H */ |