]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/libudev.xml
Merge pull request #8822 from fbuihuu/rfc-tmpfiles-safe-upstream
[thirdparty/systemd.git] / man / libudev.xml
1 <?xml version='1.0'?> <!--*-nxml-*-->
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.2//EN"
3 "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [
4 <!ENTITY % entities SYSTEM "custom-entities.ent" >
5 %entities;
6 ]>
7
8 <!--
9 SPDX-License-Identifier: LGPL-2.1+
10 -->
11
12 <refentry id="libudev"
13 xmlns:xi="http://www.w3.org/2001/XInclude">
14
15 <refentryinfo>
16 <title>libudev</title>
17 <productname>systemd</productname>
18 </refentryinfo>
19
20 <refmeta>
21 <refentrytitle>libudev</refentrytitle>
22 <manvolnum>3</manvolnum>
23 </refmeta>
24
25 <refnamediv>
26 <refname>libudev</refname>
27 <refpurpose>API for enumerating and introspecting local devices</refpurpose>
28 </refnamediv>
29
30 <refsynopsisdiv>
31 <funcsynopsis>
32 <funcsynopsisinfo>#include &lt;libudev.h&gt;</funcsynopsisinfo>
33 </funcsynopsis>
34
35 <cmdsynopsis>
36 <command>pkg-config --cflags --libs libudev</command>
37 </cmdsynopsis>
38 </refsynopsisdiv>
39
40 <refsect1>
41 <title>Description</title>
42
43 <para><filename>libudev.h</filename> provides APIs to introspect
44 and enumerate devices on the local system.</para>
45
46 <para>All functions require a libudev context to operate. This
47 context can be create via
48 <citerefentry><refentrytitle>udev_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
49 It is used to track library state and link objects together. No
50 global state is used by libudev, everything is always linked to
51 a udev context. Furthermore, multiple different udev contexts can
52 be used in parallel by multiple threads. However, a single context
53 must not be accessed by multiple threads in parallel. The caller
54 is responsible for providing suitable locking if they intend to use
55 it from multiple threads.</para>
56
57 <para>To introspect a local device on a system, a udev device
58 object can be created via
59 <citerefentry><refentrytitle>udev_device_new_from_syspath</refentrytitle><manvolnum>3</manvolnum></citerefentry>
60 and friends. The device object allows one to query current state,
61 read and write attributes and lookup properties of the device in
62 question.</para>
63
64 <para>To enumerate local devices on the system, an enumeration
65 object can be created via
66 <citerefentry><refentrytitle>udev_enumerate_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
67
68 <para>To monitor the local system for hotplugged or unplugged
69 devices, a monitor can be created via
70 <citerefentry><refentrytitle>udev_monitor_new_from_netlink</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
71
72 <para>Whenever libudev returns a list of objects, the
73 <citerefentry><refentrytitle>udev_list_entry</refentrytitle><manvolnum>3</manvolnum></citerefentry>
74 API should be used to iterate, access and modify those lists.</para>
75
76 <para>Furthermore, libudev also exports legacy APIs that should
77 not be used by new software (and as such are not documented as
78 part of this manual). This includes the hardware database known
79 as <constant>udev_hwdb</constant> (please use the new
80 <citerefentry><refentrytitle>sd-hwdb</refentrytitle><manvolnum>3</manvolnum></citerefentry>
81 API instead) and the <constant>udev_queue</constant> object to
82 query the udev daemon (which should not be used by new software
83 at all).</para>
84 </refsect1>
85
86 <refsect1>
87 <title>See Also</title>
88 <para>
89 <citerefentry><refentrytitle>udev_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
90 <citerefentry><refentrytitle>udev_device_new_from_syspath</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
91 <citerefentry><refentrytitle>udev_enumerate_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
92 <citerefentry><refentrytitle>udev_monitor_new_from_netlink</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
93 <citerefentry><refentrytitle>udev_list_entry</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
94 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
95 <citerefentry><refentrytitle>sd-device</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
96 <citerefentry><refentrytitle>sd-hwdb</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
97 <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
98 </para>
99 </refsect1>
100
101 </refentry>