NAME |SYNOPSIS |DESCRIPTION |RETURN VALUE |HISTORY |SEE ALSO |COLOPHON | |
SD_DE..._FIRST(3) sd_device_enumerator_get_device_firstSD_DE..._FIRST(3)sd_device_enumerator_get_device_first, sd_device_enumerator_get_device_next, sd_device_enumerator_get_subsystem_first, sd_device_enumerator_get_subsystem_next - Enumerates devices and get the first or next device.
#include <systemd/sd-device.h>sd_device*sd_device_enumerator_get_device_first(sd_device_enumerator *enumerator);sd_device*sd_device_enumerator_get_device_next(sd_device_enumerator *enumerator);sd_device*sd_device_enumerator_get_subsystem_first(sd_device_enumerator *enumerator);sd_device*sd_device_enumerator_get_subsystem_next(sd_device_enumerator *enumerator);
Thesd_device_enumerator_get_device_first()function enumerates all matching devices under /sys/bus/SUBSYSTEM/devices/ and /sys/class/SUBSYSTEM/devices/, and returns a pointer to the firstsd_deviceobject. If no devices are found,NULLis returned. Thesd_device_enumerator_get_device_next()function returns the pointer to the nextsd_devicefrom theenumerator. It should be called aftersd_device_enumerator_get_device_first()or after a previous call to this function. If no more devices are available,NULLis returned. Thesd_device_enumerator_get_subsystem_first()function enumerates all matching subsystem devices in /sys/module/, /sys/bus/, and /sys/bus/SUBSYSTEM/drivers/ (such as /sys/bus/pci/drivers/). It returns a pointer to the firstsd_deviceobject. If no devices are foundNULLis returned. Note that this doesnot enumerate devices provided bysd_device_enumerator_get_device_first/next(). Hence, e.g. /sys/bus/pci/, /sys/bus/pci/drivers/ahci/ and so on are enumerated, but /sys/bus/pci/devices/0000:00:00.0/ and so on are not. Thesd_device_enumerator_get_subsystem_next()function returns the next subsystem device from the enumerator. It should be called aftersd_device_enumerator_get_subsystem_first()or after a previous call to this function. If no more subsystem devices are available,NULLis returned.
On success, these functions return a pointer to ansd_device object. On failure or when no more devices are available,NULLis returned. The returned pointers are owned by the enumerator and should not be freed by the caller.
sd_device_enumerator_get_device_first(),sd_device_enumerator_get_device_next(),sd_device_enumerator_get_subsystem_first(), andsd_device_enumerator_get_subsystem_next()were introduced in systemd version 240.
sd_device_enumerator_new(3),sd_device_enumerator_add_match_parent(3),sd_device_ref(3)
This page is part of thesystemd (systemd system and service manager) project. Information about the project can be found at ⟨http://www.freedesktop.org/wiki/Software/systemd⟩. If you have a bug report for this manual page, see ⟨http://www.freedesktop.org/wiki/Software/systemd/#bugreports⟩. This page was obtained from the project's upstream Git repository ⟨https://github.com/systemd/systemd.git⟩ on 2025-08-11. (At that time, the date of the most recent commit that was found in the repository was 2025-08-11.) If you discover any rendering problems in this HTML version of the page, or you believe there is a better or more up-to-date source for the page, or you have corrections or improvements to the information in this COLOPHON (which isnot part of the original manual page), send a mail to man-pages@man7.orgsystemd 258~rc2SD_DE..._FIRST(3)Pages that refer to this page:sd_device_enumerator_add_match_parent(3), systemd.directives(7), systemd.index(7)
HTML rendering created 2025-09-06 byMichael Kerrisk, author ofThe Linux Programming Interface. For details of in-depthLinux/UNIX system programming training courses that I teach, lookhere. Hosting byjambit GmbH. | ![]() |