check_*_modified will be executed in order, but when the previous return value
is not 0, the remaining checks will not be executed. is_system_modified will
return immediately if the previous check returns 1, regardless of whether the
remaining checks return 2. However, if the return value is 2, it means an error
has occurred, and kdumpctl should not continue execution.
Signed-off-by: Lichen Liu <lichliu(a)redhat.com>
---
kdumpctl | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/kdumpctl b/kdumpctl
index 01433e2..7efaf78 100755
--- a/kdumpctl
+++ b/kdumpctl
@@ -605,6 +605,7 @@ check_fs_modified()
is_system_modified()
{
local ret
+ local max_ret=0
[[ -f $TARGET_INITRD ]] || return 1
@@ -617,9 +618,15 @@ is_system_modified()
fi
fi
- check_files_modified || return
- check_fs_modified || return
- check_drivers_modified
+ for _func in check_files_modified check_fs_modified check_drivers_modified; do
+ $_func
+ ret=$?
+ if [[ $ret -eq 2 ]]; then
+ return 2
+ fi
+ max_ret=$((max_ret > ret ? max_ret : ret))
+ done
+ return $max_ret
}
# need_initrd_rebuild - check whether the initrd needs to be rebuild
--
2.41.0