Previous rework of usbip's sysfs access structures called for a read_sysfs_attribute function to be implemented in sysfs_utils.c
Signed-off-by: Maximilian Eschenbacher <[email protected]> Signed-off-by: Fjodor Schelichow <[email protected]> Signed-off-by: Johannes Stadlinger <[email protected]> --- tools/usb/usbip/libsrc/sysfs_utils.c | 23 +++++++++++++++++++++++ tools/usb/usbip/libsrc/sysfs_utils.h | 1 + 2 files changed, 24 insertions(+) diff --git a/tools/usb/usbip/libsrc/sysfs_utils.c b/tools/usb/usbip/libsrc/sysfs_utils.c index 36ac88e..fc6d9f9 100644 --- a/tools/usb/usbip/libsrc/sysfs_utils.c +++ b/tools/usb/usbip/libsrc/sysfs_utils.c @@ -29,3 +29,26 @@ int write_sysfs_attribute(const char *attr_path, const char *new_value, return 0; } + +int read_sysfs_attribute(const char *attr_path, char *buffer, size_t buffsize) +{ + int fd; + int length; + + fd = open(attr_path, O_RDONLY); + if (fd < 0) { + dbg("error opening attribute %s", attr_path); + return -1; + } + + length = read(fd, buffer, buffsize); + if (length < 0) { + dbg("error reading from attribute %s", attr_path); + close(fd); + return -1; + } + + close(fd); + + return length; +} diff --git a/tools/usb/usbip/libsrc/sysfs_utils.h b/tools/usb/usbip/libsrc/sysfs_utils.h index 32ac1d1..c1f1b79 100644 --- a/tools/usb/usbip/libsrc/sysfs_utils.h +++ b/tools/usb/usbip/libsrc/sysfs_utils.h @@ -4,5 +4,6 @@ int write_sysfs_attribute(const char *attr_path, const char *new_value, size_t len); +int read_sysfs_attribute(const char *attr_path, char *buffer, size_t buffsize); #endif -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/

