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