Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1e940319 authored by Valentina Manea's avatar Valentina Manea Committed by Greg Kroah-Hartman
Browse files

staging: usbip: userspace: migrate usbip_bind to libudev



This patch adds autoconf check for libudev and migrates
usbip_bind to the new library.

libsysfs will still be used until all userspace is modified.

Signed-off-by: default avatarValentina Manea <valentina.manea.m@gmail.com>
Reviewed-by: default avatarShuah Khan <shuah.kh@samsung.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 0669e5fa
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -50,6 +50,12 @@ AC_CHECK_HEADER([sysfs/libsysfs.h],
			      [AC_MSG_ERROR([Missing sysfs2 library!])])],
		[AC_MSG_ERROR([Missing /usr/include/sysfs/libsysfs.h])])

AC_CHECK_HEADER([libudev.h],
		[AC_CHECK_LIB([udev], [udev_new],
			      [LIBS="$LIBS -ludev"],
			      [AC_MSG_ERROR([Missing udev library!])])],
		[AC_MSG_ERROR([Missing /usr/include/libudev.h])])

# Checks for libwrap library.
AC_MSG_CHECKING([whether to use the libwrap (TCP wrappers) library])
AC_ARG_WITH([tcp-wrappers],
+9 −0
Original line number Diff line number Diff line
@@ -30,6 +30,15 @@
#define USBIP_HOST_DRV_NAME	"usbip-host"
#define USBIP_VHCI_DRV_NAME	"vhci_hcd"

/* sysfs constants */
#define SYSFS_MNT_PATH         "/sys"
#define SYSFS_BUS_NAME         "bus"
#define SYSFS_BUS_TYPE         "usb"
#define SYSFS_DRIVERS_NAME     "drivers"

#define SYSFS_PATH_MAX		256
#define SYSFS_BUS_ID_SIZE	32

extern int usbip_use_syslog;
extern int usbip_use_stderr;
extern int usbip_use_debug ;
+2 −1
Original line number Diff line number Diff line
@@ -6,7 +6,8 @@ sbin_PROGRAMS := usbip usbipd

usbip_SOURCES := usbip.h utils.h usbip.c utils.c usbip_network.c \
		 usbip_attach.c usbip_detach.c usbip_list.c \
		 usbip_bind.c usbip_unbind.c usbip_port.c
		 usbip_bind.c usbip_unbind.c usbip_port.c \
		 sysfs_utils.c


usbipd_SOURCES := usbip_network.h usbipd.c usbip_network.c
+31 −0
Original line number Diff line number Diff line
#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;
}
+8 −0
Original line number Diff line number Diff line

#ifndef __SYSFS_UTILS_H
#define __SYSFS_UTILS_H

int write_sysfs_attribute(const char *attr_path, const char *new_value,
			  size_t len);

#endif
Loading