[ofa-general] [PATCH] installer: update kernel symbol versions

Yosef Etigin yosefe at voltaire.com
Tue Apr 17 01:48:38 PDT 2007


Enable users to build modules over OFED kernel code without additional steps.

install.sh:
  post-install step (conditioned on kernel-ib-devel installation):
   1. save ${K_SRC}/Module.symvers to ${K_SRC}/Module.symvers.save
   2. update ${K_SRC}/Module.symvers with symbol versions from ${K_TREE}/updates/kernel

uninstall.sh: 
  restore ${K_SRC}/Module.symvers.save

Signed-off-by: Yosef Etigin <yosefe at voltaire.com>

diff -urN a/install.sh b/install.sh
--- a/install.sh	2007-04-16 16:00:04.000000000 +0300
+++ b/install.sh	2007-04-17 10:42:20.000000000 +0300
@@ -99,6 +99,10 @@
         find ${STACK_PREFIX} -type d | sort -r | xargs rmdir > $NULL 2>&1
     fi
 
+    # Restore old symbol versions
+    if [ -f ${K_SRC}/Module.symvers.save ]; then
+        mv ${K_SRC}/Module.symvers.save  ${K_SRC}/Module.symvers
+    fi
 }
 
 # Remove installed packages in case of an upgrade
@@ -1023,6 +1027,47 @@
     return 0
 }
 
+# update the kernel symbol versions
+update_kernel_symbols()
+{
+
+    local MOD_SYMVERS=${K_SRC}/Module.symvers
+    
+    if [ -f ${MOD_SYMVERS} -a ! -f ${MOD_SYMVERS}.save ]; then
+        cp ${MOD_SYMVERS} ${MOD_SYMVERS}.save
+    fi
+
+    # find the new symbols that IB modules export
+    # list them all in a file,crc,symbol fashion
+    local IB_MODULES_ROOT=${KERNEL_TREE_ROOT}/updates/kernel
+    local SYM_RECS=""
+    for mod in $(find ${IB_MODULES_ROOT} -name '*.ko')
+    do
+        # break down the list to file name crc and symbol
+        group=$(nm -o ${mod} | 
+              sed -ne s#${IB_MODULES_ROOT}'/^*\(.*\)\.ko:0\{8\}\(\w\{8\}\) . __crc_\(.*\)$#\2,\3,\1#p')
+        SYM_RECS=${SYM_RECS}' '${group}
+        for rec in ${group}
+        do
+            [ -z "${rec}" ] && continue
+            sym=$(echo ${rec} | cut -d, -f2)
+            SYMS=${SYMS}"/${sym}/d;"
+        done
+    done
+
+    # remove old symbols from Module.symvers
+    ex_silent "sed -i ${MOD_SYMVERS} -e '${SYMS}'"
+
+    # add our symbols
+    for rec in ${SYM_RECS}; do
+        echo 0x${rec} | sed -e 's/,/\t/g' >> ${MOD_SYMVERS}
+    done
+
+    echo "Updated kernel symbol versions in ${MOD_SYMVERS}"
+    return 0
+
+}
+
 ibutils()
 {
 
@@ -1674,6 +1719,14 @@
                                         fi
                                     fi                                       
                                     
+                                    # Update kernel symbols
+                                    if isInstalled kernel-ib-devel ; then 
+                                        read -p  "Do you want to update kernel symbols [Y/n]?" ans_r
+                                        if [[ "$ans_r" == "" || "$ans_r" == "y" || "$ans_r" == "Y" || "$ans_r" == "yes" ]]; then
+                                            update_kernel_symbols
+                                        fi
+                                    fi                                       
+                                    
                                     # Set OpenSM configuration
                                     if isInstalled opensm && ( echo "$OFA_PACKAGES" | grep "opensm" > $NULL 2>&1 ); then
                                         read -p  "Do you want to configure OpenSM [Y/n]?" ans_r
@@ -1771,7 +1824,11 @@
             if isInstalled kernel-ib && ( echo "$OFA_KERNEL_PACKAGES" | grep ipoib > $NULL 2>&1 ); then
                 set_ip
             fi
-    
+            
+            if isInstalled kernel-ib-devel ; then
+                update_kernel_symbols
+            fi
+            
             if isInstalled opensm && ( echo "$OFA_PACKAGES" | grep opensm > $NULL 2>&1 ); then
                 set_config_opensm
             fi
diff -urN a/uninstall.sh b/uninstall.sh
--- a/uninstall.sh	2007-04-16 16:00:04.000000000 +0300
+++ b/uninstall.sh	2007-04-16 19:05:43.000000000 +0300
@@ -227,6 +227,12 @@
         find ${STACK_PREFIX} -type d | sort -r | xargs rmdir > $NULL 2>&1
     fi
 
+    # Restore old symbol versions
+    K_SRC=/lib/modules/$(uname -r)/build
+    if [ -f ${K_SRC}/Module.symvers.save ]; then
+        mv ${K_SRC}/Module.symvers.save  ${K_SRC}/Module.symvers
+    fi
+
     # Uninstall SilverStorm package
     if [ -e /sbin/iba_config ]; then
         ex /sbin/iba_config -u



More information about the general mailing list