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

Side by Side Diff: chromeos/disks/disk_mount_manager.cc

Issue 2311863002: Fix a bug where read-only volumes were recognized as read-write. (Closed)
Patch Set: Revise comment. 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 unified diff | Download patch
« no previous file with comments | « no previous file | chromeos/disks/disk_mount_manager_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chromeos/disks/disk_mount_manager.h" 5 #include "chromeos/disks/disk_mount_manager.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <set> 10 #include <set>
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 mount_info.mount_condition) && 353 mount_info.mount_condition) &&
354 mount_info.mount_type == MOUNT_TYPE_DEVICE && 354 mount_info.mount_type == MOUNT_TYPE_DEVICE &&
355 !mount_info.source_path.empty() && 355 !mount_info.source_path.empty() &&
356 !mount_info.mount_path.empty()) { 356 !mount_info.mount_path.empty()) {
357 DiskMap::iterator iter = disks_.find(mount_info.source_path); 357 DiskMap::iterator iter = disks_.find(mount_info.source_path);
358 if (iter != disks_.end()) { // disk might have been removed by now? 358 if (iter != disks_.end()) { // disk might have been removed by now?
359 Disk* disk = iter->second; 359 Disk* disk = iter->second;
360 DCHECK(disk); 360 DCHECK(disk);
361 // The is_read_only field in *disk may be incorrect when this is called 361 // The is_read_only field in *disk may be incorrect when this is called
362 // from CrosDisksClientImpl::OnMountCompleted. 362 // from CrosDisksClientImpl::OnMountCompleted.
363 // Overwrite based on the access mode option that was passed when 363 // The disk should be treated as read-only when:
364 // issuing 364 // - the read-only option was passed when issuing mount command
365 // mount command to the same mount path last time. 365 // - or the device hardware is read-only.
366 // |source_path| should be same as |disk->device_path| because 366 // |source_path| should be same as |disk->device_path| because
367 // |VolumeManager::OnDiskEvent()| passes the latter to cros-disks as a 367 // |VolumeManager::OnDiskEvent()| passes the latter to cros-disks as a
368 // source path when mounting a device. 368 // source path when mounting a device.
369 AccessModeMap::iterator it = access_modes_.find(entry.source_path()); 369 AccessModeMap::iterator it = access_modes_.find(entry.source_path());
370 if (it != access_modes_.end()) { 370 if (it != access_modes_.end() &&
371 disk->set_read_only(it->second == 371 it->second == chromeos::MOUNT_ACCESS_MODE_READ_ONLY) {
372 chromeos::MOUNT_ACCESS_MODE_READ_ONLY); 372 disk->set_read_only(true);
373 } 373 }
374 disk->set_mount_path(mount_info.mount_path); 374 disk->set_mount_path(mount_info.mount_path);
375 } 375 }
376 } 376 }
377 // Observers may read the values of disks_. So notify them after tweaking 377 // Observers may read the values of disks_. So notify them after tweaking
378 // values of disks_. 378 // values of disks_.
379 NotifyMountStatusUpdate(MOUNTING, entry.error_code(), mount_info); 379 NotifyMountStatusUpdate(MOUNTING, entry.error_code(), mount_info);
380 } 380 }
381 381
382 // Callback for UnmountPath. 382 // Callback for UnmountPath.
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 VLOG(1) << "DiskMountManager Shutdown completed"; 795 VLOG(1) << "DiskMountManager Shutdown completed";
796 } 796 }
797 797
798 // static 798 // static
799 DiskMountManager* DiskMountManager::GetInstance() { 799 DiskMountManager* DiskMountManager::GetInstance() {
800 return g_disk_mount_manager; 800 return g_disk_mount_manager;
801 } 801 }
802 802
803 } // namespace disks 803 } // namespace disks
804 } // namespace chromeos 804 } // namespace chromeos
OLDNEW
« 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