Skip to content

Commit

Permalink
kdump-lib-initramfs: Improve mount point retrieval logic
Browse files Browse the repository at this point in the history
We use findmnt to find the real mount point by mount source, however,
when there is a bind mount target, findmnt will give more than one
results and what we actually want is the one without fsroot.

Will fallback to previous method if the $_mntpoint is empty.

Signed-off-by: Lichen Liu <[email protected]>
  • Loading branch information
licliu authored and coiby committed Oct 9, 2024
1 parent 88525eb commit 27a9d1d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
10 changes: 8 additions & 2 deletions kdump-lib-initramfs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -103,8 +103,14 @@ get_fs_type_from_target()

get_mntpoint_from_target()
{
# --source is applied to ensure non-bind mount is returned
get_mount_info TARGET source "$1" -f
local _mntpoint
# get the first TARGET when SOURCE doesn't end with ].
# In most cases, a SOURCE ends with ] when fsroot or subvol exists.
_mntpoint=$(get_mount_info TARGET,SOURCE source "$1" | grep -v "\]$" | awk 'NR==1 { print $1 }')

# fallback to the old way when _mntpoint is empty.
[[ -n "$_mntpoint" ]] || _mntpoint=$(get_mount_info TARGET source "$1" -f )
echo $_mntpoint
}

is_ssh_dump_target()
Expand Down
2 changes: 1 addition & 1 deletion kdump-lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ get_bind_mount_source()

_fsroot=${_src#"${_src_nofsroot}"[}
_fsroot=${_fsroot%]}
_mnt=$(get_mount_info TARGET source "$_src_nofsroot" -f)
_mnt=$(get_mntpoint_from_target "$_src_nofsroot")

# for btrfs, _fsroot will also contain the subvol value as well, strip it
if [[ $_fstype == btrfs ]]; then
Expand Down

0 comments on commit 27a9d1d

Please sign in to comment.