Use is_mounted helper instaed of calling findmnt directly or checking if
"mount" value is empty.
If findmnt looks for fstab as well, some non mounted entry will also
return value. Required to support non-mounted target.
Signed-off-by: Kairui Song <kasong(a)redhat.com>
---
kdump-lib-initramfs.sh | 2 +-
kdump-lib.sh | 5 +++++
kdumpctl | 2 +-
mkdumprd | 2 +-
4 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
index 653c872..83fb4c9 100755
--- a/kdump-lib-initramfs.sh
+++ b/kdump-lib-initramfs.sh
@@ -102,7 +102,7 @@ dump_fs()
local _mp=$(findmnt -k -f -n -r -o TARGET $1)
local _op=$(findmnt -k -f -n -r -o OPTIONS $1)
- if [ -z "$_mp" ]; then
+ if ! is_mounted "$_mp"; then
_dev=$(findmnt -s -f -n -r -o SOURCE $1)
_mp=$(findmnt -s -f -n -r -o TARGET $1)
_op=$(findmnt -s -f -n -r -o OPTIONS $1)
diff --git a/kdump-lib.sh b/kdump-lib.sh
index 64d0603..5be9e46 100755
--- a/kdump-lib.sh
+++ b/kdump-lib.sh
@@ -246,6 +246,11 @@ get_target_from_path()
echo $_target
}
+is_mounted()
+{
+ findmnt -k -n $1 &>/dev/null
+}
+
get_fs_type_from_target()
{
findmnt -k -f -n -r -o FSTYPE $1
diff --git a/kdumpctl b/kdumpctl
index 3543bc2..76e066b 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -475,7 +475,7 @@ check_dump_fs_modified()
fi
fi
- if ! findmnt $_target >/dev/null; then
+ if ! is_mounted $_target; then
echo "Dump target $_target is probably not mounted."
return 2
fi
diff --git a/mkdumprd b/mkdumprd
index 8802307..16d9c4a 100644
--- a/mkdumprd
+++ b/mkdumprd
@@ -364,7 +364,7 @@ do
extra_modules="$extra_modules $config_val"
;;
ext[234]|xfs|btrfs|minix|nfs)
- if ! findmnt $config_val >/dev/null; then
+ if ! is_mounted $config_val; then
perror_exit "Dump target $config_val is probably not mounted."
fi
--
2.24.1