pci-database: pcidev2 (NEW) - new approach to detect kernel modules

areq areq at pld-linux.org
Sun Jan 30 20:40:23 CET 2011


Author: areq                         Date: Sun Jan 30 19:40:23 2011 GMT
Module: pci-database                  Tag: HEAD
---- Log message:
- new approach to detect kernel modules

---- Files affected:
pci-database:
   pcidev2 (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: pci-database/pcidev2
diff -u /dev/null pci-database/pcidev2:1.1
--- /dev/null	Sun Jan 30 20:40:23 2011
+++ pci-database/pcidev2	Sun Jan 30 20:40:17 2011
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+ALIAS=/lib/modules/`uname -r`/modules.alias
+
+fmodule()
+{
+for f in /sys/bus/pci/devices/*/uevent
+do
+    . $f
+    len=0
+    mod="$shownotfound"
+    case "$MODALIAS" in
+        $1)
+        while read alias pci module
+        do
+        case "$MODALIAS" in
+            $pci)
+                if [ ${#pci} -gt $len ] ; then
+                    len=${#pci}
+                    mod=$module
+                elif [ ${#pci} -eq $len ] ; then
+                    mod=$module    #moze kiedys tu bedzie obsluga priorytetow modulow
+                fi
+            ;;
+        esac
+        done < $ALIAS
+        [ -z $mod ] || if [ -z $modonly ]; then
+                echo $PCI_ID $mod
+             else
+                echo $mod
+             fi
+        ;;
+    esac
+done
+}
+
+shownotfound=""
+modonly=""
+
+while ! [ -z "$1" ]; do
+  case "$1" in
+    sto*) fmodule "*bc01sc0*"
+        ;;
+    scsi) fmodule "*bc01sc0[047]i*"
+        ;;
+    ide) fmodule "*bc01sc0[15]i*"
+        ;;
+    sata) fmodule "*bc01sc06i*"
+        ;;
+    net) fmodule "*bc02sc00i*"
+        ;;
+    usb) fmodule "*bc0Csc03i*"
+        ;;
+    nf) shownotfound="UnknownModule"
+        ;;
+    /m) modonly=1
+        ;;
+     *) echo "pcidev2 [/m] [ide] [net] [scsi] [sata] [storage] [usb]"
+        ;;
+  esac
+  shift
+done
================================================================


More information about the pld-cvs-commit mailing list