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
This commit is contained in:
@@ -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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user