Debian Codegraph @

upstream/fedora-44/man3/libudev.3

raw
1 '\" t
2 .TH "LIBUDEV" "3" "" "systemd 259.5" "libudev"
3 .\" -----------------------------------------------------------------
4 .\" * Define some portability stuff
5 .\" -----------------------------------------------------------------
6 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7 .\" http://bugs.debian.org/507673
8 .\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
9 .\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
10 .ie \n(.g .ds Aq \(aq
11 .el .ds Aq '
12 .\" -----------------------------------------------------------------
13 .\" * set default formatting
14 .\" -----------------------------------------------------------------
15 .\" disable hyphenation
16 .nh
17 .\" disable justification (adjust text to left margin only)
18 .ad l
19 .\" -----------------------------------------------------------------
20 .\" * MAIN CONTENT STARTS HERE *
21 .\" -----------------------------------------------------------------
22 .SH "NAME"
23 libudev \- API for enumerating and introspecting local devices
24 .SH "SYNOPSIS"
25 .sp
26 .ft B
27 .nf
28 #include <libudev\&.h>
29 .fi
30 .ft
31 .HP \w'\fBpkg\-config\ \-\-cflags\ \-\-libs\ libudev\fR\ 'u
32 \fBpkg\-config \-\-cflags \-\-libs libudev\fR
33 .SH "DESCRIPTION"
34 .PP
35 libudev\&.h
36 provides an API to introspect and enumerate devices on the local system\&. This library is supported, but should not be used in new projects\&. Please see
37 \fBsd-device\fR(3)
38 for an equivalent replacement with a more modern API\&.
39 .PP
40 All functions require a libudev context to operate\&. This context can be created via
41 \fBudev_new\fR(3)\&. It is used to track library state and link objects together\&. No global state is used by libudev, everything is always linked to a udev context\&.
42 .PP
43 All functions listed here are thread\-agnostic and only a single thread may operate on a given object at any given time\&. Different threads may access the same object at different times\&. Multiple independent objects may be used from different threads in parallel\&.
44 .PP
45 The code described here uses
46 \fBgetenv\fR(3), which is declared to be not multi\-thread\-safe\&. This means that the code calling the functions described here must not call
47 \fBsetenv\fR(3)
48 from a parallel thread\&. It is recommended to only do calls to
49 \fBsetenv()\fR
50 from an early phase of the program when no other threads have been started\&.
51 .PP
52 To introspect a local device on a system, a udev device object can be created via
53 \fBudev_device_new_from_syspath\fR(3)
54 and friends\&. The device object allows one to query current state, read and write attributes and lookup properties of the device in question\&.
55 .PP
56 To enumerate local devices on the system, an enumeration object can be created via
57 \fBudev_enumerate_new\fR(3)\&.
58 .PP
59 To monitor the local system for hotplugged or unplugged devices, a monitor can be created via
60 \fBudev_monitor_new_from_netlink\fR(3)\&.
61 .PP
62 Whenever libudev returns a list of objects, the
63 \fBudev_list_entry\fR(3)
64 API should be used to iterate, access and modify those lists\&.
65 .PP
66 Furthermore, libudev also exports legacy APIs that should not be used by new software (and as such are not documented as part of this manual)\&. This includes the hardware database known as
67 \fBudev_hwdb\fR
68 (please use the new
69 \fBsd-hwdb\fR(3)
70 API instead) and the
71 \fBudev_queue\fR
72 object to query the udev daemon (which should not be used by new software at all)\&.
73 .SH "SEE ALSO"
74 .PP
75 \fBudev_new\fR(3), \fBudev_device_new_from_syspath\fR(3), \fBudev_enumerate_new\fR(3), \fBudev_monitor_new_from_netlink\fR(3), \fBudev_list_entry\fR(3), \fBsystemd\fR(1), \fBsd-device\fR(3), \fBsd-hwdb\fR(3), \fBpkg-config\fR(1)