From a3a05917e8ac7050045fd7fa13c16dc890ec1605 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Pawe=C5=82=20Szewczyk?= Date: Thu, 11 Feb 2016 14:01:09 +0100 Subject: [PATCH] Use deviced instead of USB Security Daemon MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Change-Id: I507208ee6d4ba2549ce59a1d70ee224f6ee73fc3 Signed-off-by: Paweł Szewczyk --- configure.ac | 16 ++++++++-------- libusb/Makefile.am | 8 ++++---- libusb/os/linux_usbfs.c | 35 ++++++++++------------------------- packaging/libusb.spec | 4 ++-- 4 files changed, 24 insertions(+), 39 deletions(-) diff --git a/configure.ac b/configure.ac index cd63770..c64afbe 100644 --- a/configure.ac +++ b/configure.ac @@ -97,15 +97,15 @@ case $backend in linux) AC_DEFINE(OS_LINUX, 1, [Linux backend]) AC_SUBST(OS_LINUX) - AC_ARG_ENABLE([usd], - [AC_HELP_STRING([--enable-usd], [Use USB security daemon to obtain dev node fds [default=no]])], - [], [enable_usd="no"]) - if test "x$enable_usd" = "xyes"; then - PKG_CHECK_MODULES([USD], [capi-system-usbhost-usd]) - AC_DEFINE(USE_USD, 1, [Use USB security daemon to obtain dev node fds]) + AC_ARG_ENABLE([deviced], + [AC_HELP_STRING([--enable-deviced], [Use deviced to obtain dev node fds [default=no]])], + [], [enable_deviced="no"]) + if test "x$enable_deviced" = "xyes"; then + PKG_CHECK_MODULES([DEVICED], [deviced]) + AC_DEFINE(USE_DEVICED, 1, [Use deviced to obtain dev node fds]) fi - AC_SUBST(USE_USD) + AC_SUBST(USE_DEVICED) AC_SEARCH_LIBS(clock_gettime, rt, [], [], -pthread) AC_ARG_ENABLE([udev], @@ -191,7 +191,7 @@ AM_CONDITIONAL(OS_WINDOWS, test "x$backend" = xwindows) AM_CONDITIONAL(THREADS_POSIX, test "x$threads" = xposix) AM_CONDITIONAL(CREATE_IMPORT_LIB, test "x$create_import_lib" = "xyes") AM_CONDITIONAL(USE_UDEV, test "x$enable_udev" = xyes) -AM_CONDITIONAL(USE_USD, test "x$enable_usd" = xyes) +AM_CONDITIONAL(USE_DEVICED, test "x$enable_deviced" = xyes) if test "$threads" = posix; then AC_DEFINE(THREADS_POSIX, 1, [Use POSIX Threads]) fi diff --git a/libusb/Makefile.am b/libusb/Makefile.am index 7b175a2..c9c1d8c 100644 --- a/libusb/Makefile.am +++ b/libusb/Makefile.am @@ -75,8 +75,8 @@ hdrdir = $(includedir)/libusb-1.0 hdr_HEADERS = libusb.h if OS_LINUX -if USE_USD -libusb_1_0_la_CFLAGS += $(USD_CFLAGS) -libusb_1_0_la_LIBADD = $(USD_LIBS) +if USE_DEVICED +libusb_1_0_la_CFLAGS += $(DEVICED_CFLAGS) +libusb_1_0_la_LIBADD = $(DEVICED_LIBS) +endif endif -endif \ No newline at end of file diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c index 6fbf3ba..75c33ff 100644 --- a/libusb/os/linux_usbfs.c +++ b/libusb/os/linux_usbfs.c @@ -39,8 +39,8 @@ #include /* Tizen specific */ -#ifdef USE_USD -#include +#ifdef USE_DEVICED +#include #endif #include "libusb.h" @@ -210,34 +210,19 @@ static int _direct_open_device(struct libusb_context *ctx, const char *path, return fd; } -#ifdef USE_USD +#ifdef USE_DEVICED static int _ask_for_open(const char *path, mode_t mode, int silent) { int ret; int fd; - ret = usd_open_usb_device(path, &fd); - if (ret != USD_API_SUCCESS) { + ret = open_usb_device(path, &fd); + if (ret < 0) { /* * We have an error so let's set errno correctly * just like open does */ - switch (ret) { - case USD_API_ERROR_ACCESS_DENIED: - case USD_API_ERROR_SOCKET: - case USD_API_ERROR_AUTHENTICATION_FAILED: - errno = EACCES; - break; - - case USD_API_ERROR_INPUT_PARAM: - case USD_API_ERROR_FILE_NOT_EXIST: - errno = ENOENT; - break; - default: - errno = EINVAL; - break; - } - + errno= -ret; ret = -1; } else { ret = fd; @@ -245,7 +230,7 @@ static int _ask_for_open(const char *path, mode_t mode, int silent) return ret; } -#endif /* USE_USD */ +#endif /* USE_DEVICED */ static int _get_usbfs_fd(struct libusb_device *dev, mode_t mode, int silent) { @@ -264,7 +249,7 @@ static int _get_usbfs_fd(struct libusb_device *dev, mode_t mode, int silent) if (fd != -1) return fd; /* Success */ -#ifdef USE_USD +#ifdef USE_DEVICED /* * If we are here, we were unable to go simple * path and open the device directly. In Tizen @@ -280,13 +265,13 @@ static int _get_usbfs_fd(struct libusb_device *dev, mode_t mode, int silent) if (mode & O_RDWR) { if (!silent) usbi_info(ctx, "No direct access to device node: %s. " - "Trying to use USD", path); + "Trying to use deviced", path); fd = _ask_for_open(path, mode, silent); if (fd != -1) return fd; } -#endif /* USE_USD */ +#endif /* USE_DEVICED */ if (!silent) { usbi_err(ctx, "libusb couldn't open USB device %s: %s", diff --git a/packaging/libusb.spec b/packaging/libusb.spec index 1d7a227..da4d5d9 100644 --- a/packaging/libusb.spec +++ b/packaging/libusb.spec @@ -10,7 +10,7 @@ Source1: baselibs.conf Source1001: libusb.manifest BuildRequires: pkg-config BuildRequires: systemd-devel -BuildRequires: pkgconfig(capi-system-usbhost-usd) +BuildRequires: pkgconfig(deviced) %description Libusb is a library that allows userspace access to USB devices. @@ -32,7 +32,7 @@ cp %{SOURCE1001} . %reconfigure\ --with-pic\ --disable-static\ - --enable-usd + --enable-deviced make %{?_smp_mflags} %install -- 2.7.4