Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 1 | // Copyright (c) 2013 The Chromium OS Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "update_engine/hardware.h" |
Liam McLoughlin | 049d165 | 2013-07-31 18:47:46 -0700 | [diff] [blame] | 6 | #include "update_engine/utils.h" |
Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 7 | |
| 8 | #include <base/logging.h> |
| 9 | #include <rootdev/rootdev.h> |
| 10 | |
| 11 | using std::string; |
| 12 | |
| 13 | namespace chromeos_update_engine { |
| 14 | |
| 15 | const string Hardware::BootDevice() { |
| 16 | char boot_path[PATH_MAX]; |
| 17 | // Resolve the boot device path fully, including dereferencing |
| 18 | // through dm-verity. |
| 19 | int ret = rootdev(boot_path, sizeof(boot_path), true, false); |
| 20 | |
| 21 | if (ret < 0) { |
| 22 | LOG(ERROR) << "rootdev failed to find the root device"; |
| 23 | return ""; |
| 24 | } |
| 25 | LOG_IF(WARNING, ret > 0) << "rootdev found a device name with no device node"; |
| 26 | |
| 27 | // This local variable is used to construct the return string and is not |
| 28 | // passed around after use. |
| 29 | return boot_path; |
| 30 | } |
| 31 | |
Alex Deymo | 4243291 | 2013-07-12 20:21:15 -0700 | [diff] [blame] | 32 | } // namespace chromeos_update_engine |