]> git.ipfire.org Git - thirdparty/systemd.git/blame - man/udev_device_new_from_syspath.xml
test-execute: Add tests for new PassEnvironment= directive
[thirdparty/systemd.git] / man / udev_device_new_from_syspath.xml
CommitLineData
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="udev_device_new_from_syspath"
28 xmlns:xi="http://www.w3.org/2001/XInclude">
29
30 <refentryinfo>
31 <title>udev_device_new_from_syspath</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>udev_device_new_from_syspath</refentrytitle>
46 <manvolnum>3</manvolnum>
47 </refmeta>
48
49 <refnamediv>
50 <refname>udev_device_new_from_syspath</refname>
51 <refname>udev_device_new_from_devnum</refname>
52 <refname>udev_device_new_from_subsystem_sysname</refname>
53 <refname>udev_device_new_from_device_id</refname>
54 <refname>udev_device_new_from_environment</refname>
55 <refname>udev_device_ref</refname>
56 <refname>udev_device_unref</refname>
57
58 <refpurpose>Create, acquire and release a udev device object</refpurpose>
59 </refnamediv>
60
61 <refsynopsisdiv>
62 <funcsynopsis>
63 <funcsynopsisinfo>#include &lt;libudev.h&gt;</funcsynopsisinfo>
64
65 <funcprototype>
66 <funcdef>struct udev_device *<function>udev_device_new_from_syspath</function></funcdef>
67 <paramdef>struct udev *<parameter>udev</parameter></paramdef>
68 <paramdef>const char *<parameter>syspath</parameter></paramdef>
69 </funcprototype>
70
71 <funcprototype>
72 <funcdef>struct udev_device *<function>udev_device_new_from_devnum</function></funcdef>
73 <paramdef>struct udev *<parameter>udev</parameter></paramdef>
74 <paramdef>char <parameter>type</parameter></paramdef>
75 <paramdef>dev_t <parameter>devnum</parameter></paramdef>
76 </funcprototype>
77
78 <funcprototype>
79 <funcdef>struct udev_device *<function>udev_device_new_from_subsystem_sysname</function></funcdef>
80 <paramdef>struct udev *<parameter>udev</parameter></paramdef>
81 <paramdef>const char *<parameter>subsystem</parameter></paramdef>
82 <paramdef>const char *<parameter>sysname</parameter></paramdef>
83 </funcprototype>
84
85 <funcprototype>
86 <funcdef>struct udev_device *<function>udev_device_new_from_device_id</function></funcdef>
87 <paramdef>struct udev *<parameter>udev</parameter></paramdef>
88 <paramdef>const char *<parameter>id</parameter></paramdef>
89 </funcprototype>
90
91 <funcprototype>
92 <funcdef>struct udev_device *<function>udev_device_new_from_environment</function></funcdef>
93 <paramdef>struct udev *<parameter>udev</parameter></paramdef>
94 </funcprototype>
95
96 <funcprototype>
97 <funcdef>struct udev_device *<function>udev_device_ref</function></funcdef>
98 <paramdef>struct udev_device *<parameter>udev_device</parameter></paramdef>
99 </funcprototype>
100
101 <funcprototype>
102 <funcdef>struct udev_device *<function>udev_device_unref</function></funcdef>
103 <paramdef>struct udev_device *<parameter>udev_device</parameter></paramdef>
104 </funcprototype>
105
106 </funcsynopsis>
107 </refsynopsisdiv>
108
00dbd902 109 <refsect1>
06255d6f
DH
110 <title>Description</title>
111
00dbd902
TG
112 <para><function>udev_device_new_from_syspath</function>,
113 <function>udev_device_new_from_devnum</function>,
114 <function>udev_device_new_from_subsystem_sysname</function>,
115 <function>udev_device_new_from_device_id</function>, and
116 <function>udev_device_new_from_environment</function>
117 allocate a new udev device object and returns a pointer to it. This
118 object is opaque and must not be accessed by the caller via different
119 means than functions provided by libudev. Initially, the reference count
120 of the device is 1. You can acquire further references, and drop
121 gained references via <function>udev_device_ref()</function> and
122 <function>udev_device_unref()</function>. Once the reference count hits 0,
123 the device object is destroyed and freed.</para>
124
125 <para><function>udev_device_new_from_syspath</function>,
126 <function>udev_device_new_from_devnum</function>,
127 <function>udev_device_new_from_subsystem_sysname</function>, and
128 <function>udev_device_new_from_device_id</function>
129 create the device object based on information found in
b938cb90 130 <filename>/sys</filename>, annotated with properties from the udev-internal
00dbd902
TG
131 device database. A syspath is any subdirectory of <filename>/sys</filename>,
132 with the restriction that a subdirectory of <filename>/sys/devices</filename>
133 (or a symlink to one) represents a real device and as such must contain
134 a <filename>uevent</filename> file. <function>udev_device_new_from_devnum</function>
135 takes a device type, which can be <constant>b</constant> for block devices or
136 <constant>c</constant> for character devices, as well as a devnum (see
137 <citerefentry><refentrytitle>makedev</refentrytitle><manvolnum>3</manvolnum></citerefentry>).
138 <function>udev_device_new_from_subsystem_sysname</function> looks up devices based
2ef24a16
TG
139 on the provided subsystem and sysname
140 (see <citerefentry><refentrytitle>udev_device_get_subsystem</refentrytitle><manvolnum>3</manvolnum></citerefentry>
141 and
142 <citerefentry><refentrytitle>udev_device_get_sysname</refentrytitle><manvolnum>3</manvolnum></citerefentry>)
143 and <function>udev_device_new_from_device_id</function> looks up devices based on the provided
a8eaaee7 144 device ID, which is a special string in one of the following four forms:
2ef24a16
TG
145 <table>
146 <title>Device ID strings</title>
147
148 <tgroup cols='2'>
149 <colspec colname='example' />
150 <colspec colname='explanation' />
151 <thead><row>
152 <entry>Example</entry>
153 <entry>Explanation</entry>
154 </row></thead>
155 <tbody>
156 <row><entry><varname>b8:2</varname></entry>
157 <entry>block device major:minor</entry></row>
158
159 <row><entry><varname>c128:1</varname></entry>
160 <entry>char device major:minor</entry></row>
161
162 <row><entry><varname>n3</varname></entry>
163 <entry>network device ifindex</entry></row>
164
165 <row><entry><varname>+sound:card29</varname></entry>
166 <entry>kernel driver core subsystem:device name</entry></row>
167 </tbody>
168 </tgroup>
169 </table>
00dbd902
TG
170 </para>
171
172 <para><function>udev_device_new_from_environment</function>
173 creates a device from the current environment (see
174 <citerefentry><refentrytitle>environ</refentrytitle><manvolnum>7</manvolnum></citerefentry>).
175 Each key-value pair is interpreted in the same way as if it was
176 received in an uevent (see
177 <citerefentry><refentrytitle>udev_monitor_receive_device</refentrytitle><manvolnum>3</manvolnum></citerefentry>).
178 The keys <constant>DEVPATH</constant>, <constant>SUBSYSTEM</constant>,
179 <constant>ACTION</constant>, and <constant>SEQNUM</constant> are mandatory.</para>
180
181 </refsect1>
06255d6f
DH
182
183 <refsect1>
184 <title>Return Value</title>
185
186 <para>On success, <function>udev_device_new_from_syspath()</function>,
187 <function>udev_device_new_from_devnum()</function>,
188 <function>udev_device_new_from_subsystem_sysname()</function>,
189 <function>udev_device_new_from_device_id()</function> and
190 <function>udev_device_new_from_environment()</function> return a
191 pointer to the allocated udev device. On failure,
192 <constant>NULL</constant> is returned.
193 <function>udev_device_ref()</function> returns the argument
194 that it was passed, unmodified.
195 <function>udev_device_unref()</function> always returns
196 <constant>NULL</constant>.</para>
197 </refsect1>
198
199 <refsect1>
200 <title>See Also</title>
201
202 <para>
203 <citerefentry><refentrytitle>udev_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
204 <citerefentry><refentrytitle>udev_device_get_syspath</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
205 <citerefentry><refentrytitle>udev_device_has_tag</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
206 <citerefentry><refentrytitle>udev_enumerate_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
207 <citerefentry><refentrytitle>udev_monitor_new_from_netlink</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
208 <citerefentry><refentrytitle>udev_list_entry</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
209 <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
210 </para>
211 </refsect1>
212
213</refentry>