From 647fa4032714a077286dc57941731bedade94fdd Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 2 Sep 2026 12:16:14 +0200 Subject: [PATCH] blockdev-list: add blockdev_list_full() which allows passing in a pre-determined pair of root_devno/whole_root_devno --- src/shared/blockdev-list.c | 12 +++++++++--- src/shared/blockdev-list.h | 11 ++++++++++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/src/shared/blockdev-list.c b/src/shared/blockdev-list.c index e44332dc60..d46aaa8828 100644 --- a/src/shared/blockdev-list.c +++ b/src/shared/blockdev-list.c @@ -355,7 +355,13 @@ skipped: return BLOCKDEV_LIST_MATCH_SKIPPED; } -int blockdev_list(BlockDevListFlags flags, BlockDevice **ret_devices, size_t *ret_n_devices) { +int blockdev_list_full( + BlockDevListFlags flags, + dev_t root_devno, + dev_t whole_root_devno, + BlockDevice **ret_devices, + size_t *ret_n_devices) { + _cleanup_(sd_device_enumerator_unrefp) sd_device_enumerator *e = NULL; int r; @@ -368,8 +374,8 @@ int blockdev_list(BlockDevListFlags flags, BlockDevice **ret_devices, size_t *re size_t n = 0; CLEANUP_ARRAY(l, n, block_device_array_free); - dev_t root_devno = 0, whole_root_devno = 0; - (void) blockdev_list_get_root_devnos(flags, &root_devno, &whole_root_devno); + if (root_devno == 0 && whole_root_devno == 0) + (void) blockdev_list_get_root_devnos(flags, &root_devno, &whole_root_devno); if (sd_device_enumerator_new(&e) < 0) return log_oom(); diff --git a/src/shared/blockdev-list.h b/src/shared/blockdev-list.h index c50745abbb..d1146208c5 100644 --- a/src/shared/blockdev-list.h +++ b/src/shared/blockdev-list.h @@ -71,4 +71,13 @@ int blockdev_list_one( dev_t whole_root_devno, BlockDevice *ret); -int blockdev_list(BlockDevListFlags flags, BlockDevice **ret_devices, size_t *ret_n_devices); +int blockdev_list_full( + BlockDevListFlags flags, + dev_t root_devno, + dev_t whole_root_devno, + BlockDevice **ret_devices, + size_t *ret_n_devices); + +static inline int blockdev_list(BlockDevListFlags flags, BlockDevice **ret_devices, size_t *ret_n_devices) { + return blockdev_list_full(flags, 0, 0, ret_devices, ret_n_devices); +}