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

Unified Diff: chromeos/disks/disk_mount_manager.cc

Issue 2316133002: Fix a bug where read-only volumes were recognized as read-write. (Closed)
Patch Set: Created 4 years, 3 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 | chromeos/disks/disk_mount_manager_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chromeos/disks/disk_mount_manager.cc
diff --git a/chromeos/disks/disk_mount_manager.cc b/chromeos/disks/disk_mount_manager.cc
index 7f496bfd0c1061d154521cccbf400eb16deea6b6..4eebab64cfe994ee11429527e0697b9d9335ef0f 100644
--- a/chromeos/disks/disk_mount_manager.cc
+++ b/chromeos/disks/disk_mount_manager.cc
@@ -360,16 +360,16 @@ class DiskMountManagerImpl : public DiskMountManager {
DCHECK(disk);
// The is_read_only field in *disk may be incorrect when this is called
// from CrosDisksClientImpl::OnMountCompleted.
- // Overwrite based on the access mode option that was passed when
- // issuing
- // mount command to the same mount path last time.
+ // The disk should be treated as read-only when:
+ // - the read-only option was passed when issuing mount command
+ // - or the device hardware is read-only.
// |source_path| should be same as |disk->device_path| because
// |VolumeManager::OnDiskEvent()| passes the latter to cros-disks as a
// source path when mounting a device.
AccessModeMap::iterator it = access_modes_.find(entry.source_path());
- if (it != access_modes_.end()) {
- disk->set_read_only(it->second ==
- chromeos::MOUNT_ACCESS_MODE_READ_ONLY);
+ if (it != access_modes_.end() &&
+ it->second == chromeos::MOUNT_ACCESS_MODE_READ_ONLY) {
+ disk->set_read_only(true);
}
disk->set_mount_path(mount_info.mount_path);
}
« no previous file with comments | « no previous file | chromeos/disks/disk_mount_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698