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
3 // found in the LICENSE file.
5 #include "components/storage_monitor/udev_util_linux.h"
7 #include "base/files/file_path.h"
8 #include "device/udev_linux/scoped_udev.h"
10 namespace storage_monitor
{
12 std::string
GetUdevDevicePropertyValue(udev_device
* udev_device
,
14 const char* value
= udev_device_get_property_value(udev_device
, key
);
15 return value
? value
: std::string();
18 bool GetUdevDevicePropertyValueByPath(const base::FilePath
& device_path
,
20 std::string
* result
) {
21 device::ScopedUdevPtr
udev(udev_new());
24 device::ScopedUdevDevicePtr
device(udev_device_new_from_syspath(
25 udev
.get(), device_path
.value().c_str()));
28 *result
= GetUdevDevicePropertyValue(device
.get(), key
);
32 } // namespace storage_monitor