Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dracut.sh): do not add device if find_block_device returns an error #36

Merged
merged 2 commits into from
Mar 31, 2024

Conversation

dracutng
Copy link

If find_block_device returns an error, the device must not be added to the list of host devices. E.g., a system with /etc mounted as overlay is pushing the empty string '' as host device.

//usr/bin/dracut@1658(): readlink -f /etc
/usr/bin/dracut@1658(): mp=/etc
/usr/bin/dracut@1659(): mountpoint /etc
//usr/bin/dracut@1660(): find_block_device /etc
//usr/lib/dracut/dracut-functions.sh@366(find_block_device): local _dev _majmin _find_mpt
//usr/lib/dracut/dracut-functions.sh@367(find_block_device): _find_mpt=/etc
//usr/lib/dracut/dracut-functions.sh@369(find_block_device): [[ '' != yes ]]
//usr/lib/dracut/dracut-functions.sh@370(find_block_device): [[ -d /etc/. ]]
//usr/lib/dracut/dracut-functions.sh@371(find_block_device): findmnt -e -v -n -o MAJ:MIN,SOURCE --target /etc
//usr/lib/dracut/dracut-functions.sh@372(find_block_device): read -r _majmin _dev
//usr/lib/dracut/dracut-functions.sh@373(find_block_device): [[ -b overlay ]]
//usr/lib/dracut/dracut-functions.sh@384(find_block_device): [[ overlay == *:* ]]
//usr/lib/dracut/dracut-functions.sh@372(find_block_device): read -r _majmin _dev
//usr/lib/dracut/dracut-functions.sh@372(find_block_device): '[' -n '' ']'
//usr/lib/dracut/dracut-functions.sh@389(find_block_device): return 1
//usr/lib/dracut/dracut-functions.sh@393(find_block_device): [[ ! -f /etc/fstab ]]
//usr/lib/dracut/dracut-functions.sh@395(find_block_device): findmnt -e --fstab -v -n -o MAJ:MIN,SOURCE --target /etc
//usr/lib/dracut/dracut-functions.sh@396(find_block_device): read -r _majmin _dev
//usr/lib/dracut/dracut-functions.sh@397(find_block_device): [[ -n '' ]]
//usr/lib/dracut/dracut-functions.sh@398(find_block_device): _dev=overlay
//usr/lib/dracut/dracut-functions.sh@399(find_block_device): unset _majmin
//usr/lib/dracut/dracut-functions.sh@401(find_block_device): [[ -b overlay ]]
//usr/lib/dracut/dracut-functions.sh@410(find_block_device): [[ overlay == *:* ]]
//usr/lib/dracut/dracut-functions.sh@396(find_block_device): read -r _majmin _dev
//usr/lib/dracut/dracut-functions.sh@396(find_block_device): '[' -n '' ']'
//usr/lib/dracut/dracut-functions.sh@415(find_block_device): return 1
//usr/lib/dracut/dracut-functions.sh@418(find_block_device): return 1
/usr/bin/dracut@1660(): _dev=
//usr/bin/dracut@1661(): readlink -f /dev/block/
/usr/bin/dracut@1661(): _bdev=/dev/block
/usr/bin/dracut@1662(): [[ -b /dev/block ]]
/usr/bin/dracut@1663(): [[ /etc == \/ ]]
/usr/bin/dracut@1664(): push_host_devs ''

Checklist

  • I have tested it locally
  • I have reviewed and updated any documentation if relevant
  • I am providing new code and test(s) for it

Fixes dracutdevs/dracut#2592

(Cherry-picked commit from dracutdevs/dracut#2593)

…rror

If `find_block_device` returns an error, the device must not be added to the
list of host devices. E.g., a system with /etc mounted as overlay is pushing
the empty string '' as host device.

```
//usr/bin/dracut@1658(): readlink -f /etc
/usr/bin/dracut@1658(): mp=/etc
/usr/bin/dracut@1659(): mountpoint /etc
//usr/bin/dracut@1660(): find_block_device /etc
//usr/lib/dracut/dracut-functions.sh@366(find_block_device): local _dev _majmin _find_mpt
//usr/lib/dracut/dracut-functions.sh@367(find_block_device): _find_mpt=/etc
//usr/lib/dracut/dracut-functions.sh@369(find_block_device): [[ '' != yes ]]
//usr/lib/dracut/dracut-functions.sh@370(find_block_device): [[ -d /etc/. ]]
//usr/lib/dracut/dracut-functions.sh@371(find_block_device): findmnt -e -v -n -o MAJ:MIN,SOURCE --target /etc
//usr/lib/dracut/dracut-functions.sh@372(find_block_device): read -r _majmin _dev
//usr/lib/dracut/dracut-functions.sh@373(find_block_device): [[ -b overlay ]]
//usr/lib/dracut/dracut-functions.sh@384(find_block_device): [[ overlay == *:* ]]
//usr/lib/dracut/dracut-functions.sh@372(find_block_device): read -r _majmin _dev
//usr/lib/dracut/dracut-functions.sh@372(find_block_device): '[' -n '' ']'
//usr/lib/dracut/dracut-functions.sh@389(find_block_device): return 1
//usr/lib/dracut/dracut-functions.sh@393(find_block_device): [[ ! -f /etc/fstab ]]
//usr/lib/dracut/dracut-functions.sh@395(find_block_device): findmnt -e --fstab -v -n -o MAJ:MIN,SOURCE --target /etc
//usr/lib/dracut/dracut-functions.sh@396(find_block_device): read -r _majmin _dev
//usr/lib/dracut/dracut-functions.sh@397(find_block_device): [[ -n '' ]]
//usr/lib/dracut/dracut-functions.sh@398(find_block_device): _dev=overlay
//usr/lib/dracut/dracut-functions.sh@399(find_block_device): unset _majmin
//usr/lib/dracut/dracut-functions.sh@401(find_block_device): [[ -b overlay ]]
//usr/lib/dracut/dracut-functions.sh@410(find_block_device): [[ overlay == *:* ]]
//usr/lib/dracut/dracut-functions.sh@396(find_block_device): read -r _majmin _dev
//usr/lib/dracut/dracut-functions.sh@396(find_block_device): '[' -n '' ']'
//usr/lib/dracut/dracut-functions.sh@415(find_block_device): return 1
//usr/lib/dracut/dracut-functions.sh@418(find_block_device): return 1
/usr/bin/dracut@1660(): _dev=
//usr/bin/dracut@1661(): readlink -f /dev/block/
/usr/bin/dracut@1661(): _bdev=/dev/block
/usr/bin/dracut@1662(): [[ -b /dev/block ]]
/usr/bin/dracut@1663(): [[ /etc == \/ ]]
/usr/bin/dracut@1664(): push_host_devs ''
```

Fixes #2592
Check at least that the arguments are not an empty string.
@LaszloGombos
Copy link
Collaborator

This PR is already in openSUSE - see openSUSE/dracut#307 .

I need help reviewing this one.

CC @aafeijoo-suse @tblume @Conan-Kudo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

handle directories in /dev/disk/by-path
4 participants