Linux: use read-only access to enumerate devices and descriptors
authorDaniel Drake <dsd@gentoo.org>
Sat, 3 May 2008 13:24:40 +0000 (14:24 +0100)
committerDaniel Drake <dsd@gentoo.org>
Sat, 3 May 2008 13:24:40 +0000 (14:24 +0100)
Write access is not needed until later.
Also fix handling of open() error code.

TODO
libusb/os/linux_usbfs.c

diff --git a/TODO b/TODO
index 955e501..4598e4f 100644 (file)
--- a/TODO
+++ b/TODO
@@ -7,6 +7,7 @@ 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
 =========================================
index 30cb9b9..fe69b6d 100644 (file)
@@ -151,8 +151,8 @@ static int initialize_device(struct libusb_device *dev, uint8_t busnum,
 
        snprintf(path, PATH_MAX, "%s/%03d/%03d", usbfs_path, busnum, devaddr);
        usbi_dbg("%s", path);
-       fd = open(path, O_RDWR);
-       if (!fd) {
+       fd = open(path, O_RDONLY);
+       if (fd < 0) {
                usbi_dbg("open '%s' failed, ret=%d errno=%d", path, fd, errno);
                /* FIXME this might not be an error if the file has gone away due
                 * to unplugging */