diff options
author | Adam Hampson <ahampson@google.com> | 2013-04-08 13:24:21 -0700 |
---|---|---|
committer | Adam Hampson <ahampson@google.com> | 2013-04-08 14:30:38 -0700 |
commit | 14419c9d3d0a82243f69238ce927edb52bf3d727 (patch) | |
tree | 429e03d0f199846e5016fbe12b07478612f397f3 | |
parent | 60ccd6b0b264605d84fd85c343ae465e7fa4deb0 (diff) | |
download | libusb_aah-14419c9d3d0a82243f69238ce927edb52bf3d727.tar.gz |
Revert "temp: Reuse file descriptor if available"HEADandroid-4.4w_r1android-4.3_r3.1android-4.3_r3android-4.3_r2.3android-4.3_r2.2android-4.3_r2.1android-4.3_r2android-4.3_r1.1android-4.3_r1android-4.3_r0.9.1android-4.3_r0.9android-4.3.1_r1tools_r22.2mastermainkitkat-wearjb-mr2.0.0-releasejb-mr2.0-releasejb-mr2-releasejb-mr2-dev
This reverts commit 60ccd6b0b264605d84fd85c343ae465e7fa4deb0.
Bug: 8133917
Change-Id: Ic5114ce77d6ef3f9711fb9a3423d965b94e6644c
Signed-off-by: Adam Hampson <ahampson@google.com>
-rw-r--r-- | libusb/os/linux_usbfs.c | 46 |
1 files changed, 3 insertions, 43 deletions
diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c index 2bdd510..02d182d 100644 --- a/libusb/os/linux_usbfs.c +++ b/libusb/os/linux_usbfs.c @@ -212,13 +212,13 @@ static int check_usb_vfs(const char *dirname) static const char *find_usbfs_path(void) { - const char *path = "/proc/bus/usb"; + const char *path = "/dev/bus/usb"; const char *ret = NULL; if (check_usb_vfs(path)) { ret = path; } else { - path = "/dev/bus/usb"; + path = "/proc/bus/usb"; if (check_usb_vfs(path)) ret = path; } @@ -1211,38 +1211,6 @@ static int op_get_device_list(struct libusb_context *ctx, return usbfs_get_device_list(ctx, _discdevs); } -/* Returns the file descriptor of 'file_name', if it has been opened by the process, or -1 otherwise. */ -static int find_fd_by_name(char *file_name) -{ - struct dirent *fd_dirent; - DIR *proc_fd = opendir("/proc/self/fd"); - int ret = -1; - - while (fd_dirent = readdir(proc_fd)) - { - char link_file_name[1024]; - char fd_file_name[1024]; - - if (fd_dirent->d_type != DT_LNK) - { - continue; - } - - snprintf(link_file_name, 1024, "/proc/self/fd/%s", fd_dirent->d_name); - - memset(fd_file_name, 0, sizeof(fd_file_name)); - readlink(link_file_name, fd_file_name, sizeof(fd_file_name) - 1); - - if (!strcmp(fd_file_name, file_name)) - { - ret = atoi(fd_dirent->d_name); - } - } - - closedir(proc_fd); - - return ret; -} static int op_open(struct libusb_device_handle *handle) { struct linux_device_handle_priv *hpriv = _device_handle_priv(handle); @@ -1250,15 +1218,7 @@ static int op_open(struct libusb_device_handle *handle) _get_usbfs_path(handle->dev, filename); usbi_dbg("opening %s", filename); - - hpriv->fd = find_fd_by_name(filename); - - /* Fallback to normal behavior */ - if (hpriv->fd == -1) - { - hpriv->fd = open(filename, O_RDWR); - } - + hpriv->fd = open(filename, O_RDWR); if (hpriv->fd < 0) { if (errno == EACCES) { usbi_err(HANDLE_CTX(handle), "libusb couldn't open USB device %s: " |