From: Paweł Szewczyk Date: Thu, 11 Feb 2016 13:01:09 +0000 (+0100) Subject: Use deviced instead of USB Security Daemon X-Git-Tag: accepted/tizen/unified/20170428.053642~6 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=30abdfc69b62d03900f45fac8652173af75e3450;p=platform%2Fupstream%2Flibusb.git Use deviced instead of USB Security Daemon Change-Id: I507208ee6d4ba2549ce59a1d70ee224f6ee73fc3 Signed-off-by: Paweł Szewczyk [Rebase onto new library version] Signed-off-by: Krzysztof Opasiak --- diff --git a/configure.ac b/configure.ac index 7eb4628..c822e5b 100644 --- a/configure.ac +++ b/configure.ac @@ -107,15 +107,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], @@ -223,7 +223,7 @@ 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_USBDK, test "x$enable_usbdk" = 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 2731986..e6fc154 100644 --- a/libusb/Makefile.am +++ b/libusb/Makefile.am @@ -104,8 +104,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 f6ee9a3..90b80c4 100644 --- a/libusb/os/linux_usbfs.c +++ b/libusb/os/linux_usbfs.c @@ -40,8 +40,8 @@ #include /* Tizen specific */ -#ifdef USE_USD -#include +#ifdef USE_DEVICED +#include #endif #include "libusbi.h" @@ -211,34 +211,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; @@ -246,7 +231,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) { @@ -265,7 +250,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 @@ -281,13 +266,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