From 2e185878726a7605c69e10123ca6224d9a0773a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Fri, 21 Aug 2026 10:19:29 +0200 Subject: [PATCH] shared/blockdev-list: allow uninitalized devices This means we can gather stats without udev running, which can be good in containers and such. --- src/shared/blockdev-list.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/shared/blockdev-list.c b/src/shared/blockdev-list.c index 32e121bb4b..fe71bd4ccc 100644 --- a/src/shared/blockdev-list.c +++ b/src/shared/blockdev-list.c @@ -363,6 +363,13 @@ int blockdev_list(BlockDevListFlags flags, BlockDevice **ret_devices, size_t *re if (r < 0) return log_error_errno(r, "Failed to add subsystem match: %m"); + if (!(flags & (BLOCKDEV_LIST_REQUIRE_LUKS | BLOCKDEV_LIST_SHOW_SYMLINKS | BLOCKDEV_LIST_METADATA))) { + /* If everything we need comes from the device name or sysfs directly, no udev db entry is needed. */ + r = sd_device_enumerator_allow_uninitialized(e); + if (r < 0) + log_debug_errno(r, "Failed to allow uninitialized devices, ignoring: %m"); + } + if (FLAGS_SET(flags, BLOCKDEV_LIST_REQUIRE_LUKS)) { /* blockdev_list_one() enforces this filter authoritatively; the enumerator match is just * an optimization so we don't iterate non-LUKS devices here. */