1LIBUDEV(3) libudev LIBUDEV(3)
2
3
4
6 libudev - API for enumerating and introspecting local devices
7
9 #include <libudev.h>
10
11 pkg-config --cflags --libs libudev
12
14 libudev.h provides APIs to introspect and enumerate devices on the
15 local system.
16
17 All functions require a libudev context to operate. This context can be
18 create via udev_new(3). It is used to track library state and link
19 objects together. No global state is used by libudev, everything is
20 always linked to a udev context. Furthermore, multiple different udev
21 contexts can be used in parallel by multiple threads. However, a single
22 context must not be accessed by multiple threads in parallel. The
23 caller is responsible for providing suitable locking if they intend to
24 use it from multiple threads.
25
26 To introspect a local device on a system, a udev device object can be
27 created via udev_device_new_from_syspath(3) and friends. The device
28 object allows one to query current state, read and write attributes and
29 lookup properties of the device in question.
30
31 To enumerate local devices on the system, an enumeration object can be
32 created via udev_enumerate_new(3).
33
34 To monitor the local system for hotplugged or unplugged devices, a
35 monitor can be created via udev_monitor_new_from_netlink(3).
36
37 Whenever libudev returns a list of objects, the udev_list_entry(3) API
38 should be used to iterate, access and modify those lists.
39
40 Furthermore, libudev also exports legacy APIs that should not be used
41 by new software (and as such are not documented as part of this
42 manual). This includes the hardware database known as udev_hwdb (please
43 use the new sd-hwdb(3) API instead) and the udev_queue object to query
44 the udev daemon (which should not be used by new software at all).
45
47 udev_new(3), udev_device_new_from_syspath(3), udev_enumerate_new(3),
48 udev_monitor_new_from_netlink(3), udev_list_entry(3), systemd(1), sd-
49 device(3), sd-hwdb(3), pkg-config(1)
50
51
52
53systemd 239 LIBUDEV(3)