summaryrefslogtreecommitdiffstats
path: root/upstream/fedora-40/man3/libudev.3
blob: ebc82bdb867129d898bc495f6b682fc3c81ac5f9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
'\" t
.TH "LIBUDEV" "3" "" "systemd 255" "libudev"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.\" http://bugs.debian.org/507673
.\" http://lists.gnu.org/archive/html/groff/2009-02/msg00013.html
.\" ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
.ie \n(.g .ds Aq \(aq
.el       .ds Aq '
.\" -----------------------------------------------------------------
.\" * set default formatting
.\" -----------------------------------------------------------------
.\" disable hyphenation
.nh
.\" disable justification (adjust text to left margin only)
.ad l
.\" -----------------------------------------------------------------
.\" * MAIN CONTENT STARTS HERE *
.\" -----------------------------------------------------------------
.SH "NAME"
libudev \- API for enumerating and introspecting local devices
.SH "SYNOPSIS"
.sp
.ft B
.nf
#include <libudev\&.h>
.fi
.ft
.HP \w'\fBpkg\-config\ \-\-cflags\ \-\-libs\ libudev\fR\ 'u
\fBpkg\-config \-\-cflags \-\-libs libudev\fR
.SH "DESCRIPTION"
.PP
libudev\&.h
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
\fBsd-device\fR(3)
for an equivalent replacement with a more modern API\&.
.PP
All functions require a libudev context to operate\&. This context can be created via
\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\&.
.PP
All functions listed here are thread\-agnostic and only a single specific thread may operate on a given object during its entire lifetime\&. It\*(Aqs safe to allocate multiple independent objects and use each from a specific thread in parallel\&. However, it\*(Aqs not safe to allocate such an object in one thread, and operate or free it from any other, even if locking is used to ensure these threads don\*(Aqt operate on it at the very same time\&.
.PP
The code described here uses
\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
\fBsetenv\fR(3)
from a parallel thread\&. It is recommended to only do calls to
\fBsetenv()\fR
from an early phase of the program when no other threads have been started\&.
.PP
To introspect a local device on a system, a udev device object can be created via
\fBudev_device_new_from_syspath\fR(3)
and friends\&. The device object allows one to query current state, read and write attributes and lookup properties of the device in question\&.
.PP
To enumerate local devices on the system, an enumeration object can be created via
\fBudev_enumerate_new\fR(3)\&.
.PP
To monitor the local system for hotplugged or unplugged devices, a monitor can be created via
\fBudev_monitor_new_from_netlink\fR(3)\&.
.PP
Whenever libudev returns a list of objects, the
\fBudev_list_entry\fR(3)
API should be used to iterate, access and modify those lists\&.
.PP
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
\fBudev_hwdb\fR
(please use the new
\fBsd-hwdb\fR(3)
API instead) and the
\fBudev_queue\fR
object to query the udev daemon (which should not be used by new software at all)\&.
.SH "SEE ALSO"
.PP
\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)