From: Daniel Drake Date: Sat, 3 May 2008 13:34:54 +0000 (+0100) Subject: Linux: better EACCES handling X-Git-Tag: upstream/1.0.21~1080 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5384bbf300779e7936eac9ebd33ee38f5b533f8e;p=platform%2Fupstream%2Flibusb.git Linux: better EACCES handling --- diff --git a/TODO b/TODO index 4598e4f..955e501 100644 --- a/TODO +++ b/TODO @@ -7,7 +7,6 @@ doxygen warnings serialization of handle_events 0.1 compat layer internal docs for OS porters -passing of "access denied" error code from op_open 1.0 API style/naming points to reconsider ========================================= diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c index bf68d39..ecf6e0a 100644 --- a/libusb/os/linux_usbfs.c +++ b/libusb/os/linux_usbfs.c @@ -399,8 +399,16 @@ static int op_open(struct libusb_device_handle *handle) hpriv->fd = open(dpriv->nodepath, O_RDWR); if (hpriv->fd < 0) { - usbi_err("open failed, code %d errno %d", hpriv->fd, errno); - return -EIO; + if (errno == EACCES) { + fprintf(stderr, "libusb couldn't open USB device %s: " + "Permission denied.\n" + "libusb requires write access to USB device nodes.\n", + dpriv->nodepath); + return -EACCES; + } else { + usbi_err("open failed, code %d errno %d", hpriv->fd, errno); + return -EIO; + } } return usbi_add_pollfd(hpriv->fd, POLLOUT);