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 #ifndef DEVICE_UDEV_LINUX_UDEV_H_
6 #define DEVICE_UDEV_LINUX_UDEV_H_
12 #if !defined(USE_UDEV)
13 #error "USE_UDEV not defined"
16 // Adapted from libudev.h.
17 #define udev_list_entry_foreach(list_entry, first_entry) \
18 for (list_entry = first_entry; list_entry != NULL; \
19 list_entry = ::device::udev_list_entry_get_next(list_entry))
21 // Forward declarations of opaque structs.
24 struct udev_enumerate
;
25 struct udev_list_entry
;
30 const char* udev_device_get_action(udev_device
* udev_device
);
31 const char* udev_device_get_devnode(udev_device
* udev_device
);
32 udev_device
* udev_device_get_parent(udev_device
* udev_device
);
33 udev_device
* udev_device_get_parent_with_subsystem_devtype(
34 udev_device
* udev_device
,
35 const char* subsystem
,
37 const char* udev_device_get_property_value(udev_device
* udev_device
,
39 const char* udev_device_get_subsystem(udev_device
* udev_device
);
40 const char* udev_device_get_sysattr_value(udev_device
* udev_device
,
42 const char* udev_device_get_sysname(udev_device
* udev_device
);
43 const char* udev_device_get_syspath(udev_device
* udev_device
);
44 udev_device
* udev_device_new_from_devnum(udev
* udev
, char type
, dev_t devnum
);
45 udev_device
* udev_device_new_from_subsystem_sysname(
47 const char* subsystem
,
49 udev_device
* udev_device_new_from_syspath(udev
* udev
, const char* syspath
);
50 void udev_device_unref(udev_device
* udev_device
);
51 int udev_enumerate_add_match_subsystem(udev_enumerate
* udev_enumerate
,
52 const char* subsystem
);
53 udev_list_entry
* udev_enumerate_get_list_entry(udev_enumerate
* udev_enumerate
);
54 udev_enumerate
* udev_enumerate_new(udev
* udev
);
55 int udev_enumerate_scan_devices(udev_enumerate
* udev_enumerate
);
56 void udev_enumerate_unref(udev_enumerate
* udev_enumerate
);
57 udev_list_entry
* udev_list_entry_get_next(udev_list_entry
* list_entry
);
58 const char* udev_list_entry_get_name(udev_list_entry
* list_entry
);
59 int udev_monitor_enable_receiving(udev_monitor
* udev_monitor
);
60 int udev_monitor_filter_add_match_subsystem_devtype(udev_monitor
* udev_monitor
,
61 const char* subsystem
,
63 int udev_monitor_get_fd(udev_monitor
* udev_monitor
);
64 udev_monitor
* udev_monitor_new_from_netlink(udev
* udev
, const char* name
);
65 udev_device
* udev_monitor_receive_device(udev_monitor
* udev_monitor
);
66 void udev_monitor_unref(udev_monitor
* udev_monitor
);
70 void (*log_fn
)(struct udev
* udev
, int priority
, const char* file
, int line
,
71 const char* fn
, const char* format
, va_list args
));
72 void udev_set_log_priority(struct udev
* udev
, int priority
);
73 void udev_unref(udev
* udev
);
77 #endif // DEVICE_UDEV_LINUX_UDEV_H_