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