[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1410910735-27929-2-git-send-email-maximilian@eschenbacher.email>
Date: Tue, 16 Sep 2014 23:38:38 +0000
From: Maximilian Eschenbacher <maximilian@...henbacher.email>
To: linux-kernel@...r.kernel.org
Cc: valentina.manea.m@...il.com, shuah.kh@...sung.com,
gregkh@...uxfoundation.org,
Maximilian Eschenbacher <maximilian@...henbacher.email>,
Fjodor Schelichow <fjodor.schelichow@...mail.com>,
Johannes Stadlinger <johannes.stadlinger@....de>
Subject: [PATCH 01/18] usbip: sysfs_utils: add read_sysfs_attribute
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 <maximilian@...henbacher.email>
Signed-off-by: Fjodor Schelichow <fjodor.schelichow@...mail.com>
Signed-off-by: Johannes Stadlinger <johannes.stadlinger@....de>
---
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 majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists