Fix build break
[chromium-blink-merge.git] / chrome / browser / storage_monitor / udev_util_linux.cc
blobe6c62baa45c9572f469b80bec7d68465f9b37511
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
3 // found in the LICENSE file.
5 #include "chrome/browser/storage_monitor/udev_util_linux.h"
7 #include "base/files/file_path.h"
9 namespace chrome {
11 std::string GetUdevDevicePropertyValue(struct udev_device* udev_device,
12 const char* key) {
13 const char* value = udev_device_get_property_value(udev_device, key);
14 return value ? value : std::string();
17 bool GetUdevDevicePropertyValueByPath(const base::FilePath& device_path,
18 const char* key,
19 std::string* result) {
20 ScopedUdevObject udev(udev_new());
21 if (!udev.get())
22 return false;
23 ScopedUdevDeviceObject device(udev_device_new_from_syspath(
24 udev.get(), device_path.value().c_str()));
25 if (!device.get())
26 return false;
27 *result = GetUdevDevicePropertyValue(device.get(), key);
28 return true;
31 } // namespace chrome