From 22f0d38f86509f1a003d32fe1aa17e92c45e5a7b Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Tue, 3 Jun 2014 13:00:53 -0500 Subject: [PATCH 1/2] kpatch: improve "unload --all" error message In the case of "kpatch unload --all", just show the usage help instead of this: # kpatch unload --all basename: unrecognized option '--all' Try 'basename --help' for more information. unloading patch module: basename: unrecognized option '--all' Try 'basename --help' for more information. rmmod: ERROR: Module is builtin. kpatch: failed to unload patch --all --- kpatch/kpatch | 1 + 1 file changed, 1 insertion(+) diff --git a/kpatch/kpatch b/kpatch/kpatch index 3fd6e42..fe7ab00 100755 --- a/kpatch/kpatch +++ b/kpatch/kpatch @@ -166,6 +166,7 @@ case "$1" in "unload") [[ "$#" -ne 2 ]] && usage + [[ $2 =~ ^- ]] && usage unload_module "$2" || die "failed to unload patch $2" ;; From d2b765fea50695ec4dd626cecd203f60e58c02c5 Mon Sep 17 00:00:00 2001 From: Josh Poimboeuf Date: Tue, 3 Jun 2014 13:09:38 -0500 Subject: [PATCH 2/2] kpatch: consistent naming: module vs patch Try to be more consistent with the naming of patch modules. They are patch modules, where patch is the adjective and module is the noun. So calling them patches is confusing. --- kpatch/kpatch | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/kpatch/kpatch b/kpatch/kpatch index fe7ab00..8e26f93 100755 --- a/kpatch/kpatch +++ b/kpatch/kpatch @@ -151,7 +151,7 @@ case "$1" in *) PATCH="$2" find_module "$PATCH" || die "can't find $PATCH" - load_module "$MODULE" || die "failed to load patch $PATCH" + load_module "$MODULE" || die "failed to load module $PATCH" ;; esac ;; @@ -160,14 +160,14 @@ case "$1" in [[ "$#" -ne 2 ]] && usage PATCH="$2" find_module "$PATCH" || die "can't find $PATCH" - load_module "$MODULE" replace=1 || die "failed to load patch $PATCH" + load_module "$MODULE" replace=1 || die "failed to load module $PATCH" unload_disabled_modules || die "failed to unload old modules" ;; "unload") [[ "$#" -ne 2 ]] && usage [[ $2 =~ ^- ]] && usage - unload_module "$2" || die "failed to unload patch $2" + unload_module "$2" || die "failed to unload module $2" ;; "install") @@ -182,7 +182,7 @@ case "$1" in shift ;; --) - [[ -z "$2" ]] && die "no patch file specified" + [[ -z "$2" ]] && die "no module file specified" PATCH="$2" ;; esac @@ -199,7 +199,7 @@ case "$1" in echo "installing $PATCH ($KVER)" mkdir -p $INSTALLDIR/$KVER || die "failed to create install directory" - cp -f "$PATCH" $INSTALLDIR/$KVER || die "failed to install patch $PATCH" + cp -f "$PATCH" $INSTALLDIR/$KVER || die "failed to install module $PATCH" if lsinitrd -k $KVER &> /dev/null; then echo "rebuilding $KVER initramfs" @@ -219,7 +219,7 @@ case "$1" in shift ;; --) - [[ -z "$2" ]] && die "no patch file specified" + [[ -z "$2" ]] && die "no module file specified" PATCH="$2" [[ "$PATCH" != $(basename "$PATCH") ]] && die "please supply patch module name without path" ;; @@ -230,7 +230,7 @@ case "$1" in [[ ! -e $INSTALLDIR/$KVER/"$PATCH" ]] && die "$PATCH is not installed for kernel $KVER" echo "uninstalling $PATCH ($KVER)" - rm -f $INSTALLDIR/$KVER/"$PATCH" || die "failed to uninstall patch $PATCH" + rm -f $INSTALLDIR/$KVER/"$PATCH" || die "failed to uninstall module $PATCH" if lsinitrd -k $KVER &> /dev/null; then echo "rebuilding $KVER initramfs" dracut -f --kver $KVER || die "dracut failed" @@ -261,7 +261,7 @@ case "$1" in PATCH="$2" find_module "$PATCH" || die "can't find $PATCH" echo "Patch information for $PATCH:" - /usr/sbin/modinfo "$MODULE" || die "failed to get info for patch $PATCH" + /usr/sbin/modinfo "$MODULE" || die "failed to get info for module $PATCH" ;; "help"|"-h"|"--help")