From e4143381b1fd7763e26fe6850018016ff5158c8f Mon Sep 17 00:00:00 2001 From: Pratyush Anand Date: Mon, 9 May 2016 13:47:52 +0530 Subject: [PATCH] kdumpctl: force rebuild in case of dynamic system modification There could be some dynamic system modification, which may affect kdump kernel boot process. In such situation initramfs must be rebuilt on the basis of changes. Since most of these checking methods will use information from TARGET_INITRD, therefore check its existence in common code. Signed-off-by: Pratyush Anand Acked-by: Xunlei Pang Acked-by: Baoquan He Acked-by: Dave Young --- kdumpctl | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/kdumpctl b/kdumpctl index 8ec6b2d..ea6ef72 100755 --- a/kdumpctl +++ b/kdumpctl @@ -327,10 +327,21 @@ setup_target_initrd() fi } +# returns 0 if system is not modified +# returns 1 if system is modified +# returns 2 if system modification is invalid +check_system_modified() +{ + [[ -f $TARGET_INITRD ]] || return 1 + + return 0 +} + check_rebuild() { local extra_modules modified_files="" local _force_rebuild force_rebuild="0" + local ret system_modified="0" local initramfs_has_fadump check_boot_dir @@ -388,6 +399,14 @@ check_rebuild() fi done + check_system_modified + ret=$? + if [ $ret -eq 2 ]; then + return 1 + elif [ $ret -eq 1 ];then + system_modified="1" + fi + #check if target initrd has fadump support if [ "$DEFAULT_DUMP_MODE" = "fadump" ] && [ -f "$TARGET_INITRD" ]; then initramfs_has_fadump=`lsinitrd -m $TARGET_INITRD | grep ^kdumpbase$ | wc -l` @@ -399,6 +418,8 @@ check_rebuild() echo "$TARGET_INITRD has no fadump support" elif [ "$force_rebuild" != "0" ]; then echo -n "Force rebuild $TARGET_INITRD"; echo + elif [ "$system_modified" != "0" ]; then + : elif [ -n "$modified_files" ]; then echo "Detected change(s) in the following file(s):" echo -n " "; echo "$modified_files" | sed 's/\s/\n /g'