We need to check if a directory or a device is lvm2 thinp target.
First, we use get_block_dump_target() to convert dump path into
block device, then we check if the device is in the output of
cmd lvs. If the device is lvm2 thinp, whose attribute given by
lvs will be '/^.{6}t'. And the device's full path can be one of:
1) /dev/mapper/vg-thinp, 2) /dev/vg/thinp.
Signed-off-by: Tao Liu <ltao(a)redhat.com>
---
kdump-lib-initramfs.sh | 24 ++++++++++++++++++++++++
1 file changed, 24 insertions(+)
diff --git a/kdump-lib-initramfs.sh b/kdump-lib-initramfs.sh
index 84e6bf7..149aa49 100755
--- a/kdump-lib-initramfs.sh
+++ b/kdump-lib-initramfs.sh
@@ -131,3 +131,27 @@ is_fs_dump_target()
{
[ -n "$(kdump_get_conf_val "ext[234]\|xfs\|btrfs\|minix")" ]
}
+
+is_lvm2_thinp_device()
+{
+ local _device_path=$1
+ local _lvm2_thinp_volumes=($(lvs 2>/dev/null |
+ awk '{if ($3 ~ /^.{6}t/) {printf("%s-%s %s/%s ", $2, $1, $2,
$1);}}'))
+
+ for _v in ${_lvm2_thinp_volumes[@]}; do
+ [[ "/dev/mapper/$_v" == $_device_path ||
+ "/dev/$_v" == $_device_path ]] &&
+ return 0
+ done
+ return 1
+}
+
+is_lvm2_thinp_dump_target()
+{
+ local _target=$(get_block_dump_target)
+ if [ -n $_target ]; then
+ is_lvm2_thinp_device $_target
+ else
+ return 1
+ fi
+}
\ No newline at end of file
--
2.33.1