summaryrefslogtreecommitdiffstats
path: root/tools/usb/usbip/libsrc/sysfs_utils.c
diff options
context:
space:
mode:
authorIngo Molnar <mingo@kernel.org>2014-09-09 06:48:07 +0200
committerIngo Molnar <mingo@kernel.org>2014-09-09 06:48:07 +0200
commitbdea534db894ea19320f470ce2e63b1d9de96a15 (patch)
tree8ec2a0a93d9bb5e7205253c67aa624b9ec227477 /tools/usb/usbip/libsrc/sysfs_utils.c
parent39b5a56ec0be5effe9b7d0f18cb27724bf2e5d47 (diff)
parent2ce7598c9a453e0acd0e07be7be3f5eb39608ebd (diff)
downloadop-kernel-dev-bdea534db894ea19320f470ce2e63b1d9de96a15.zip
op-kernel-dev-bdea534db894ea19320f470ce2e63b1d9de96a15.tar.gz
Merge tag 'v3.17-rc4' into perf/core, to pick up fixes
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Diffstat (limited to 'tools/usb/usbip/libsrc/sysfs_utils.c')
-rw-r--r--tools/usb/usbip/libsrc/sysfs_utils.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/tools/usb/usbip/libsrc/sysfs_utils.c b/tools/usb/usbip/libsrc/sysfs_utils.c
new file mode 100644
index 0000000..36ac88e
--- /dev/null
+++ b/tools/usb/usbip/libsrc/sysfs_utils.c
@@ -0,0 +1,31 @@
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+
+#include "sysfs_utils.h"
+#include "usbip_common.h"
+
+int write_sysfs_attribute(const char *attr_path, const char *new_value,
+ size_t len)
+{
+ int fd;
+ int length;
+
+ fd = open(attr_path, O_WRONLY);
+ if (fd < 0) {
+ dbg("error opening attribute %s", attr_path);
+ return -1;
+ }
+
+ length = write(fd, new_value, len);
+ if (length < 0) {
+ dbg("error writing to attribute %s", attr_path);
+ close(fd);
+ return -1;
+ }
+
+ close(fd);
+
+ return 0;
+}
OpenPOWER on IntegriCloud