From: Chris Down Date: Thu, 22 Jan 2026 10:15:33 +0000 (+0800) Subject: blockdev-util: Iterate through all DM layers X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F40426%2Fhead;p=thirdparty%2Fsystemd.git blockdev-util: Iterate through all DM layers get_block_device_harder_fd() currently only traverses one level of device mapper stacking when looking for the underlying block device. This causes issues with nested DM setups like dm-crypt on top of dm-integrity, where we don't traverse enough to get the actual physical device. Fix this by iterating through all DM layers until we reach a device with no underlying device. Fixes: #40419 --- diff --git a/src/shared/blockdev-util.c b/src/shared/blockdev-util.c index b138455acc9..44feae5ab60 100644 --- a/src/shared/blockdev-util.c +++ b/src/shared/blockdev-util.c @@ -346,14 +346,14 @@ int get_block_device_harder_fd(int fd, dev_t *ret) { assert(fd >= 0); assert(ret); - /* Gets the backing block device for a file system, and handles LUKS encrypted file systems, looking for its - * immediate parent, if there is one. */ + /* Gets the backing block device for a file system, and handles LUKS encrypted file systems, looking + * for its underlying physical device, if there is one. */ r = get_block_device_fd(fd, ret); if (r <= 0) return r; - r = block_get_originating(*ret, ret, /* recursive= */ false); + r = block_get_originating(*ret, ret, /* recursive= */ true); if (r < 0) log_debug_errno(r, "Failed to chase block device, ignoring: %m");