From e2f822b4f17342f614ab2455179a80975fca6cb0 Mon Sep 17 00:00:00 2001 From: Daniel Drake Date: Sat, 3 May 2008 14:24:40 +0100 Subject: [PATCH] Linux: use read-only access to enumerate devices and descriptors Write access is not needed until later. Also fix handling of open() error code. --- TODO | 1 + libusb/os/linux_usbfs.c | 4 ++-- 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 */ -- 2.7.4