OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ | 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ |
6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ | 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ |
7 | 7 |
8 #include <errno.h> | 8 #include <errno.h> |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <set> | 10 #include <set> |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 vect.end(), | 128 vect.end(), |
129 value); | 129 value); |
130 if (it == vect.end()) { | 130 if (it == vect.end()) { |
131 return false; | 131 return false; |
132 } else { | 132 } else { |
133 *out_index = it - vect.begin(); | 133 *out_index = it - vect.begin(); |
134 return true; | 134 return true; |
135 } | 135 } |
136 } | 136 } |
137 | 137 |
138 // Returns the currently booted device. "/dev/sda1", for example. | 138 // Returns the currently booted device. "/dev/sda3", for example. |
139 // This will not interpret LABEL= or UUID=. You'll need to use findfs | 139 // This will not interpret LABEL= or UUID=. You'll need to use findfs |
140 // or something with equivalent funcionality to interpret those. | 140 // or something with equivalent funcionality to interpret those. |
141 const std::string BootDevice(); | 141 const std::string BootDevice(); |
142 | 142 |
| 143 // Returns the currently booted kernel device, "dev/sda2", for example. |
| 144 // Client must pass in the boot device. The suggested calling convention |
| 145 // is: BootKernelDevice(BootDevice()). |
| 146 // This function works by doing string modification on boot_device. |
| 147 // Returns empty string on failure. |
| 148 const std::string BootKernelDevice(const std::string& boot_device); |
| 149 |
| 150 |
143 } // namespace utils | 151 } // namespace utils |
144 | 152 |
145 // Class to unmount FS when object goes out of scope | 153 // Class to unmount FS when object goes out of scope |
146 class ScopedFilesystemUnmounter { | 154 class ScopedFilesystemUnmounter { |
147 public: | 155 public: |
148 explicit ScopedFilesystemUnmounter(const std::string& mountpoint) | 156 explicit ScopedFilesystemUnmounter(const std::string& mountpoint) |
149 : mountpoint_(mountpoint) {} | 157 : mountpoint_(mountpoint) {} |
150 ~ScopedFilesystemUnmounter() { | 158 ~ScopedFilesystemUnmounter() { |
151 utils::UnmountFilesystem(mountpoint_); | 159 utils::UnmountFilesystem(mountpoint_); |
152 } | 160 } |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 bool _success = (_x); \ | 276 bool _success = (_x); \ |
269 if (!_success) { \ | 277 if (!_success) { \ |
270 LOG(ERROR) << #_x " failed."; \ | 278 LOG(ERROR) << #_x " failed."; \ |
271 return; \ | 279 return; \ |
272 } \ | 280 } \ |
273 } while (0) | 281 } while (0) |
274 | 282 |
275 | 283 |
276 | 284 |
277 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ | 285 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_UTILS_H__ |
OLD | NEW |