libudev-device.c revision 4189708ad0cde8e211e38d27de943579772f8869
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers This file is part of systemd.
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers Copyright 2008-2012 Kay Sievers <kay@vrfy.org>
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers Copyright 2015 Tom Gundersen <teg@jklm.no>
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers systemd is free software; you can redistribute it and/or modify it
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers under the terms of the GNU Lesser General Public License as published by
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers the Free Software Foundation; either version 2.1 of the License, or
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers (at your option) any later version.
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers systemd is distributed in the hope that it will be useful, but
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers WITHOUT ANY WARRANTY; without even the implied warranty of
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers Lesser General Public License for more details.
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers You should have received a copy of the GNU Lesser General Public License
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers along with systemd; If not, see <http://www.gnu.org/licenses/>.
ad37f393fa97f4274cc3bf97a0d8c388a429037eKay Sievers * SECTION:libudev-device
472780d8b1ec3f3f4ff78eb21a013136e5aa1cfeKay Sievers * @short_description: kernel sys devices
214daa72cb0c72ea78d1eccd5ffe630a1e04b2f7Sean McGovern * Representation of kernel sys devices. Devices are uniquely identified
214daa72cb0c72ea78d1eccd5ffe630a1e04b2f7Sean McGovern * by their syspath, every device has exactly one path in the kernel sys
0d6ce9236f61cb991d7e8f2359d818e41ead0cf5Kay Sievers * filesystem. Devices usually belong to a kernel subsystem, and have
0d6ce9236f61cb991d7e8f2359d818e41ead0cf5Kay Sievers * a unique name inside that subsystem.
a8eaaee72a2f06e0fb64fb71de3b71ecba31dafbJan Engelhardt * udev_device_get_seqnum:
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers * @udev_device: udev device
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers * This is only valid if the device was received through a monitor. Devices read from
a8eaaee72a2f06e0fb64fb71de3b71ecba31dafbJan Engelhardt * sys do not have a sequence number.
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers * Returns: the kernel event sequence number, or 0 if there is no sequence number available.
de892aea1c486b59e04884268b612081d1660514Kay Sievers_public_ unsigned long long int udev_device_get_seqnum(struct udev_device *udev_device)
decd634e801bee2c554edb35383cc9d43417a850Kay Sievers unsigned long long ret;
decd634e801bee2c554edb35383cc9d43417a850Kay Sievers r = sd_device_get_property_value(udev_device->device, "SEQNUM", &seqnum);
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers else if (r < 0) {
f610d6de38119b372b377ec41b2a6089872d3294Kay Sievers if (r < 0) {
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers * udev_device_get_devnum:
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering * @udev_device: udev device
19aa72f74e41045510b4af3f1415b419d42ff20bTom Gundersen * Get the device major/minor number.
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering * Returns: the dev_t number.
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering_public_ dev_t udev_device_get_devnum(struct udev_device *udev_device)
a5c32cff1f56afe6f0c6c70d91a88a7a8238b2d7Harald Hoyer assert_return_errno(udev_device, makedev(0, 0), EINVAL);
07630cea1f3a845c09309f197ac7c4f11edd3b62Lennart Poettering r = sd_device_get_devnum(udev_device->device, &devnum);
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers if (r < 0) {
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers return makedev(0, 0);
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * udev_device_get_driver:
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * @udev_device: udev device
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * Get the kernel driver name.
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * Returns: the driver name string, or #NULL if there is no driver attached.
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers_public_ const char *udev_device_get_driver(struct udev_device *udev_device)
984c4348ff14d29c526d3d372daa82e278eeb5b4Kay Sievers r = sd_device_get_driver(udev_device->device, &driver);
d4b687c96adf207f0878aebf3ce3371f6160687fKay Sievers if (r < 0) {
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers * udev_device_get_devtype:
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers * @udev_device: udev device
c0a43734ca84a3c9170d4a2d7f4d329b9ef47abcTom Gundersen * Retrieve the devtype string of the udev device.
c0a43734ca84a3c9170d4a2d7f4d329b9ef47abcTom Gundersen * Returns: the devtype name of the udev device, or #NULL if it can not be determined
c0a43734ca84a3c9170d4a2d7f4d329b9ef47abcTom Gundersen_public_ const char *udev_device_get_devtype(struct udev_device *udev_device)
309b578d313b363974b99e48f0e378111cc1fa91Tom Gundersen r = sd_device_get_devtype(udev_device->device, &devtype);
c0a43734ca84a3c9170d4a2d7f4d329b9ef47abcTom Gundersen * udev_device_get_subsystem:
c0a43734ca84a3c9170d4a2d7f4d329b9ef47abcTom Gundersen * @udev_device: udev device
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * Retrieve the subsystem string of the udev device. The string does not
c0a43734ca84a3c9170d4a2d7f4d329b9ef47abcTom Gundersen * contain any "/".
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers * Returns: the subsystem name of the udev device, or #NULL if it can not be determined
137661d87525a3c339afd2804e577532d58d3fbcKay Sievers_public_ const char *udev_device_get_subsystem(struct udev_device *udev_device)
0454229c100a2113ba82df55703436d6cb2c492bJason S. McMullan r = sd_device_get_subsystem(udev_device->device, &subsystem);
de892aea1c486b59e04884268b612081d1660514Kay Sievers * udev_device_get_property_value:
de892aea1c486b59e04884268b612081d1660514Kay Sievers * @udev_device: udev device
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * @key: property name
3058e017fced6d5c8712e10c8c1477421bc1e960Thadeu Lima de Souza Cascardo * Get the value of a given property.
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers * Returns: the property string, or #NULL if there is no such property.
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers_public_ const char *udev_device_get_property_value(struct udev_device *udev_device, const char *key)
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers assert_return_errno(udev_device && key, NULL, EINVAL);
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers r = sd_device_get_property_value(udev_device->device, key, &value);
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers if (r < 0) {
214daa72cb0c72ea78d1eccd5ffe630a1e04b2f7Sean McGovernstruct udev_device *udev_device_new(struct udev *udev) {
1fa2f38f0f011010bf57522b42fcc168856a7003Zbigniew Jędrzejewski-Szmek assert_return_errno(udev, NULL, EINVAL);
1fa2f38f0f011010bf57522b42fcc168856a7003Zbigniew Jędrzejewski-Szmek udev_device = new0(struct udev_device, 1);
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers udev_list_init(udev, &udev_device->properties, true);
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers udev_list_init(udev, &udev_device->sysattrs, true);
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers udev_list_init(udev, &udev_device->devlinks, true);
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers * udev_device_new_from_syspath:
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers * @udev: udev library context
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers * @syspath: sys device path including sys directory
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers * Create new udev device, and fill in information from the sys
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers * device and the udev database entry. The syspath is the absolute
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers * path to the device, including the sys mount point.
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers * The initial refcount is 1, and needs to be decremented to
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers * release the resources of the udev device.
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers * Returns: a new udev device, or #NULL, if it does not exist
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers_public_ struct udev_device *udev_device_new_from_syspath(struct udev *udev, const char *syspath) {
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers r = sd_device_new_from_syspath(&udev_device->device, syspath);
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers if (r < 0) {
214daa72cb0c72ea78d1eccd5ffe630a1e04b2f7Sean McGovern * udev_device_new_from_devnum:
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers * @udev: udev library context
d5a89d7dc17a5ba5cf4fc71f82963c5c94a31c3dKay Sievers * @type: char or block device
3058e017fced6d5c8712e10c8c1477421bc1e960Thadeu Lima de Souza Cascardo * @devnum: device major/minor number
1328f66ad16b5afeb5684858c27e121a46c1959eKay Sievers * Create new udev device, and fill in information from the sys
16f948cb208f1db9a1665f07ac9b22e416dc19d4Tom Gundersen * device and the udev database entry. The device is looked-up
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers * by its major/minor number and type. Character and block device
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers * numbers are not unique across the two types.
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers * The initial refcount is 1, and needs to be decremented to
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers * release the resources of the udev device.
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * Returns: a new udev device, or #NULL, if it does not exist
0035597a30d120f70df2dd7da3d6128fb8ba6051Kay Sievers_public_ struct udev_device *udev_device_new_from_devnum(struct udev *udev, char type, dev_t devnum)
54683f0f9b97a8f88aaf4fbb45b4d729057b101cTom Gundersen r = sd_device_new_from_devnum(&udev_device->device, type, devnum);
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * udev_device_new_from_device_id:
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * @udev: udev library context
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * @id: text string identifying a kernel device
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * Create new udev device, and fill in information from the sys
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * device and the udev database entry. The device is looked-up
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * by a special string:
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * b8:2 - block device major:minor
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * c128:1 - char device major:minor
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * n3 - network device ifindex
984c4348ff14d29c526d3d372daa82e278eeb5b4Kay Sievers * +sound:card29 - kernel driver core subsystem:device name
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * The initial refcount is 1, and needs to be decremented to
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * release the resources of the udev device.
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * Returns: a new udev device, or #NULL, if it does not exist
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers_public_ struct udev_device *udev_device_new_from_device_id(struct udev *udev, const char *id)
984c4348ff14d29c526d3d372daa82e278eeb5b4Kay Sievers r = sd_device_new_from_device_id(&udev_device->device, id);
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers if (r < 0) {
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * udev_device_new_from_subsystem_sysname:
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * @udev: udev library context
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * @subsystem: the subsystem of the device
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * @sysname: the name of the device
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * Create new udev device, and fill in information from the sys device
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * and the udev database entry. The device is looked up by the subsystem
f7340ab269828d917cd1281e33e6dd4fdfee67b3Torstein Husebø * and name string of the device, like "mem" / "zero", or "block" / "sda".
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * The initial refcount is 1, and needs to be decremented to
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * release the resources of the udev device.
d5a89d7dc17a5ba5cf4fc71f82963c5c94a31c3dKay Sievers * Returns: a new udev device, or #NULL, if it does not exist
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers_public_ struct udev_device *udev_device_new_from_subsystem_sysname(struct udev *udev, const char *subsystem, const char *sysname)
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers r = sd_device_new_from_subsystem_sysname(&udev_device->device, subsystem, sysname);
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers if (r < 0) {
3b64e4d4f40baac56148c7d333d6a0053358ec7aTom Gundersen * udev_device_new_from_environment
984c4348ff14d29c526d3d372daa82e278eeb5b4Kay Sievers * @udev: udev library context
984c4348ff14d29c526d3d372daa82e278eeb5b4Kay Sievers * Create new udev device, and fill in information from the
984c4348ff14d29c526d3d372daa82e278eeb5b4Kay Sievers * current process environment. This only works reliable if
f4ddacbd4de0f159ec598f8ad690466a84787ec5Kay Sievers * the process is called from a udev rule. It is usually used
b5dd8148730db080b48b874c214f8f74ae787d6bZbigniew Jędrzejewski-Szmek * for tools executed from IMPORT= rules.
f4ddacbd4de0f159ec598f8ad690466a84787ec5Kay Sievers * The initial refcount is 1, and needs to be decremented to
f4ddacbd4de0f159ec598f8ad690466a84787ec5Kay Sievers * release the resources of the udev device.
f4ddacbd4de0f159ec598f8ad690466a84787ec5Kay Sievers * Returns: a new udev device, or #NULL, if it does not exist
984c4348ff14d29c526d3d372daa82e278eeb5b4Kay Sievers_public_ struct udev_device *udev_device_new_from_environment(struct udev *udev)
3b64e4d4f40baac56148c7d333d6a0053358ec7aTom Gundersen r = device_new_from_strv(&udev_device->device, environ);
e0d4a0ac06afb856c9370c5c256f0f7bb7efdc8eHendrik Bruecknerstatic struct udev_device *device_new_from_parent(struct udev_device *child)
e0d4a0ac06afb856c9370c5c256f0f7bb7efdc8eHendrik Brueckner r = sd_device_get_parent(child->device, &parent->device);
e0d4a0ac06afb856c9370c5c256f0f7bb7efdc8eHendrik Brueckner /* the parent is unref'ed with the child, so take a ref from libudev as well */
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * udev_device_get_parent:
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers * @udev_device: the device to start searching from
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers * Find the next parent device, and fill in information from the sys
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers * device and the udev database entry.
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers * Returned device is not referenced. It is attached to the child
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers * device, and will be cleaned up when the child device is cleaned up.
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers * It is not necessarily just the upper level directory, empty or not
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers * recognized sys directories are ignored.
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers * It can be called as many times as needed, without caring about
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers * references.
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers * Returns: a new udev device, or #NULL, if it no parent exist.
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers_public_ struct udev_device *udev_device_get_parent(struct udev_device *udev_device)
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers udev_device->parent = device_new_from_parent(udev_device);
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers /* TODO: errno will differ here in case parent == NULL */
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * udev_device_get_parent_with_subsystem_devtype:
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers * @udev_device: udev device to start searching from
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * @subsystem: the subsystem of the device
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * @devtype: the type (DEVTYPE) of the device
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * Find the next parent device, with a matching subsystem and devtype
971e7fb62548f2c9c4e32684bb13409e6579dc6aKay Sievers * value, and fill in information from the sys device and the udev
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * database entry.
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * If devtype is #NULL, only subsystem is checked, and any devtype will
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * Returned device is not referenced. It is attached to the child
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * device, and will be cleaned up when the child device is cleaned up.
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * It can be called as many times as needed, without caring about
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers * references.
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers * Returns: a new udev device, or #NULL if no matching parent exists.
72bc96f07868d532596477604b6fb41633ebd124Kay Sievers_public_ struct udev_device *udev_device_get_parent_with_subsystem_devtype(struct udev_device *udev_device, const char *subsystem, const char *devtype)
e0d4a0ac06afb856c9370c5c256f0f7bb7efdc8eHendrik Brueckner /* this relies on the fact that finding the subdevice of a parent or the
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers parent of a subdevice commute */
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers /* first find the correct sd_device */
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers r = sd_device_get_parent_with_subsystem_devtype(udev_device->device, subsystem, devtype, &parent);
e0d4a0ac06afb856c9370c5c256f0f7bb7efdc8eHendrik Brueckner /* then walk the chain of udev_device parents until the correspanding
e0d4a0ac06afb856c9370c5c256f0f7bb7efdc8eHendrik Brueckner one is found */
e0d4a0ac06afb856c9370c5c256f0f7bb7efdc8eHendrik Brueckner while ((udev_device = udev_device_get_parent(udev_device))) {
72bc96f07868d532596477604b6fb41633ebd124Kay Sievers * udev_device_get_udev:
090be8653471e1abe3f1cdd32eaad0fbd65f85cdThomas Hindoe Paaboel Andersen * @udev_device: udev device
72bc96f07868d532596477604b6fb41633ebd124Kay Sievers * Retrieve the udev library context the device was created with.
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers * Returns: the udev library context
d23965a64eb5c2c97b839dc2e3e79fc1613994f1Kay Sievers_public_ struct udev *udev_device_get_udev(struct udev_device *udev_device)
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * udev_device_ref:
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * @udev_device: udev device
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * Take a reference of a udev device.
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * Returns: the passed udev device
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers_public_ struct udev_device *udev_device_ref(struct udev_device *udev_device)
e0d4a0ac06afb856c9370c5c256f0f7bb7efdc8eHendrik Brueckner * udev_device_unref:
e0d4a0ac06afb856c9370c5c256f0f7bb7efdc8eHendrik Brueckner * @udev_device: udev device
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * Drop a reference of a udev device. If the refcount reaches zero,
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * the resources of the device will be released.
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * Returns: #NULL
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers_public_ struct udev_device *udev_device_unref(struct udev_device *udev_device)
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers if (udev_device && (-- udev_device->refcount) == 0) {
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * udev_device_get_devpath:
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * @udev_device: udev device
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * Retrieve the kernel devpath value of the udev device. The path
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * does not contain the sys mount point, and starts with a '/'.
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers * Returns: the devpath of the udev device
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers_public_ const char *udev_device_get_devpath(struct udev_device *udev_device)
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers r = sd_device_get_devpath(udev_device->device, &devpath);
984c4348ff14d29c526d3d372daa82e278eeb5b4Kay Sievers if (r < 0) {
984c4348ff14d29c526d3d372daa82e278eeb5b4Kay Sievers * udev_device_get_syspath:
984c4348ff14d29c526d3d372daa82e278eeb5b4Kay Sievers * @udev_device: udev device
984c4348ff14d29c526d3d372daa82e278eeb5b4Kay Sievers * Retrieve the sys path of the udev device. The path is an
984c4348ff14d29c526d3d372daa82e278eeb5b4Kay Sievers * absolute path and starts with the sys mount point.
984c4348ff14d29c526d3d372daa82e278eeb5b4Kay Sievers * Returns: the sys path of the udev device
0260944060426d54d9ecb40930baad985cbd02a1Kay Sievers_public_ const char *udev_device_get_syspath(struct udev_device *udev_device)
5ac0162c3af95efa08a07b84ff62ad32842922c7Lennart Poettering r = sd_device_get_syspath(udev_device->device, &syspath);
a660c63c551b88136ac6176855b5907cc533e848Kay Sievers if (r < 0) {
errno = -r;
return NULL;
return syspath;
const char *sysname;
errno = -r;
return NULL;
return sysname;
const char *sysnum;
errno = -r;
return NULL;
return sysnum;
const char *devnode;
errno = -r;
return NULL;
return devnode;
_public_ struct udev_list_entry *udev_device_get_devlinks_list_entry(struct udev_device *udev_device)
const char *devlink;
_public_ struct udev_list_entry *udev_device_get_properties_list_entry(struct udev_device *udev_device)
if (r < 0 && r != -ENOENT) {
errno = -r;
return NULL;
return action;
_public_ unsigned long long int udev_device_get_usec_since_initialized(struct udev_device *udev_device)
return ts;
_public_ const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr)
const char *value;
errno = -r;
return NULL;
return value;
_public_ int udev_device_set_sysattr_value(struct udev_device *udev_device, const char *sysattr, char *value)
_public_ struct udev_list_entry *udev_device_get_sysattr_list_entry(struct udev_device *udev_device)
const char *sysattr;
int r, initialized;
errno = -r;
return initialized;
const char *tag;