libudev-device.c revision cdd45c1ffbf790facd1817757832aa25d9211967
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering This file is part of systemd.
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering Copyright 2008-2012 Kay Sievers <kay@vrfy.org>
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering systemd is free software; you can redistribute it and/or modify it
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering under the terms of the GNU Lesser General Public License as published by
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering the Free Software Foundation; either version 2.1 of the License, or
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering (at your option) any later version.
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering systemd is distributed in the hope that it will be useful, but
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering WITHOUT ANY WARRANTY; without even the implied warranty of
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering Lesser General Public License for more details.
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering You should have received a copy of the GNU Lesser General Public License
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering along with systemd; If not, see <http://www.gnu.org/licenses/>.
875c2e220e2611165e09051c4747971811f1de58Lennart Poetteringstatic int udev_device_set_devnode(struct udev_device *udev_device, const char *devnode);
875c2e220e2611165e09051c4747971811f1de58Lennart Poetteringstatic struct udev_list_entry *udev_device_add_property_internal(struct udev_device *udev_device, const char *key, const char *value);
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * SECTION:libudev-device
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * @short_description: kernel sys devices
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * Representation of kernel sys devices. Devices are uniquely identified
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * by their syspath, every device has exactly one path in the kernel sys
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * filesystem. Devices usually belong to a kernel subsystem, and have
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * a unique name inside that subsystem.
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * udev_device:
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * Opaque object representing one kernel sys device.
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering unsigned long long int seqnum;
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * udev_device_get_seqnum:
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * @udev_device: udev device
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * This is only valid if the device was received through a monitor. Devices read from
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * sys do not have a sequence number.
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * Returns: the kernel event sequence number, or 0 if there is no sequence number available.
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering_public_ unsigned long long int udev_device_get_seqnum(struct udev_device *udev_device)
875c2e220e2611165e09051c4747971811f1de58Lennart Poetteringstatic int udev_device_set_seqnum(struct udev_device *udev_device, unsigned long long int seqnum)
78fe420ff0bb4cd94de3c4d3f15a3021cc3e2878Lennart Poettering snprintf(num, sizeof(num), "%llu", seqnum);
78fe420ff0bb4cd94de3c4d3f15a3021cc3e2878Lennart Poettering udev_device_add_property_internal(udev_device, "SEQNUM", num);
78fe420ff0bb4cd94de3c4d3f15a3021cc3e2878Lennart Poetteringint udev_device_get_ifindex(struct udev_device *udev_device)
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_read_uevent_file(udev_device);
875c2e220e2611165e09051c4747971811f1de58Lennart Poetteringstatic int udev_device_set_ifindex(struct udev_device *udev_device, int ifindex)
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering snprintf(num, sizeof(num), "%d", ifindex);
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_add_property_internal(udev_device, "IFINDEX", num);
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * udev_device_get_devnum:
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * @udev_device: udev device
78fe420ff0bb4cd94de3c4d3f15a3021cc3e2878Lennart Poettering * Get the device major/minor number.
78fe420ff0bb4cd94de3c4d3f15a3021cc3e2878Lennart Poettering * Returns: the dev_t number.
78fe420ff0bb4cd94de3c4d3f15a3021cc3e2878Lennart Poettering_public_ dev_t udev_device_get_devnum(struct udev_device *udev_device)
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_read_uevent_file(udev_device);
875c2e220e2611165e09051c4747971811f1de58Lennart Poetteringstatic int udev_device_set_devnum(struct udev_device *udev_device, dev_t devnum)
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering snprintf(num, sizeof(num), "%u", major(devnum));
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_add_property_internal(udev_device, "MAJOR", num);
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering snprintf(num, sizeof(num), "%u", minor(devnum));
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_add_property_internal(udev_device, "MINOR", num);
875c2e220e2611165e09051c4747971811f1de58Lennart Poetteringconst char *udev_device_get_devpath_old(struct udev_device *udev_device)
875c2e220e2611165e09051c4747971811f1de58Lennart Poetteringstatic int udev_device_set_devpath_old(struct udev_device *udev_device, const char *devpath_old)
9833a66c7eba011c3740867c80133bc6fa976aa3Lennart Poettering udev_device->devpath_old = strdup(devpath_old);
9833a66c7eba011c3740867c80133bc6fa976aa3Lennart Poettering udev_device_add_property_internal(udev_device, "DEVPATH_OLD", udev_device->devpath_old);
9833a66c7eba011c3740867c80133bc6fa976aa3Lennart Poettering pos = strrchr(udev_device->devpath_old, '/');
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * udev_device_get_driver:
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * @udev_device: udev device
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * Get the kernel driver name.
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * Returns: the driver name string, or #NULL if there is no driver attached.
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering_public_ const char *udev_device_get_driver(struct udev_device *udev_device)
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering if (util_get_sys_core_link_value(udev_device->udev, "driver", udev_device->syspath, driver, sizeof(driver)) > 0)
875c2e220e2611165e09051c4747971811f1de58Lennart Poetteringstatic int udev_device_set_driver(struct udev_device *udev_device, const char *driver)
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_add_property_internal(udev_device, "DRIVER", udev_device->driver);
78fe420ff0bb4cd94de3c4d3f15a3021cc3e2878Lennart Poettering * udev_device_get_devtype:
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * @udev_device: udev device
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * Retrieve the devtype string of the udev device.
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * Returns: the devtype name of the udev device, or #NULL if it can not be determined
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering_public_ const char *udev_device_get_devtype(struct udev_device *udev_device)
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_read_uevent_file(udev_device);
875c2e220e2611165e09051c4747971811f1de58Lennart Poetteringstatic int udev_device_set_devtype(struct udev_device *udev_device, const char *devtype)
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_add_property_internal(udev_device, "DEVTYPE", udev_device->devtype);
875c2e220e2611165e09051c4747971811f1de58Lennart Poetteringstatic int udev_device_set_subsystem(struct udev_device *udev_device, const char *subsystem)
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device->subsystem = strdup(subsystem);
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_add_property_internal(udev_device, "SUBSYSTEM", udev_device->subsystem);
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * udev_device_get_subsystem:
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * @udev_device: udev device
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * Retrieve the subsystem string of the udev device. The string does not
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * contain any "/".
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * Returns: the subsystem name of the udev device, or #NULL if it can not be determined
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering_public_ const char *udev_device_get_subsystem(struct udev_device *udev_device)
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering /* read "subsystem" link */
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering if (util_get_sys_core_link_value(udev_device->udev, "subsystem", udev_device->syspath, subsystem, sizeof(subsystem)) > 0) {
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_set_subsystem(udev_device, subsystem);
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering /* implicit names */
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering if (startswith(udev_device->devpath, "/module/")) {
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_set_subsystem(udev_device, "module");
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering if (strstr(udev_device->devpath, "/drivers/") != NULL) {
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_set_subsystem(udev_device, "drivers");
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering if (startswith(udev_device->devpath, "/subsystem/") ||
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering startswith(udev_device->devpath, "/class/") ||
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering startswith(udev_device->devpath, "/bus/")) {
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_set_subsystem(udev_device, "subsystem");
23bbb0de4e3f85d9704a5c12a5afa2dfa0159e41Michal Schmidtmode_t udev_device_get_devnode_mode(struct udev_device *udev_device)
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_read_uevent_file(udev_device);
875c2e220e2611165e09051c4747971811f1de58Lennart Poetteringstatic int udev_device_set_devnode_mode(struct udev_device *udev_device, mode_t mode)
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_add_property_internal(udev_device, "DEVMODE", num);
875c2e220e2611165e09051c4747971811f1de58Lennart Poetteringuid_t udev_device_get_devnode_uid(struct udev_device *udev_device)
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_read_uevent_file(udev_device);
875c2e220e2611165e09051c4747971811f1de58Lennart Poetteringstatic int udev_device_set_devnode_uid(struct udev_device *udev_device, uid_t uid)
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_add_property_internal(udev_device, "DEVUID", num);
875c2e220e2611165e09051c4747971811f1de58Lennart Poetteringgid_t udev_device_get_devnode_gid(struct udev_device *udev_device)
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_read_uevent_file(udev_device);
875c2e220e2611165e09051c4747971811f1de58Lennart Poetteringstatic int udev_device_set_devnode_gid(struct udev_device *udev_device, gid_t gid)
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_add_property_internal(udev_device, "DEVGID", num);
875c2e220e2611165e09051c4747971811f1de58Lennart Poetteringstatic struct udev_list_entry *udev_device_add_property_internal(struct udev_device *udev_device, const char *key, const char *value)
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering list_entry = udev_device_get_properties_list_entry(udev_device);
5034c7bcdfc4493ed3c30722e9d897c8da78fedeLennart Poettering list_entry = udev_list_entry_get_by_name(list_entry, key);
cd556b6ca8aec8dd371806afedec45f852f8f724Zbigniew Jędrzejewski-Szmek return udev_list_entry_add(&udev_device->properties_list, key, value);
875c2e220e2611165e09051c4747971811f1de58Lennart Poetteringint udev_device_add_property(struct udev_device *udev_device, const char *key, const char *value)
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering property = udev_device_add_property_internal(udev_device, key, value);
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering /* store in db, skip private keys */
875c2e220e2611165e09051c4747971811f1de58Lennart Poetteringstatic struct udev_list_entry *udev_device_add_property_from_string(struct udev_device *udev_device, const char *property)
cd556b6ca8aec8dd371806afedec45f852f8f724Zbigniew Jędrzejewski-Szmek strscpy(name, sizeof(name), property);
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering return udev_device_add_property_internal(udev_device, name, val);
875c2e220e2611165e09051c4747971811f1de58Lennart Poetteringstatic int udev_device_set_syspath(struct udev_device *udev_device, const char *syspath)
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device->devpath = udev_device->syspath + strlen("/sys");
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_add_property_internal(udev_device, "DEVPATH", udev_device->devpath);
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering pos = strrchr(udev_device->syspath, '/');
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering /* some devices have '!' in their name, change that to '/' */
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering while (udev_device->sysname[len] != '\0') {
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering /* trailing number */
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering while (len > 0 && isdigit(udev_device->sysname[--len]))
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device->sysnum = &udev_device->sysname[len];
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering /* sysname is completely numeric */
875c2e220e2611165e09051c4747971811f1de58Lennart Poetteringstatic void udev_device_set_usec_initialized(struct udev_device *udev_device, usec_t usec_initialized)
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device->usec_initialized = usec_initialized;
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering snprintf(num, sizeof(num), USEC_FMT, usec_initialized);
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_add_property_internal(udev_device, "USEC_INITIALIZED", num);
875c2e220e2611165e09051c4747971811f1de58Lennart Poetteringvoid udev_device_ensure_usec_initialized(struct udev_device *udev_device, struct udev_device *old_device)
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering if (old_device && old_device->usec_initialized != 0)
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_set_usec_initialized(udev_device, old_device->usec_initialized);
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_set_usec_initialized(udev_device, now(CLOCK_MONOTONIC));
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * parse property string, and if needed, update internal values accordingly
0b97208d8c39131f8a7cfcfccb5c40b86af44ee5Lennart Poettering * udev_device_add_property_from_string_parse_finish() needs to be
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering * called after adding properties, and its return value checked
4d9ced9956755901238fede6fc5a3d7e4e816aa6Lennart Poettering * udev_device_set_info_loaded() needs to be set, to avoid trying
4d9ced9956755901238fede6fc5a3d7e4e816aa6Lennart Poettering * to use a device without a DEVPATH set
4d9ced9956755901238fede6fc5a3d7e4e816aa6Lennart Poetteringstatic void udev_device_add_property_from_string_parse(struct udev_device *udev_device, const char *property)
4d9ced9956755901238fede6fc5a3d7e4e816aa6Lennart Poettering strscpyl(path, sizeof(path), "/sys", &property[8], NULL);
4d9ced9956755901238fede6fc5a3d7e4e816aa6Lennart Poettering udev_device_set_syspath(udev_device, path);
4d9ced9956755901238fede6fc5a3d7e4e816aa6Lennart Poettering } else if (startswith(property, "SUBSYSTEM=")) {
4d9ced9956755901238fede6fc5a3d7e4e816aa6Lennart Poettering udev_device_set_subsystem(udev_device, &property[10]);
4d9ced9956755901238fede6fc5a3d7e4e816aa6Lennart Poettering } else if (startswith(property, "DEVTYPE=")) {
4d9ced9956755901238fede6fc5a3d7e4e816aa6Lennart Poettering udev_device_set_devtype(udev_device, &property[8]);
4d9ced9956755901238fede6fc5a3d7e4e816aa6Lennart Poettering } else if (startswith(property, "DEVNAME=")) {
4d9ced9956755901238fede6fc5a3d7e4e816aa6Lennart Poettering udev_device_set_devnode(udev_device, &property[8]);
4d9ced9956755901238fede6fc5a3d7e4e816aa6Lennart Poettering } else if (startswith(property, "DEVLINKS=")) {
4d9ced9956755901238fede6fc5a3d7e4e816aa6Lennart Poettering strscpy(devlinks, sizeof(devlinks), &property[9]);
4d9ced9956755901238fede6fc5a3d7e4e816aa6Lennart Poettering udev_device_add_devlink(udev_device, slink);
4d9ced9956755901238fede6fc5a3d7e4e816aa6Lennart Poettering udev_device_add_devlink(udev_device, slink);
4d9ced9956755901238fede6fc5a3d7e4e816aa6Lennart Poettering } else if (startswith(property, "TAGS=")) {
4d9ced9956755901238fede6fc5a3d7e4e816aa6Lennart Poettering strscpy(tags, sizeof(tags), &property[5]);
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering } else if (startswith(property, "USEC_INITIALIZED=")) {
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_set_usec_initialized(udev_device, strtoull(&property[19], NULL, 10));
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering } else if (startswith(property, "DRIVER=")) {
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_set_driver(udev_device, &property[7]);
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering } else if (startswith(property, "ACTION=")) {
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_set_action(udev_device, &property[7]);
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering } else if (startswith(property, "MAJOR=")) {
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device->maj = strtoull(&property[6], NULL, 10);
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering } else if (startswith(property, "MINOR=")) {
56f64d95763a799ba4475daf44d8e9f72a1bd474Michal Schmidt udev_device->min = strtoull(&property[6], NULL, 10);
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering } else if (startswith(property, "DEVPATH_OLD=")) {
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_set_devpath_old(udev_device, &property[12]);
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering } else if (startswith(property, "SEQNUM=")) {
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_set_seqnum(udev_device, strtoull(&property[7], NULL, 10));
417a7fdc418ec76cc4c321c9a07ec15c72b3ac7dLennart Poettering } else if (startswith(property, "IFINDEX=")) {
417a7fdc418ec76cc4c321c9a07ec15c72b3ac7dLennart Poettering udev_device_set_ifindex(udev_device, strtoull(&property[8], NULL, 10));
417a7fdc418ec76cc4c321c9a07ec15c72b3ac7dLennart Poettering } else if (startswith(property, "DEVMODE=")) {
417a7fdc418ec76cc4c321c9a07ec15c72b3ac7dLennart Poettering udev_device_set_devnode_mode(udev_device, strtoul(&property[8], NULL, 8));
417a7fdc418ec76cc4c321c9a07ec15c72b3ac7dLennart Poettering } else if (startswith(property, "DEVUID=")) {
417a7fdc418ec76cc4c321c9a07ec15c72b3ac7dLennart Poettering udev_device_set_devnode_uid(udev_device, strtoul(&property[7], NULL, 10));
417a7fdc418ec76cc4c321c9a07ec15c72b3ac7dLennart Poettering } else if (startswith(property, "DEVGID=")) {
417a7fdc418ec76cc4c321c9a07ec15c72b3ac7dLennart Poettering udev_device_set_devnode_gid(udev_device, strtoul(&property[7], NULL, 10));
875c2e220e2611165e09051c4747971811f1de58Lennart Poettering udev_device_add_property_from_string(udev_device, property);
4a62c710b62a5a3c7a8a278b810b9d5b5a0c8f4fMichal Schmidtstatic int udev_device_add_property_from_string_parse_finish(struct udev_device *udev_device)
23bbb0de4e3f85d9704a5c12a5afa2dfa0159e41Michal Schmidt udev_device_set_devnum(udev_device, makedev(udev_device->maj, udev_device->min));
4d9ced9956755901238fede6fc5a3d7e4e816aa6Lennart Poettering if (udev_device->devpath == NULL || udev_device->subsystem == NULL)
_public_ const char *udev_device_get_property_value(struct udev_device *udev_device, const char *key)
return NULL;
return NULL;
const char *id;
FILE *f;
if (f == NULL)
const char *val;
switch(line[0]) {
fclose(f);
FILE *f;
int maj = 0;
int min = 0;
if (f == NULL)
return -errno;
char *pos;
fclose(f);
return NULL;
return NULL;
return udev_device;
const char *subdir;
char *pos;
return NULL;
return NULL;
return NULL;
return NULL;
return NULL;
return NULL;
return NULL;
return NULL;
return udev_device;
_public_ struct udev_device *udev_device_new_from_devnum(struct udev *udev, char type, dev_t devnum)
const char *type_str;
return NULL;
char type;
char *sysname;
switch(id[0]) {
return NULL;
int sk;
int ifindex;
if (ifindex <= 0) {
return NULL;
if (sk < 0)
return NULL;
return NULL;
return NULL;
return dev;
return NULL;
return NULL;
return NULL;
_public_ struct udev_device *udev_device_new_from_subsystem_sysname(struct udev *udev, const char *subsystem, const char *sysname)
goto found;
goto found;
goto found;
goto out;
goto found;
goto out;
char *driver;
goto found;
goto found;
goto out;
goto found;
goto found;
goto found;
out:
return NULL;
return NULL;
return udev_device;
const char *subdir;
char *pos;
return udev_device_parent;
return NULL;
return NULL;
_public_ struct udev_device *udev_device_get_parent_with_subsystem_devtype(struct udev_device *udev_device, const char *subsystem, const char *devtype)
return NULL;
const char *parent_subsystem;
const char *parent_devtype;
if (!parent)
return parent;
return NULL;
return NULL;
return udev_device;
return NULL;
return NULL;
return NULL;
return NULL;
return NULL;
return NULL;
return NULL;
return NULL;
_public_ struct udev_list_entry *udev_device_get_devlinks_list_entry(struct udev_device *udev_device)
return NULL;
_public_ struct udev_list_entry *udev_device_get_properties_list_entry(struct udev_device *udev_device)
return NULL;
size_t l;
s = symlinks;
size_t l;
s = tags;
return NULL;
_public_ unsigned long long int udev_device_get_usec_since_initialized(struct udev_device *udev_device)
if (now_ts == 0)
_public_ const char *udev_device_get_sysattr_value(struct udev_device *udev_device, const char *sysattr)
int fd;
return NULL;
return NULL;
goto out;
return NULL;
goto out;
goto out;
goto out;
goto out;
if (fd < 0)
goto out;
if (size < 0)
goto out;
goto out;
out:
return val;
_public_ int udev_device_set_sysattr_value(struct udev_device *udev_device, const char *sysattr, char *value)
int fd;
int ret = 0;
return -EINVAL;
return -EINVAL;
value_len = 0;
goto out;
goto out;
goto out;
goto out;
goto out;
if (fd < 0) {
goto out;
if (size < 0) {
goto out;
goto out;
out:
return ret;
int num = 0;
return -EINVAL;
if (!dir)
return -errno;
num++;
return num;
_public_ struct udev_list_entry *udev_device_get_sysattr_list_entry(struct udev_device *udev_device)
int ret;
if (0 > ret)
return NULL;
return -ENOMEM;
return -ENOMEM;
return NULL;
const char *sysname;
return NULL;
if (asprintf(&udev_device->id_filename, "+%s:%s", udev_device_get_subsystem(udev_device), sysname) < 0)
return -EINVAL;
return -ENOMEM;
struct udev_list_entry *e;
return NULL;
size_t l;
return -ENOMEM;
return -ENOMEM;
l = MONITOR_BUF_SIZE;
const char *key;
return -EINVAL;
return -EINVAL;
return NULL;
return -EINVAL;
return -ENOMEM;
const char *interface;
char *new_syspath;
return -EINVAL;
if (!dirname)
return -ENOMEM;
if (interface) {
/* like DEVPATH_OLD, INTERFACE_OLD is not saved to the db, but only stays around for the current event */
return NULL;
if (!device) {
return NULL;
return device;
if (!device)
return NULL;
return device;
return NULL;
if (!device) {
return NULL;
char *key;
if (keylen == 0)
return NULL;
return device;
for ((entry = udev_device_get_properties_list_entry(src)); entry; entry = udev_list_entry_get_next(entry)) {