Revert "lib: Ensure we don't find bind mounts for device target"

Resolves: https://issues.redhat.com/browse/RHEL-56832
Upstream Status: RHEL-only

This reverts commit 099aead590.

Currently get_mntpoint_from_target incorrectly return empty result for
targets that contain square bracket '[', e.g
 - eng.redhat.com:/srv/[nfs]
 - [2620:52:0:a1:217:38ff:fe01:131]:/srv/[nfs]
 - /dev/mapper/rhel[disk]

get_mntpoint_from_target is also used in several places. To avoid
RHEL-56832 and other possible regressions, revert the bad commit.

Suggested-by: Dave Young <dyoung@redhat.com>
Signed-off-by: Coiby Xu <coxu@redhat.com>
This commit is contained in:
Coiby Xu 2024-09-09 14:48:30 +08:00
parent 0de1f1cc1b
commit d7d847c81d
2 changed files with 3 additions and 10 deletions

View File

@ -101,15 +101,8 @@ get_fs_type_from_target()
get_mntpoint_from_target() get_mntpoint_from_target()
{ {
local SOURCE TARGET # --source is applied to ensure non-bind mount is returned
findmnt -k --pairs -o SOURCE,TARGET "$1" | while read line; do get_mount_info TARGET source "$1" -f
eval "$line"
# omit sources that are bind mounts i.e. they contain a [/path/to/subpath].
if [[ ! "$SOURCE" =~ \[ ]]; then
echo $TARGET
break
fi
done
} }
is_ssh_dump_target() is_ssh_dump_target()

View File

@ -213,7 +213,7 @@ get_bind_mount_source()
_fsroot=${_src#${_src_nofsroot}[} _fsroot=${_src#${_src_nofsroot}[}
_fsroot=${_fsroot%]} _fsroot=${_fsroot%]}
_mnt=$(get_mntpoint_from_target "$_src_nofsroot") _mnt=$(get_mount_info TARGET source "$_src_nofsroot" -f)
# for btrfs, _fsroot will also contain the subvol value as well, strip it # for btrfs, _fsroot will also contain the subvol value as well, strip it
if [[ $_fstype == btrfs ]]; then if [[ $_fstype == btrfs ]]; then