]>
Commit | Line | Data |
---|---|---|
06255d6f | 1 | <?xml version='1.0'?> <!--*-nxml-*--> |
3a54a157 | 2 | <!DOCTYPE refentry PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" |
06255d6f DH |
3 | "http://www.oasis-open.org/docbook/xml/4.2/docbookx.dtd" [ |
4 | <!ENTITY % entities SYSTEM "custom-entities.ent" > | |
5 | %entities; | |
6 | ]> | |
0307f791 | 7 | <!-- SPDX-License-Identifier: LGPL-2.1+ --> |
06255d6f DH |
8 | |
9 | <refentry id="udev_device_has_tag" | |
10 | xmlns:xi="http://www.w3.org/2001/XInclude"> | |
11 | ||
12 | <refentryinfo> | |
13 | <title>udev_device_has_tag</title> | |
14 | <productname>systemd</productname> | |
06255d6f DH |
15 | </refentryinfo> |
16 | ||
17 | <refmeta> | |
18 | <refentrytitle>udev_device_has_tag</refentrytitle> | |
19 | <manvolnum>3</manvolnum> | |
20 | </refmeta> | |
21 | ||
22 | <refnamediv> | |
23 | <refname>udev_device_has_tag</refname> | |
278fdd06 | 24 | <refname>udev_device_has_current_tag</refname> |
06255d6f DH |
25 | <refname>udev_device_get_devlinks_list_entry</refname> |
26 | <refname>udev_device_get_properties_list_entry</refname> | |
27 | <refname>udev_device_get_tags_list_entry</refname> | |
278fdd06 | 28 | <refname>udev_device_get_current_tags_list_entry</refname> |
06255d6f DH |
29 | <refname>udev_device_get_sysattr_list_entry</refname> |
30 | <refname>udev_device_get_property_value</refname> | |
31 | <refname>udev_device_get_sysattr_value</refname> | |
32 | <refname>udev_device_set_sysattr_value</refname> | |
33 | ||
34 | <refpurpose>Retrieve or set device attributes</refpurpose> | |
35 | </refnamediv> | |
36 | ||
37 | <refsynopsisdiv> | |
38 | <funcsynopsis> | |
39 | <funcsynopsisinfo>#include <libudev.h></funcsynopsisinfo> | |
40 | ||
278fdd06 LP |
41 | <funcprototype> |
42 | <funcdef>int <function>udev_device_has_tag</function></funcdef> | |
43 | <paramdef>struct udev_device *<parameter>udev_device</parameter></paramdef> | |
44 | <paramdef>const char *<parameter>tag</parameter></paramdef> | |
45 | </funcprototype> | |
46 | ||
47 | <funcprototype> | |
48 | <funcdef>int <function>udev_device_has_current_tag</function></funcdef> | |
49 | <paramdef>struct udev_device *<parameter>udev_device</parameter></paramdef> | |
50 | <paramdef>const char *<parameter>tag</parameter></paramdef> | |
51 | </funcprototype> | |
52 | ||
06255d6f DH |
53 | <funcprototype> |
54 | <funcdef>struct udev_list_entry *<function>udev_device_get_devlinks_list_entry</function></funcdef> | |
55 | <paramdef>struct udev_device *<parameter>udev_device</parameter></paramdef> | |
56 | </funcprototype> | |
57 | ||
58 | <funcprototype> | |
59 | <funcdef>struct udev_list_entry *<function>udev_device_get_properties_list_entry</function></funcdef> | |
60 | <paramdef>struct udev_device *<parameter>udev_device</parameter></paramdef> | |
61 | </funcprototype> | |
62 | ||
63 | <funcprototype> | |
64 | <funcdef>struct udev_list_entry *<function>udev_device_get_tags_list_entry</function></funcdef> | |
65 | <paramdef>struct udev_device *<parameter>udev_device</parameter></paramdef> | |
66 | </funcprototype> | |
67 | ||
68 | <funcprototype> | |
278fdd06 | 69 | <funcdef>struct udev_list_entry *<function>udev_device_get_current_tags_list_entry</function></funcdef> |
06255d6f DH |
70 | <paramdef>struct udev_device *<parameter>udev_device</parameter></paramdef> |
71 | </funcprototype> | |
72 | ||
73 | <funcprototype> | |
278fdd06 | 74 | <funcdef>struct udev_list_entry *<function>udev_device_get_sysattr_list_entry</function></funcdef> |
06255d6f | 75 | <paramdef>struct udev_device *<parameter>udev_device</parameter></paramdef> |
06255d6f DH |
76 | </funcprototype> |
77 | ||
78 | <funcprototype> | |
278fdd06 | 79 | <funcdef>const char *<function>udev_device_get_property_value</function></funcdef> |
06255d6f | 80 | <paramdef>struct udev_device *<parameter>udev_device</parameter></paramdef> |
278fdd06 | 81 | <paramdef>const char *<parameter>key</parameter></paramdef> |
06255d6f DH |
82 | </funcprototype> |
83 | ||
84 | <funcprototype> | |
85 | <funcdef>const char *<function>udev_device_get_sysattr_value</function></funcdef> | |
86 | <paramdef>struct udev_device *<parameter>udev_device</parameter></paramdef> | |
87 | <paramdef>const char *<parameter>sysattr</parameter></paramdef> | |
88 | </funcprototype> | |
89 | ||
90 | <funcprototype> | |
91 | <funcdef>int <function>udev_device_set_sysattr_value</function></funcdef> | |
92 | <paramdef>struct udev_device *<parameter>udev_device</parameter></paramdef> | |
93 | <paramdef>const char *<parameter>sysattr</parameter></paramdef> | |
94 | <paramdef>const char *<parameter>value</parameter></paramdef> | |
95 | </funcprototype> | |
96 | ||
97 | </funcsynopsis> | |
98 | </refsynopsisdiv> | |
99 | ||
278fdd06 | 100 | <refsect1> |
06255d6f DH |
101 | <title>Description</title> |
102 | ||
278fdd06 LP |
103 | <para><function>udev_device_has_tag()</function> returns a valuer larger than zero if the specified |
104 | device object has the indicated tag assigned to it, and zero otherwise. See | |
105 | <citerefentry><refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum></citerefentry> for details on | |
106 | the tags concept. <function>udev_device_has_current_tag()</function> executes a similar check, however | |
107 | only determines whether the indicated tag was set as result of the most recent event seen for the | |
108 | device. Tags are "sticky", i.e. once set for a device they remain on the device until the device is | |
109 | unplugged, even if the rules run for later events of the same device do not set them anymore. Any tag for | |
110 | which <function>udev_device_has_current_tag()</function> returns true will hence also return true when | |
111 | passed to <function>udev_device_has_tag()</function>, but the opposite might not be true, in case a tag is | |
112 | no longer configured by the rules applied to the most recent device even.</para> | |
113 | ||
114 | <para><function>udev_device_get_tags_list_entry()</function> returns a a | |
115 | <function>udev_list_entry</function> object, encapsulating a list of tags set for the specified | |
116 | device. Similar, <function>udev_device_get_current_tags_list_entry()</function> returns a list of tags | |
117 | set for the specified device as effect of the most recent device event seen (see above for details on the | |
118 | difference).</para> | |
119 | </refsect1> | |
06255d6f DH |
120 | |
121 | <refsect1> | |
122 | <title>Return Value</title> | |
123 | ||
278fdd06 LP |
124 | <para>On success, <function>udev_device_has_tag()</function> and |
125 | <function>udev_device_has_current_tag()</function> return positive or <constant>0</constant>, depending | |
126 | on whether the device has the given tag or not. On failure, a negative error code is returned.</para> | |
127 | ||
128 | <para>On success, <function>udev_device_get_devlinks_list_entry()</function>, | |
06255d6f | 129 | <function>udev_device_get_properties_list_entry()</function>, |
278fdd06 LP |
130 | <function>udev_device_get_tags_list_entry()</function>, |
131 | <function>udev_device_get_current_tags_list_entry()</function> and | |
132 | <function>udev_device_get_sysattr_list_entry()</function> return a pointer to the first entry of the | |
133 | retrieved list. If that list is empty, or if an error occurred, <constant>NULL</constant> is | |
06255d6f DH |
134 | returned.</para> |
135 | ||
136 | <para>On success, | |
137 | <function>udev_device_get_property_value()</function> and | |
138 | <function>udev_device_get_sysattr_value()</function> return a | |
139 | pointer to a constant string of the requested value. On error, | |
8e44f571 SM |
140 | <constant>NULL</constant> is returned. Attributes that may |
141 | contain <constant>NUL</constant> bytes should not be retrieved | |
142 | with <function>udev_device_get_sysattr_value()</function>; | |
143 | instead, read them directly from the files within the device's | |
144 | <property>syspath</property>.</para> | |
06255d6f DH |
145 | |
146 | <para>On success, | |
147 | <function>udev_device_set_sysattr_value()</function> returns | |
148 | an integer greater than, or equal to, <constant>0</constant>. | |
8e44f571 SM |
149 | On failure, a negative error code is returned. Values that |
150 | contain <constant>NUL</constant> bytes should not be set with | |
151 | this function; instead, write them directly to the files within | |
152 | the device's <property>syspath</property>.</para> | |
06255d6f DH |
153 | </refsect1> |
154 | ||
155 | <refsect1> | |
156 | <title>See Also</title> | |
157 | ||
158 | <para> | |
278fdd06 | 159 | <citerefentry><refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum></citerefentry>, |
06255d6f DH |
160 | <citerefentry><refentrytitle>udev_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>, |
161 | <citerefentry><refentrytitle>udev_device_new_from_syspath</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
162 | <citerefentry><refentrytitle>udev_device_get_syspath</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
163 | <citerefentry><refentrytitle>udev_enumerate_new</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
164 | <citerefentry><refentrytitle>udev_monitor_new_from_netlink</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
165 | <citerefentry><refentrytitle>udev_list_entry</refentrytitle><manvolnum>3</manvolnum></citerefentry>, | |
166 | <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, | |
167 | </para> | |
168 | </refsect1> | |
169 | ||
170 | </refentry> |