]> git.ipfire.org Git - thirdparty/systemd.git/blobdiff - man/udev_device_new_from_syspath.xml
test-execute: change log level from error to notice
[thirdparty/systemd.git] / man / udev_device_new_from_syspath.xml
index c3c0d763e4d8bac58dd9307a9d7b43b18e86fe23..13f1b4ccef3af284affe1b76583cefac9b724de3 100644 (file)
@@ -6,6 +6,8 @@
 ]>
 
 <!--
+  SPDX-License-Identifier: LGPL-2.1+
+
   This file is part of systemd.
 
   Copyright 2015 David Herrmann <dh.herrmann@gmail.com>
     </funcsynopsis>
   </refsynopsisdiv>
 
-  <!--<refsect1>
+  <refsect1>
     <title>Description</title>
 
-    <para>XXX: Add some description.</para>
-  </refsect1>-->
+    <para><function>udev_device_new_from_syspath</function>,
+    <function>udev_device_new_from_devnum</function>,
+    <function>udev_device_new_from_subsystem_sysname</function>,
+    <function>udev_device_new_from_device_id</function>, and
+    <function>udev_device_new_from_environment</function>
+    allocate a new udev device object and returns a pointer to it. This
+    object is opaque and must not be accessed by the caller via different
+    means than functions provided by libudev. Initially, the reference count
+    of the device is 1. You can acquire further references, and drop
+    gained references via <function>udev_device_ref()</function> and
+    <function>udev_device_unref()</function>. Once the reference count hits 0,
+    the device object is destroyed and freed.</para>
+
+    <para><function>udev_device_new_from_syspath</function>,
+    <function>udev_device_new_from_devnum</function>,
+    <function>udev_device_new_from_subsystem_sysname</function>, and
+    <function>udev_device_new_from_device_id</function>
+    create the device object based on information found in
+    <filename>/sys</filename>, annotated with properties from the udev-internal
+    device database. A syspath is any subdirectory of <filename>/sys</filename>,
+    with the restriction that a subdirectory of <filename>/sys/devices</filename>
+    (or a symlink to one) represents a real device and as such must contain
+    a <filename>uevent</filename> file. <function>udev_device_new_from_devnum</function>
+    takes a device type, which can be <constant>b</constant> for block devices or
+    <constant>c</constant> for character devices, as well as a devnum (see
+    <citerefentry project='man-pages'><refentrytitle>makedev</refentrytitle><manvolnum>3</manvolnum></citerefentry>).
+    <function>udev_device_new_from_subsystem_sysname</function> looks up devices based
+    on the provided subsystem and sysname
+    (see <citerefentry><refentrytitle>udev_device_get_subsystem</refentrytitle><manvolnum>3</manvolnum></citerefentry>
+    and
+    <citerefentry><refentrytitle>udev_device_get_sysname</refentrytitle><manvolnum>3</manvolnum></citerefentry>)
+    and <function>udev_device_new_from_device_id</function> looks up devices based on the provided
+    device ID, which is a special string in one of the following four forms:
+    <table>
+      <title>Device ID strings</title>
+
+      <tgroup cols='2'>
+        <colspec colname='example' />
+        <colspec colname='explanation' />
+        <thead><row>
+          <entry>Example</entry>
+          <entry>Explanation</entry>
+        </row></thead>
+        <tbody>
+          <row><entry><varname>b8:2</varname></entry>
+          <entry>block device major:minor</entry></row>
+
+          <row><entry><varname>c128:1</varname></entry>
+          <entry>char device major:minor</entry></row>
+
+          <row><entry><varname>n3</varname></entry>
+          <entry>network device ifindex</entry></row>
+
+          <row><entry><varname>+sound:card29</varname></entry>
+          <entry>kernel driver core subsystem:device name</entry></row>
+        </tbody>
+      </tgroup>
+    </table>
+    </para>
+
+    <para><function>udev_device_new_from_environment</function>
+    creates a device from the current environment (see
+    <citerefentry project='man-pages'><refentrytitle>environ</refentrytitle><manvolnum>7</manvolnum></citerefentry>).
+    Each key-value pair is interpreted in the same way as if it was
+    received in an uevent (see
+    <citerefentry><refentrytitle>udev_monitor_receive_device</refentrytitle><manvolnum>3</manvolnum></citerefentry>).
+    The keys <constant>DEVPATH</constant>, <constant>SUBSYSTEM</constant>,
+    <constant>ACTION</constant>, and <constant>SEQNUM</constant> are mandatory.</para>
+
+  </refsect1>
 
   <refsect1>
     <title>Return Value</title>
     <function>udev_device_new_from_device_id()</function> and
     <function>udev_device_new_from_environment()</function> return a
     pointer to the allocated udev device. On failure,
-    <constant>NULL</constant> is returned.
+    <constant>NULL</constant> is returned,
+    and <varname>errno</varname> is set appropriately.
     <function>udev_device_ref()</function> returns the argument
     that it was passed, unmodified.
     <function>udev_device_unref()</function> always returns