From 08d9846ebad3ce210cfa5388ac7286e30c36d233 Mon Sep 17 00:00:00 2001 From: Kairui Song Date: Mon, 23 Nov 2020 21:41:51 +0800 Subject: [PATCH] Make get_mount_info work with bind mount Remove the --real when calling findmnt. The option is only useful in capture kernel, to avoid `findmnt` returning the pseudo 'rootfs' for non mounted path. example, when /kdumproot/mnt/ is not mounted: kdump:/# findmnt --target /kdumproot/mnt TARGET SOURCE FSTYPE OPTIONS / rootfs rootfs rw,size=61368k,nr_inodes=15342 kdump:/# findmnt --target /kdumproot/mnt But this function will make findmnt also return empty value for bind mount. So remove it and add an extra if statement for second kernel. Signed-off-by: Kairui Song Acked-by: Pingfan Liu --- kdump-lib-initramfs.sh | 2 +- kdump-lib.sh | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh index d8d4893..9275c83 100755 --- a/kdump-lib-initramfs.sh +++ b/kdump-lib-initramfs.sh @@ -123,7 +123,7 @@ dump_fs() ddebug "_mp=$_mp _dev=$_dev _op=$_op" # If dump path have a corresponding device entry but not mounted, mount it. - if [ -n "$_dev" ]; then + if [ -n "$_dev" ] && [ "$_dev" != "rootfs" ]; then if ! is_mounted "$_mp"; then dinfo "dump target $_dev is not mounted, trying to mount..." mkdir -p $_mp diff --git a/kdump-lib.sh b/kdump-lib.sh index 98ff27c..f04095a 100755 --- a/kdump-lib.sh +++ b/kdump-lib.sh @@ -256,9 +256,9 @@ is_mounted() get_mount_info() { local _info_type=$1 _src_type=$2 _src=$3; shift 3 - local _info=$(findmnt --real -k -n -r -o $_info_type --$_src_type $_src $@) + local _info=$(findmnt -k -n -r -o $_info_type --$_src_type $_src $@) - [ -z "$_info" ] && [ -e "/etc/fstab" ] && _info=$(findmnt --real -s -n -r -o $_info_type --$_src_type $_src $@) + [ -z "$_info" ] && [ -e "/etc/fstab" ] && _info=$(findmnt -s -n -r -o $_info_type --$_src_type $_src $@) echo $_info }