aboutsummaryrefslogtreecommitdiffstats
path: root/tools/usb/usbip/libsrc/sysfs_utils.c
diff options
context:
space:
mode:
authorValentina Manea <valentina.manea.m@gmail.com>2014-08-20 07:30:59 +0300
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2014-08-25 10:38:56 -0700
commit588b48caf65c4a92af567948ec0025065e749ddf (patch)
tree6cf9771e522864db1685ffd7cabd31439fe93305 /tools/usb/usbip/libsrc/sysfs_utils.c
parentMerge tag 'fixes-for-v3.17-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/balbi/usb into work-linus (diff)
downloadlinux-dev-588b48caf65c4a92af567948ec0025065e749ddf.tar.xz
linux-dev-588b48caf65c4a92af567948ec0025065e749ddf.zip
usbip: move usbip userspace code out of staging
At this point, USB/IP userspace code is fully functional and can be moved out of staging. Signed-off-by: Valentina Manea <valentina.manea.m@gmail.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.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 000000000000..36ac88ece0b8
--- /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;
+}