| 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="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> |
| 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> |
| 24 |
<refname>udev_device_has_current_tag</refname> |
| 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> |
| 28 |
<refname>udev_device_get_current_tags_list_entry</refname> |
| 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 |
|
| 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 |
|
| 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> |
| 69 |
<funcdef>struct udev_list_entry *<function>udev_device_get_current_tags_list_entry</function></funcdef> |
| 70 |
<paramdef>struct udev_device *<parameter>udev_device</parameter></paramdef> |
| 71 |
</funcprototype> |
| 72 |
|
| 73 |
<funcprototype> |
| 74 |
<funcdef>struct udev_list_entry *<function>udev_device_get_sysattr_list_entry</function></funcdef> |
| 75 |
<paramdef>struct udev_device *<parameter>udev_device</parameter></paramdef> |
| 76 |
</funcprototype> |
| 77 |
|
| 78 |
<funcprototype> |
| 79 |
<funcdef>const char *<function>udev_device_get_property_value</function></funcdef> |
| 80 |
<paramdef>struct udev_device *<parameter>udev_device</parameter></paramdef> |
| 81 |
<paramdef>const char *<parameter>key</parameter></paramdef> |
| 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 |
|
| 100 |
<refsect1> |
| 101 |
<title>Description</title> |
| 102 |
|
| 103 |
<para><function>udev_device_has_tag()</function> returns a value 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 |
| 115 |
<structname>udev_list_entry</structname> 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> |
| 120 |
|
| 121 |
<refsect1> |
| 122 |
<title>Return Value</title> |
| 123 |
|
| 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>, |
| 129 |
<function>udev_device_get_properties_list_entry()</function>, |
| 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 |
| 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, |
| 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> |
| 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>. |
| 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> |
| 153 |
</refsect1> |
| 154 |
|
| 155 |
<refsect1> |
| 156 |
<title>History</title> |
| 157 |
<para><function>udev_device_get_devlinks_list_entry()</function>, |
| 158 |
<function>udev_device_get_properties_list_entry()</function>, |
| 159 |
<function>udev_device_get_tags_list_entry()</function>, |
| 160 |
<function>udev_device_get_sysattr_list_entry()</function>, |
| 161 |
<function>udev_device_get_property_value()</function>, |
| 162 |
<function>udev_device_has_tag()</function>, |
| 163 |
<function>udev_device_get_sysattr_value()</function>, and |
| 164 |
<function>udev_device_set_sysattr_value()</function> were added in version 221.</para> |
| 165 |
<para><function>udev_device_has_current_tag()</function> and |
| 166 |
<function>udev_device_get_current_tags_list_entry()</function> were added in version 247.</para> |
| 167 |
</refsect1> |
| 168 |
|
| 169 |
<refsect1> |
| 170 |
<title>See Also</title> |
| 171 |
|
| 172 |
<para><simplelist type="inline"> |
| 173 |
<member><citerefentry><refentrytitle>udev</refentrytitle><manvolnum>7</manvolnum></citerefentry></member> |
| 174 |
<member><citerefentry><refentrytitle>udev_new</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 175 |
<member><citerefentry><refentrytitle>udev_device_new_from_syspath</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 176 |
<member><citerefentry><refentrytitle>udev_device_get_syspath</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 177 |
<member><citerefentry><refentrytitle>udev_enumerate_new</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 178 |
<member><citerefentry><refentrytitle>udev_monitor_new_from_netlink</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 179 |
<member><citerefentry><refentrytitle>udev_list_entry</refentrytitle><manvolnum>3</manvolnum></citerefentry></member> |
| 180 |
<member><citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry></member> |
| 181 |
</simplelist></para> |
| 182 |
</refsect1> |
| 183 |
|
| 184 |
</refentry> |