Repository navigation
utils: Resolve symlinks with an absolute target in bd_utils_resolve_device - #1217
Conversation
…evice Only relative symlink targets were handled. An absolute target such as /dev/mapper/vg-swap -> /dev/dm-1, as created by udev rules in some environments, was turned into "/dev//dev/dm-1" and the resolution failed. bd_swap_swapstatus() then took the device for inactive and callers such as blivet tried to activate an already active swap, which failed with "Device or resource busy". Resolve absolute targets with realpath() so chains of symlinks work too. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
|
Jenkins, ok to test. |
vojtechtrefny
left a comment
There was a problem hiding this comment.
Looks good to me, thank you.
Thanks for the quick review! |
035a8ae
into
storaged-project:master
bd_utils_resolve_device()only handled relative symlink targets such as../dm-1. An absolute target such as/dev/mapper/vg-swap -> /dev/dm-1, as created in some environments (for example an initramfs with a different udev setup), was turned into/dev//dev/dm-1and the resolution failed withFailed to stat '/dev//dev/dm-1'.bd_swap_swapstatus()resolves/dev/mapper/*paths with this function and treats a failure as "device is not an active swap". Callers such as blivet (and so thelinux-system-roles.storagerole) then tried to activate an already active swap, which failed withFailed to activate swap on /dev/mapper/vg-swap: Device or resource busy.Absolute targets are now resolved with
realpath(), so chains of symlinks (/dev/vg/swap -> /dev/mapper/vg-swap -> /dev/dm-1) work too. Relative targets behave as before.Testing:
dev_utils.con its own: an absolute symlink and a two-level chain resolve to the block device, a dangling symlink still returns an error; before the change both failed withFailed to stat '/dev//dev/...'libbd_utilswith this change on a VM where/dev/mapper/vg.rh-swap -> /dev/dm-1:swapstatus("/dev/mapper/vg.rh-swap")went fromFalsetoTrueand the storage role no longer failsUtilsDevUtilsTestCase.test_resolve_device; the full test suite was not run🤖 Generated with Claude Code
Summary by CodeRabbit