]> git.ipfire.org Git - thirdparty/systemd.git/blob - man/libudev.xml
Merge pull request #9302 from keszybz/drop-my-copyright-and-some-license-tags
[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 Copyright © 2015 David Herrmann <dh.herrmann@gmail.com>
12 -->
13
14 <refentry id="libudev"
15 xmlns:xi="http://www.w3.org/2001/XInclude">
16
17 <refentryinfo>
18 <title>libudev</title>
19 <productname>systemd</productname>
20
21 <authorgroup>
22 <author>
23 <contrib>Developer</contrib>
24 <firstname>David</firstname>
25 <surname>Herrmann</surname>
26 <email>dh.herrmann@gmail.com</email>
27 </author>
28 </authorgroup>
29 </refentryinfo>
30
31 <refmeta>
32 <refentrytitle>libudev</refentrytitle>
33 <manvolnum>3</manvolnum>
34 </refmeta>
35
36 <refnamediv>
37 <refname>libudev</refname>
38 <refpurpose>API for enumerating and introspecting local devices</refpurpose>
39 </refnamediv>
40
41 <refsynopsisdiv>
42 <funcsynopsis>
43 <funcsynopsisinfo>#include &lt;libudev.h&gt;</funcsynopsisinfo>
44 </funcsynopsis>
45
46 <cmdsynopsis>
47 <command>pkg-config --cflags --libs libudev</command>
48 </cmdsynopsis>
49 </refsynopsisdiv>
50
51 <refsect1>
52 <title>Description</title>
53
54 <para><filename>libudev.h</filename> provides APIs to introspect
55 and enumerate devices on the local system.</para>
56
57 <para>All functions require a libudev context to operate. This
58 context can be create via
59 <citerefentry><refentrytitle>udev_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
60 It is used to track library state and link objects together. No
61 global state is used by libudev, everything is always linked to
62 a udev context. Furthermore, multiple different udev contexts can
63 be used in parallel by multiple threads. However, a single context
64 must not be accessed by multiple threads in parallel. The caller
65 is responsible for providing suitable locking if they intend to use
66 it from multiple threads.</para>
67
68 <para>To introspect a local device on a system, a udev device
69 object can be created via
70 <citerefentry><refentrytitle>udev_device_new_from_syspath</refentrytitle><manvolnum>3</manvolnum></citerefentry>
71 and friends. The device object allows one to query current state,
72 read and write attributes and lookup properties of the device in
73 question.</para>
74
75 <para>To enumerate local devices on the system, an enumeration
76 object can be created via
77 <citerefentry><refentrytitle>udev_enumerate_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
78
79 <para>To monitor the local system for hotplugged or unplugged
80 devices, a monitor can be created via
81 <citerefentry><refentrytitle>udev_monitor_new_from_netlink</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
82
83 <para>Whenever libudev returns a list of objects, the
84 <citerefentry><refentrytitle>udev_list_entry</refentrytitle><manvolnum>3</manvolnum></citerefentry>
85 API should be used to iterate, access and modify those lists.</para>
86
87 <para>Furthermore, libudev also exports legacy APIs that should
88 not be used by new software (and as such are not documented as
89 part of this manual). This includes the hardware database known
90 as <constant>udev_hwdb</constant> (please use the new
91 <citerefentry><refentrytitle>sd-hwdb</refentrytitle><manvolnum>3</manvolnum></citerefentry>
92 API instead) and the <constant>udev_queue</constant> object to
93 query the udev daemon (which should not be used by new software
94 at all).</para>
95 </refsect1>
96
97 <refsect1>
98 <title>See Also</title>
99 <para>
100 <citerefentry><refentrytitle>udev_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
101 <citerefentry><refentrytitle>udev_device_new_from_syspath</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
102 <citerefentry><refentrytitle>udev_enumerate_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
103 <citerefentry><refentrytitle>udev_monitor_new_from_netlink</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
104 <citerefentry><refentrytitle>udev_list_entry</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
105 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
106 <citerefentry><refentrytitle>sd-device</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
107 <citerefentry><refentrytitle>sd-hwdb</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
108 <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry>
109 </para>
110 </refsect1>
111
112 </refentry>