| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 |
| OLD | NEW |