Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(8545)

Unified Diff: device/hid/hid_connection_linux.cc

Issue 240263003: HID : read-only device access fallback when read/write fails (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: oops Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | device/hid/hid_connection_win.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: device/hid/hid_connection_linux.cc
diff --git a/device/hid/hid_connection_linux.cc b/device/hid/hid_connection_linux.cc
index 936c7b1bd23fe95a13c2fd29453fe2119ab59089..204d41d47554ee0ea9cadc1eefe470aa334a5d4f 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)) {
« no previous file with comments | « no previous file | device/hid/hid_connection_win.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698