blockdev-list: add blockdev_list_full() which allows passing in a pre-determined pair of root_devno/whole_root_devno

This commit is contained in:
Lennart Poettering
2026-09-23 10:08:36 +02:00
parent 48a9afb6ec
commit 647fa40327
2 changed files with 19 additions and 4 deletions
+9 -3
View File
@@ -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();
+10 -1
View File
@@ -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);
}