blob: 1c0b3a6a276e55c034169f3e850d9e58aa6bce6f [file] [log] [blame]
Alex Deymo42432912013-07-12 20:21:15 -07001// 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 McLoughlin049d1652013-07-31 18:47:46 -07006#include "update_engine/utils.h"
Alex Deymo42432912013-07-12 20:21:15 -07007
8#include <base/logging.h>
9#include <rootdev/rootdev.h>
10
11using std::string;
12
13namespace chromeos_update_engine {
14
15const 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 Deymo42432912013-07-12 20:21:15 -070032} // namespace chromeos_update_engine