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"
9 namespace storage_monitor
{
11 void UdevDeleter::operator()(struct udev
* udev
) {
15 void UdevDeviceDeleter::operator()(struct udev_device
* device
) {
16 udev_device_unref(device
);
19 std::string
GetUdevDevicePropertyValue(struct udev_device
* udev_device
,
21 const char* value
= udev_device_get_property_value(udev_device
, key
);
22 return value
? value
: std::string();
25 bool GetUdevDevicePropertyValueByPath(const base::FilePath
& device_path
,
27 std::string
* result
) {
28 ScopedUdevObject
udev(udev_new());
31 ScopedUdevDeviceObject
device(udev_device_new_from_syspath(
32 udev
.get(), device_path
.value().c_str()));
35 *result
= GetUdevDevicePropertyValue(device
.get(), key
);
39 } // namespace storage_monitor