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

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

Issue 2247263002: Prevent formatting a device being mounted in read-only mode. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert some more changes to preserve existing style. 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 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
116 return; 116 return;
117 } 117 }
118 118
119 std::string device_path = mount_point->second.source_path; 119 std::string device_path = mount_point->second.source_path;
120 DiskMap::const_iterator disk = disks_.find(device_path); 120 DiskMap::const_iterator disk = disks_.find(device_path);
121 if (disk == disks_.end()) { 121 if (disk == disks_.end()) {
122 LOG(ERROR) << "Device with path \"" << device_path << "\" not found."; 122 LOG(ERROR) << "Device with path \"" << device_path << "\" not found.";
123 OnFormatCompleted(FORMAT_ERROR_UNKNOWN, device_path); 123 OnFormatCompleted(FORMAT_ERROR_UNKNOWN, device_path);
124 return; 124 return;
125 } 125 }
126 if (disk->second->is_read_only()) {
127 LOG(ERROR) << "Mount point with path \"" << mount_path
128 << "\" is read-only.";
129 OnFormatCompleted(FORMAT_ERROR_DEVICE_NOT_ALLOWED, mount_path);
130 return;
131 }
126 132
127 UnmountPath(disk->second->mount_path(), 133 UnmountPath(disk->second->mount_path(),
128 UNMOUNT_OPTIONS_NONE, 134 UNMOUNT_OPTIONS_NONE,
129 base::Bind(&DiskMountManagerImpl::OnUnmountPathForFormat, 135 base::Bind(&DiskMountManagerImpl::OnUnmountPathForFormat,
130 weak_ptr_factory_.GetWeakPtr(), 136 weak_ptr_factory_.GetWeakPtr(),
131 device_path)); 137 device_path));
132 } 138 }
133 139
134 // DiskMountManager override. 140 // DiskMountManager override.
135 void UnmountDeviceRecursively( 141 void UnmountDeviceRecursively(
(...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after
757 VLOG(1) << "DiskMountManager Shutdown completed"; 763 VLOG(1) << "DiskMountManager Shutdown completed";
758 } 764 }
759 765
760 // static 766 // static
761 DiskMountManager* DiskMountManager::GetInstance() { 767 DiskMountManager* DiskMountManager::GetInstance() {
762 return g_disk_mount_manager; 768 return g_disk_mount_manager;
763 } 769 }
764 770
765 } // namespace disks 771 } // namespace disks
766 } // namespace chromeos 772 } // 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