OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 // StorageMonitorLinux implementation. | 5 // StorageMonitorLinux implementation. |
6 | 6 |
7 #include "components/storage_monitor/storage_monitor_linux.h" | 7 #include "components/storage_monitor/storage_monitor_linux.h" |
8 | 8 |
9 #include <mntent.h> | 9 #include <mntent.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 | 215 |
216 base::LaunchOptions options; | 216 base::LaunchOptions options; |
217 base::ProcessHandle handle; | 217 base::ProcessHandle handle; |
218 if (!base::LaunchProcess(command, options, &handle)) | 218 if (!base::LaunchProcess(command, options, &handle)) |
219 return StorageMonitor::EJECT_FAILURE; | 219 return StorageMonitor::EJECT_FAILURE; |
220 | 220 |
221 int exit_code = -1; | 221 int exit_code = -1; |
222 if (!base::WaitForExitCodeWithTimeout(handle, &exit_code, | 222 if (!base::WaitForExitCodeWithTimeout(handle, &exit_code, |
223 base::TimeDelta::FromMilliseconds(3000))) { | 223 base::TimeDelta::FromMilliseconds(3000))) { |
224 base::KillProcess(handle, -1, false); | 224 base::KillProcess(handle, -1, false); |
225 base::EnsureProcessTerminated(handle); | 225 base::EnsureProcessTerminated(base::Process(handle)); |
226 return StorageMonitor::EJECT_FAILURE; | 226 return StorageMonitor::EJECT_FAILURE; |
227 } | 227 } |
228 | 228 |
229 // TODO(gbillock): Make sure this is found in documentation | 229 // TODO(gbillock): Make sure this is found in documentation |
230 // somewhere. Experimentally it seems to hold that exit code | 230 // somewhere. Experimentally it seems to hold that exit code |
231 // 1 means device is in use. | 231 // 1 means device is in use. |
232 if (exit_code == 1) | 232 if (exit_code == 1) |
233 return StorageMonitor::EJECT_IN_USE; | 233 return StorageMonitor::EJECT_IN_USE; |
234 if (exit_code != 0) | 234 if (exit_code != 0) |
235 return StorageMonitor::EJECT_FAILURE; | 235 return StorageMonitor::EJECT_FAILURE; |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
500 mount_priority_map_[mount_device][mount_point] = removable; | 500 mount_priority_map_[mount_device][mount_point] = removable; |
501 receiver()->ProcessAttach(*storage_info); | 501 receiver()->ProcessAttach(*storage_info); |
502 } | 502 } |
503 | 503 |
504 StorageMonitor* StorageMonitor::CreateInternal() { | 504 StorageMonitor* StorageMonitor::CreateInternal() { |
505 const base::FilePath kDefaultMtabPath("/etc/mtab"); | 505 const base::FilePath kDefaultMtabPath("/etc/mtab"); |
506 return new StorageMonitorLinux(kDefaultMtabPath); | 506 return new StorageMonitorLinux(kDefaultMtabPath); |
507 } | 507 } |
508 | 508 |
509 } // namespace storage_monitor | 509 } // namespace storage_monitor |
OLD | NEW |