summaryrefslogtreecommitdiffstats
path: root/device/hid/hid_connection_linux.cc
diff options
context:
space:
mode:
authorjracle@logitech.com <jracle@logitech.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-24 23:03:30 +0000
committerjracle@logitech.com <jracle@logitech.com@0039d316-1c4b-4281-b951-d872f2087c98>2014-04-24 23:03:30 +0000
commit20a58e6943c8d3ff008b3043d01642b34511c0b1 (patch)
tree4658063e0e3d2187d355516568f4ba19ceb620b9 /device/hid/hid_connection_linux.cc
parentdb2833886f19cd4a687b5159e066e89d889ad21a (diff)
downloadchromium_src-20a58e6943c8d3ff008b3043d01642b34511c0b1.zip
chromium_src-20a58e6943c8d3ff008b3043d01642b34511c0b1.tar.gz
chromium_src-20a58e6943c8d3ff008b3043d01642b34511c0b1.tar.bz2
HID : read-only device access fallback when read/write fails
- for Windows and Linux - open device with read access when read/write fails BUG=364438 R=rockot@chromium.org Review URL: https://codereview.chromium.org/240263003 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@266022 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'device/hid/hid_connection_linux.cc')
-rw-r--r--device/hid/hid_connection_linux.cc16
1 files changed, 14 insertions, 2 deletions
diff --git a/device/hid/hid_connection_linux.cc b/device/hid/hid_connection_linux.cc
index 936c7b1..204d41d 100644
--- a/device/hid/hid_connection_linux.cc
+++ b/device/hid/hid_connection_linux.cc
@@ -64,8 +64,20 @@ HidConnectionLinux::HidConnectionLinux(HidDeviceInfo device_info,
base::File device_file(base::FilePath(dev_node), flags);
if (!device_file.IsValid()) {
- LOG(ERROR) << device_file.error_details();
- return;
+ base::File::Error file_error = device_file.error_details();
+
+ if (file_error == base::File::FILE_ERROR_ACCESS_DENIED) {
+ flags = base::File::FLAG_OPEN | base::File::FLAG_READ;
+
+ base::File device_file(base::FilePath(dev_node), flags);
+ if (!device_file.IsValid()) {
+ LOG(ERROR) << device_file.error_details();
+ return;
+ }
+ } else {
+ LOG(ERROR) << file_error;
+ return;
+ }
}
if (fcntl(device_file.GetPlatformFile(), F_SETFL,
fcntl(device_file.GetPlatformFile(), F_GETFL) | O_NONBLOCK)) {