Debian Codegraph @

man/sd_device_enumerator_get_device_first.xml

raw
1 <?xml version='1.0'?>
2 <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN"
3 "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd">
4 <!-- SPDX-License-Identifier: LGPL-2.1-or-later -->
5
6 <refentry id="sd_device_enumerator_get_device_first" xmlns:xi="http://www.w3.org/2001/XInclude">
7
8 <refentryinfo>
9 <title>sd_device_enumerator_get_device_first</title>
10 <productname>systemd</productname>
11 </refentryinfo>
12
13 <refmeta>
14 <refentrytitle>sd_device_enumerator_get_device_first</refentrytitle>
15 <manvolnum>3</manvolnum>
16 </refmeta>
17
18 <refnamediv>
19 <refname>sd_device_enumerator_get_device_first</refname>
20 <refname>sd_device_enumerator_get_device_next</refname>
21 <refname>sd_device_enumerator_get_subsystem_first</refname>
22 <refname>sd_device_enumerator_get_subsystem_next</refname>
23
24 <refpurpose>Enumerates devices and get the first or next device.</refpurpose>
25 </refnamediv>
26
27 <refsynopsisdiv>
28 <funcsynopsis>
29 <funcsynopsisinfo>#include &lt;systemd/sd-device.h&gt;</funcsynopsisinfo>
30
31 <funcprototype>
32 <funcdef>sd_device *<function>sd_device_enumerator_get_device_first</function></funcdef>
33 <paramdef>sd_device_enumerator *<parameter>enumerator</parameter></paramdef>
34 </funcprototype>
35
36 <funcprototype>
37 <funcdef>sd_device *<function>sd_device_enumerator_get_device_next</function></funcdef>
38 <paramdef>sd_device_enumerator *<parameter>enumerator</parameter></paramdef>
39 </funcprototype>
40
41 <funcprototype>
42 <funcdef>sd_device *<function>sd_device_enumerator_get_subsystem_first</function></funcdef>
43 <paramdef>sd_device_enumerator *<parameter>enumerator</parameter></paramdef>
44 </funcprototype>
45
46 <funcprototype>
47 <funcdef>sd_device *<function>sd_device_enumerator_get_subsystem_next</function></funcdef>
48 <paramdef>sd_device_enumerator *<parameter>enumerator</parameter></paramdef>
49 </funcprototype>
50 </funcsynopsis>
51 </refsynopsisdiv>
52
53 <refsect1>
54 <title>Description</title>
55 <para>The <function>sd_device_enumerator_get_device_first()</function> function enumerates all
56 matching devices under <filename>/sys/bus/<replaceable>SUBSYSTEM</replaceable>/devices/</filename>
57 and <filename>/sys/class/<replaceable>SUBSYSTEM</replaceable>/devices/</filename>,
58 and returns a pointer to the first <type>sd_device</type> object. If no devices are found,
59 <constant>NULL</constant> is returned.</para>
60
61 <para>The <function>sd_device_enumerator_get_device_next()</function> function returns the pointer
62 to the next <type>sd_device</type> from the <parameter>enumerator</parameter>. It should
63 be called after <function>sd_device_enumerator_get_device_first()</function> or after a previous
64 call to this function. If no more devices are available, <constant>NULL</constant> is returned.</para>
65
66 <para>The <function>sd_device_enumerator_get_subsystem_first()</function> function enumerates all
67 matching subsystem devices in <filename>/sys/module/</filename>, <filename>/sys/bus/</filename>,
68 and <filename>/sys/bus/<replaceable>SUBSYSTEM</replaceable>/drivers/</filename>
69 (such as <filename>/sys/bus/pci/drivers/</filename>). It returns a pointer to the first
70 <type>sd_device</type> object. If no devices are found <constant>NULL</constant> is returned.
71 Note that this does <emphasis>not</emphasis> enumerate devices provided by
72 <function>sd_device_enumerator_get_device_first/next()</function>. Hence, e.g.
73 <filename>/sys/bus/pci/</filename>, <filename>/sys/bus/pci/drivers/ahci/</filename> and so on are
74 enumerated, but <filename>/sys/bus/pci/devices/0000:00:00.0/</filename> and so on are not.</para>
75
76 <para>The <function>sd_device_enumerator_get_subsystem_next()</function> function returns the next
77 subsystem device from the enumerator. It should be called after
78 <function>sd_device_enumerator_get_subsystem_first()</function> or after a previous call to this
79 function. If no more subsystem devices are available, <constant>NULL</constant> is returned.</para>
80 </refsect1>
81
82 <refsect1>
83 <title>Return Value</title>
84 <para>On success, these functions return a pointer to an <type>sd_device</type> object.
85 On failure or when no more devices are available, <constant>NULL</constant> is returned. The
86 returned pointers are owned by the enumerator and should not be freed by the caller.</para>
87 </refsect1>
88
89 <refsect1>
90 <title>History</title>
91 <para><function>sd_device_enumerator_get_device_first()</function>,
92 <function>sd_device_enumerator_get_device_next()</function>,
93 <function>sd_device_enumerator_get_subsystem_first()</function>, and
94 <function>sd_device_enumerator_get_subsystem_next()</function> were introduced in systemd version
95 240.</para>
96 </refsect1>
97
98 <refsect1>
99 <title>See Also</title>
100
101 <para><simplelist type="inline">
102 <member><citerefentry><refentrytitle>sd_device_enumerator_new</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
103 <member><citerefentry><refentrytitle>sd_device_enumerator_add_match_parent</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
104 <member><citerefentry><refentrytitle>sd_device_ref</refentrytitle><manvolnum>3</manvolnum></citerefentry></member>
105 </simplelist></para>
106 </refsect1>
107
108 </refentry>