diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-08-28 15:59:08 +0900 |
---|---|---|
committer | Yu Watanabe <watanabe.yu+github@gmail.com> | 2018-09-10 16:47:35 +0900 |
commit | 708474c5a06f590748cf37392b9eef803740719b (patch) | |
tree | ee18c61b844ee9c66eec73023e5be649af19e60f /src | |
parent | 0a1665890cec06032a17c16206e9f519ca88446e (diff) | |
download | systemd-708474c5a06f590748cf37392b9eef803740719b.tar.gz |
sd-device: introduce device_enumerator_get_devices()
Diffstat (limited to 'src')
-rw-r--r-- | src/libsystemd/sd-device/device-enumerator-private.h | 1 | ||||
-rw-r--r-- | src/libsystemd/sd-device/device-enumerator.c | 11 |
2 files changed, 12 insertions, 0 deletions
diff --git a/src/libsystemd/sd-device/device-enumerator-private.h b/src/libsystemd/sd-device/device-enumerator-private.h index 56a953d33b..87411bfdd8 100644 --- a/src/libsystemd/sd-device/device-enumerator-private.h +++ b/src/libsystemd/sd-device/device-enumerator-private.h @@ -9,6 +9,7 @@ int device_enumerator_add_device(sd_device_enumerator *enumerator, sd_device *de int device_enumerator_add_match_is_initialized(sd_device_enumerator *enumerator); sd_device *device_enumerator_get_first(sd_device_enumerator *enumerator); sd_device *device_enumerator_get_next(sd_device_enumerator *enumerator); +sd_device **device_enumerator_get_devices(sd_device_enumerator *enumerator, size_t *ret_n_devices); #define FOREACH_DEVICE_AND_SUBSYSTEM(enumerator, device) \ for (device = device_enumerator_get_first(enumerator); \ diff --git a/src/libsystemd/sd-device/device-enumerator.c b/src/libsystemd/sd-device/device-enumerator.c index 509b72256a..3f7ead268e 100644 --- a/src/libsystemd/sd-device/device-enumerator.c +++ b/src/libsystemd/sd-device/device-enumerator.c @@ -973,3 +973,14 @@ sd_device *device_enumerator_get_next(sd_device_enumerator *enumerator) { return enumerator->devices[++enumerator->current_device_index]; } + +sd_device **device_enumerator_get_devices(sd_device_enumerator *enumerator, size_t *ret_n_devices) { + assert(enumerator); + assert(ret_n_devices); + + if (!enumerator->scan_uptodate) + return NULL; + + *ret_n_devices = enumerator->n_devices; + return enumerator->devices; +} |