Blame SOURCES/0002-Support-modprobe-style-names-in-kpatch-load.patch

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