From 1d63ce84932efda559d6d745930e1b05f446a334 Mon Sep 17 00:00:00 2001 From: Seth Jennings Date: Tue, 26 Aug 2014 15:47:07 -0500 Subject: [PATCH 2/5] Support modprobe style names in kpatch load To: rhkernel-list@redhat.com When the argument is a .ko file, it should be considered a path (i.e. don't even look for it in the installed DB). When the argument is a module name, it should be considered a loaded or installed module (and then in the case of kpatch load we have to do a reverse translation of all installed modules to see if any of them match). Signed-off-by: Seth Jennings --- kpatch/kpatch | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/kpatch/kpatch b/kpatch/kpatch index 074beeb..1d33641 100755 --- a/kpatch/kpatch +++ b/kpatch/kpatch @@ -73,9 +73,29 @@ __find_module () { return 1 } +mod_name () { + MODNAME="$(basename $1)" + MODNAME="${MODNAME%.ko}" + MODNAME="${MODNAME//-/_}" +} + find_module () { arg="$1" - __find_module "${arg}" + if [[ "$arg" =~ \.ko ]]; then + __find_module "$arg" || return 1 + mod_name "$MODULE" + return + else + for i in $INSTALLDIR/$(uname -r)/*; do + mod_name "$i" + if [[ $MODNAME == $arg ]]; then + MODULE="$i" + return + fi + done + fi + + return 1 } find_core_module() { @@ -268,7 +288,8 @@ case "$1" in [[ -e "$kdir" ]] || continue for module in $kdir/*; do [[ -e "$module" ]] || continue - echo "$(basename $module) ($(basename $kdir))" + mod_name "$module" + echo "$MODNAME ($(basename $kdir))" done done ;; -- 1.9.3