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 void UdevDeleter::operator()(struct udev
* udev
) {
13 void UdevDeviceDeleter::operator()(struct udev_device
* device
) {
14 udev_device_unref(device
);
17 std::string
GetUdevDevicePropertyValue(struct udev_device
* udev_device
,
19 const char* value
= udev_device_get_property_value(udev_device
, key
);
20 return value
? value
: std::string();
23 bool GetUdevDevicePropertyValueByPath(const base::FilePath
& device_path
,
25 std::string
* result
) {
26 ScopedUdevObject
udev(udev_new());
29 ScopedUdevDeviceObject
device(udev_device_new_from_syspath(
30 udev
.get(), device_path
.value().c_str()));
33 *result
= GetUdevDevicePropertyValue(device
.get(), key
);