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

Unified Diff: chromeos/disks/disk_mount_manager.cc

Issue 2230713003: Store correct read-only flag of mounted disks. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use source path of mount info directly to lookup. Comment update. Created 4 years, 4 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 | « chromeos/disks/disk_mount_manager.h ('k') | 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 756920ac8c608f7de4a0309f2590d9458b9f811f..0565842c65816979bac8aec74f494afd49126bc5 100644
--- a/chromeos/disks/disk_mount_manager.cc
+++ b/chromeos/disks/disk_mount_manager.cc
@@ -87,6 +87,11 @@ class DiskMountManagerImpl : public DiskMountManager {
base::Bind(&DiskMountManagerImpl::OnMountCompleted,
weak_ptr_factory_.GetWeakPtr(),
MountEntry(MOUNT_ERROR_INTERNAL, source_path, type, "")));
+
+ // Record the access mode option passed to CrosDisks.
+ // This is needed because CrosDisks service methods doesn't return the info
+ // via DBus.
+ access_modes_.insert(std::make_pair(source_path, access_mode));
}
// DiskMountManager override.
@@ -357,6 +362,18 @@ class DiskMountManagerImpl : public DiskMountManager {
}
Disk* disk = iter->second;
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.
+ // |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);
+ }
disk->set_mount_path(mount_info.mount_path);
}
}
@@ -473,6 +490,15 @@ class DiskMountManagerImpl : public DiskMountManager {
disk_info.on_boot_device(),
disk_info.on_removable_device(),
disk_info.is_hidden());
+ // If the device was mounted by the instance, apply recorded parameter.
+ // Lookup by |device_path| which we pass to cros-disks when mounting a
+ // device in |VolumeManager::OnDiskEvent()|.
+ AccessModeMap::iterator access_mode =
+ access_modes_.find(disk->device_path());
+ if (access_mode != access_modes_.end()) {
+ disk->set_read_only(access_mode->second ==
+ chromeos::MOUNT_ACCESS_MODE_READ_ONLY);
+ }
disks_.insert(std::make_pair(disk_info.device_path(), disk));
NotifyDiskStatusUpdate(is_new ? DISK_ADDED : DISK_CHANGED, disk);
}
@@ -640,6 +666,11 @@ class DiskMountManagerImpl : public DiskMountManager {
std::unique_ptr<SuspendUnmountManager> suspend_unmount_manager_;
+ // Whether the instance attempted to mount a device in read-only mode for
+ // each source path.
+ typedef std::map<std::string, chromeos::MountAccessMode> AccessModeMap;
+ AccessModeMap access_modes_;
+
base::WeakPtrFactory<DiskMountManagerImpl> weak_ptr_factory_;
DISALLOW_COPY_AND_ASSIGN(DiskMountManagerImpl);
« no previous file with comments | « chromeos/disks/disk_mount_manager.h ('k') | chromeos/disks/disk_mount_manager_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698