diff --git a/kpatch/kpatch b/kpatch/kpatch index bca8f41..c4ac151 100755 --- a/kpatch/kpatch +++ b/kpatch/kpatch @@ -49,8 +49,8 @@ usage () { echo >&2 usage_cmd "load --all" "load all installed patch modules into the running kernel" usage_cmd "load " "load patch module into the running kernel" - usage_cmd "unload --all" "unload all patch modules from the running kernel" - usage_cmd "unload " "unload patch module from the running kernel" + usage_cmd "unload --all (UNSUPPORTED)" "unload all patch modules from the running kernel" + usage_cmd "unload (UNSUPPORTED)" "unload patch module from the running kernel" echo >&2 usage_cmd "info " "show information about a patch module" echo >&2 @@ -71,6 +71,16 @@ die() { exit 1 } +confirm_prompt() { + local prompt="$1" + local answer + while true; do + read -rp "$prompt [Y/N] " answer + [[ $answer == 'Y' || $answer == 'y' ]] && return 0 + [[ $answer == 'N' || $answer == 'n' ]] && return 1 + done +} + __find_module () { MODULE="$1" [[ -f "$MODULE" ]] && return @@ -407,6 +417,19 @@ unset MODULE init_sysfs_var [[ "$#" -lt 1 ]] && usage + +# RHEL-specific support options +case "$1" in +"force") + # For scripting purposes, support "kpatch force unload". + # Shift out the "force" to avoid the user-prompt check below. + shift + ;; +"unload") + confirm_prompt "WARNING: Red Hat doesn't support unloading of kpatches, continue anyway?" || exit 1 + ;; +esac + case "$1" in "load") [[ "$#" -ne 2 ]] && usage diff --git a/man/kpatch.1 b/man/kpatch.1 index a30bdb7..765628a 100644 --- a/man/kpatch.1 +++ b/man/kpatch.1 @@ -23,10 +23,10 @@ load --all load load patch module into the running kernel -unload --all +unload --all (UNSUPPORTED) unload all patch modules from the running kernel -unload +unload (UNSUPPORTED) unload patch module from the running kernel info