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