summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Drake <dsd@gentoo.org>2008-05-03 14:24:40 +0100
committerDaniel Drake <dsd@gentoo.org>2008-05-03 14:24:40 +0100
commite2f822b4f17342f614ab2455179a80975fca6cb0 (patch)
treebc7f3532dd298d7531903694b85a4a60b554193d
parent81204eed3d0a7744b89b68bd90d567b68d191a91 (diff)
downloadlibusb-e2f822b4f17342f614ab2455179a80975fca6cb0.tar.gz
Linux: use read-only access to enumerate devices and descriptors
Write access is not needed until later. Also fix handling of open() error code.
-rw-r--r--TODO1
-rw-r--r--libusb/os/linux_usbfs.c4
2 files changed, 3 insertions, 2 deletions
diff --git a/TODO b/TODO
index 955e501..4598e4f 100644
--- 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
=========================================
diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c
index 30cb9b9..fe69b6d 100644
--- a/libusb/os/linux_usbfs.c
+++ b/libusb/os/linux_usbfs.c
@@ -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 */