]>
Commit | Line | Data |
---|---|---|
06255d6f DH |
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 | <!-- | |
572eb058 ZJS |
9 | SPDX-License-Identifier: LGPL-2.1+ |
10 | ||
06255d6f DH |
11 | This file is part of systemd. |
12 | ||
13 | Copyright 2015 David Herrmann <dh.herrmann@gmail.com> | |
14 | ||
15 | systemd is free software; you can redistribute it and/or modify it | |
16 | under the terms of the GNU Lesser General Public License as published by | |
17 | the Free Software Foundation; either version 2.1 of the License, or | |
18 | (at your option) any later version. | |
19 | ||
20 | systemd is distributed in the hope that it will be useful, but | |
21 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
22 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
23 | Lesser General Public License for more details. | |
24 | ||
25 | You should have received a copy of the GNU Lesser General Public License | |
26 | along with systemd; If not, see <http://www.gnu.org/licenses/>. | |
27 | --> | |
28 | ||
29 | <refentry id="libudev" | |
30 | xmlns:xi="http://www.w3.org/2001/XInclude"> | |
31 | ||
32 | <refentryinfo> | |
33 | <title>libudev</title> | |
34 | <productname>systemd</productname> | |
35 | ||
36 | <authorgroup> | |
37 | <author> | |
38 | <contrib>Developer</contrib> | |
39 | <firstname>David</firstname> | |
40 | <surname>Herrmann</surname> | |
41 | <email>dh.herrmann@gmail.com</email> | |
42 | </author> | |
43 | </authorgroup> | |
44 | </refentryinfo> | |
45 | ||
46 | <refmeta> | |
47 | <refentrytitle>libudev</refentrytitle> | |
48 | <manvolnum>3</manvolnum> | |
49 | </refmeta> | |
50 | ||
51 | <refnamediv> | |
52 | <refname>libudev</refname> | |
53 | <refpurpose>API for enumerating and introspecting local devices</refpurpose> | |
54 | </refnamediv> | |
55 | ||
56 | <refsynopsisdiv> | |
57 | <funcsynopsis> | |
58 | <funcsynopsisinfo>#include <libudev.h></funcsynopsisinfo> | |
59 | </funcsynopsis> | |
60 | ||
61 | <cmdsynopsis> | |
62 | <command>pkg-config --cflags --libs libudev</command> | |
63 | </cmdsynopsis> | |
64 | </refsynopsisdiv> | |
65 | ||
66 | <refsect1> | |
67 | <title>Description</title> | |
68 | ||
69 | <para><filename>libudev.h</filename> provides APIs to introspect | |
70 | and enumerate devices on the local system.</para> | |
71 | ||
72 | <para>All functions require a libudev context to operate. This | |
73 | context can be create via | |
74 | <citerefentry><refentrytitle>udev_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>. | |
75 | It is used to track library state and link objects together. No | |
76 | global state is used by libudev, everything is always linked to | |
77 | a udev context. Furthermore, multiple different udev contexts can | |
78 | be used in parallel by multiple threads. However, a single context | |
79 | must not be accessed by multiple threads in parallel. The caller | |
a8eaaee7 | 80 | is responsible for providing suitable locking if they intend to use |
06255d6f DH |
81 | it from multiple threads.</para> |
82 | ||
83 | <para>To introspect a local device on a system, a udev device | |
84 | object can be created via | |
85 | <citerefentry><refentrytitle>udev_device_new_from_syspath</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
595bfe7d | 86 | and friends. The device object allows one to query current state, |
06255d6f DH |
87 | read and write attributes and lookup properties of the device in |
88 | question.</para> | |
89 | ||
90 | <para>To enumerate local devices on the system, an enumeration | |
91 | object can be created via | |
92 | <citerefentry><refentrytitle>udev_enumerate_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para> | |
93 | ||
94 | <para>To monitor the local system for hotplugged or unplugged | |
95 | devices, a monitor can be created via | |
96 | <citerefentry><refentrytitle>udev_monitor_new_from_netlink</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para> | |
97 | ||
98 | <para>Whenever libudev returns a list of objects, the | |
99 | <citerefentry><refentrytitle>udev_list_entry</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
100 | API should be used to iterate, access and modify those lists.</para> | |
101 | ||
102 | <para>Furthermore, libudev also exports legacy APIs that should | |
103 | not be used by new software (and as such are not documented as | |
b938cb90 | 104 | part of this manual). This includes the hardware database known |
06255d6f DH |
105 | as <constant>udev_hwdb</constant> (please use the new |
106 | <citerefentry><refentrytitle>sd-hwdb</refentrytitle><manvolnum>3</manvolnum></citerefentry> | |
107 | API instead) and the <constant>udev_queue</constant> object to | |
b938cb90 | 108 | query the udev daemon (which should not be used by new software |
06255d6f DH |
109 | at all).</para> |
110 | </refsect1> | |
111 | ||
112 | <refsect1> | |
113 | <title>See Also</title> | |
114 | <para> | |
115 | <citerefentry><refentrytitle>udev_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
116 | <citerefentry><refentrytitle>udev_device_new_from_syspath</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
117 | <citerefentry><refentrytitle>udev_enumerate_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
118 | <citerefentry><refentrytitle>udev_monitor_new_from_netlink</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
119 | <citerefentry><refentrytitle>udev_list_entry</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
120 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
121 | <citerefentry><refentrytitle>sd-device</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
122 | <citerefentry><refentrytitle>sd-hwdb</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
123 | <citerefentry project='die-net'><refentrytitle>pkg-config</refentrytitle><manvolnum>1</manvolnum></citerefentry> | |
124 | </para> | |
125 | </refsect1> | |
126 | ||
127 | </refentry> |