Package: discover
Version: 2.1.1-1
The hardware detecting package installation script discover-pkginstall
should have a way to map from kernel modules to debian packages, as
some packages are related to kernel modules and not for exapmle PCI
devices.
For example, the hdapsd package should be installed on all systems
with the hdaps kernel module (to park the thinkpad hard drive in
emergencies), and the cpqarrayd package should be installed if the
cpqarray kernel module is loaded.
Here is a draft patch relative to the current svn repository to enable
this. It introduces a new bus type, linmod, based on the content of
/proc/modules. It loads the bus, but using it trigger a segfault when
I test it. I'm not quite sure what is wrong, but I submit it here for
review and to make sure it isn't forgotten.
Index: debian/changelog
===================================================================
--- debian/changelog (revision 1393)
+++ debian/changelog (working copy)
@@ -2,6 +2,9 @@
* Only call module-assistant in discover-pkginstall if it is
installed.
+ * Support linmod (linux kernel modules) as a pseudo bus, to
+ make it possible to map loaded kernel modules to Debian
+ packages.
-- Petter Reinholdtsen <[EMAIL PROTECTED]> Wed, 8 Aug 2007 20:24:53 +0200
Index: include/discover/discover.h
===================================================================
--- include/discover/discover.h (revision 1388)
+++ include/discover/discover.h (working copy)
@@ -149,12 +149,13 @@
PCMCIA,
SCSI,
USB
+ ,LINMOD
} discover_bus_t;
/**
* Number of buses we support
* */
-#define BUS_COUNT 5
+#define BUS_COUNT 6
/**
* Enumerate the types of data files: vendor, busclass, and device.
Index: include/discover/sysdep.h
===================================================================
--- include/discover/sysdep.h (revision 1388)
+++ include/discover/sysdep.h (working copy)
@@ -76,6 +76,7 @@
discover_sysdep_data_t *_discover_get_usb_raw(void);
discover_sysdep_data_t *_discover_get_pcmcia_raw(void);
discover_sysdep_data_t *_discover_get_scsi_raw(void);
+discover_sysdep_data_t *_discover_get_linmod_raw(void);
#ifdef __cplusplus
}
Index: lib/sysdep.c
===================================================================
--- lib/sysdep.c (revision 1388)
+++ lib/sysdep.c (working copy)
@@ -54,6 +54,7 @@
_discover_get_pcmcia_raw,
_discover_get_scsi_raw,
_discover_get_usb_raw
+ ,_discover_get_linmod_raw
};
Index: lib/conf.c
===================================================================
--- lib/conf.c (revision 1388)
+++ lib/conf.c (working copy)
@@ -73,6 +73,7 @@
{ "pcmcia", 0, 0, NULL },
{ "scsi", 0, 0, NULL },
{ "usb", 0, 0, NULL },
+ { "linmod", 0, 0, NULL },
{ NULL }
};
Index: etc/discover.conf
===================================================================
--- etc/discover.conf (revision 1388)
+++ etc/discover.conf (working copy)
@@ -11,5 +11,6 @@
<bus name="pcmcia"/>
<bus name="scsi"/>
<bus name="usb"/>
+ <bus name="linmod"/>
</busscan>
</conffile>
Index: sysdeps/linux/Makefile.in
===================================================================
--- sysdeps/linux/Makefile.in (revision 1388)
+++ sysdeps/linux/Makefile.in (working copy)
@@ -7,8 +7,8 @@
###############################################################################
# Build
-SOURCES= ata.c pci.c pcmcia.c usb.c scsi.c
-OBJS= ata.lo pci.lo pcmcia.lo usb.lo scsi.lo
+SOURCES= ata.c pci.c pcmcia.c usb.c scsi.c linmod.c
+OBJS= ata.lo pci.lo pcmcia.lo usb.lo scsi.lo linmod.lo
libsysdeps.la: ${OBJS}
${LTLINK} -o $@ ${OBJS}
Index: sysdeps/linux/linmod.c
===================================================================
--- sysdeps/linux/linmod.c (revision 0)
+++ sysdeps/linux/linmod.c (revision 0)
@@ -0,0 +1,87 @@
+/* linmod.c -- Scan the list of kernel modules loaded
+ *
+ * Copyright 2007 Petter Reinholdtsen
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ */
+
+#include "config.h"
+
+#include <stdio.h>
+#include <string.h>
+#include <sys/stat.h>
+#include <dirent.h>
+
+#include <discover/sysdep.h>
+
+#define PATH_PROC_MODULES "/proc/modules"
+
+/*
+ * This function is specific to each sysdep.
+ */
+static void
+_discover_sysdep_init(discover_sysdep_data_t *node)
+{
+ (void)node; /* Avoid warning about unused node */
+}
+
+/*
+ * Loop over /proc/modules, adding each kernel module into the list of
+ * bus devices.
+ */
+discover_sysdep_data_t *
+_discover_get_linmod_raw(void)
+{
+ char *line = NULL;
+ FILE *modfile;
+ size_t len = 0;
+
+ discover_sysdep_data_t *first, *last, *node;
+
+ first = last = node = NULL;
+
+ modfile = fopen(PATH_PROC_MODULES, "r");
+ if(NULL == modfile) {
+ return NULL;
+ }
+
+ /* For each entry in the PATH_PROC_MODULES file */
+ while ((getline(&line, &len, modfile)) != -1) {
+ char *modnameend = strchr(line, ' '); /* module name is first word */
+ *modnameend = '\0';
+ fprintf(stderr, "Found '%s'\n", line);
+
+ /* Initialize the node */
+ node = _discover_sysdep_data_new();
+ _discover_sysdep_init(node);
+
+ /* Save the node information */
+ node->busclass = strdup("0");
+ node->model = strdup(line);
+ node->vendor = strdup("0");
+
+ if (last) {
+ last->next = node;
+ last = node;
+ } else {
+ first = last = node;
+ }
+ free(line);
+ line=NULL;
+ }
+
+ fclose(modfile);
+ return first;
+}
Happy hacking,
--
Petter Reinholdtsen
--
To UNSUBSCRIBE, email to [EMAIL PROTECTED]
with a subject of "unsubscribe". Trouble? Contact [EMAIL PROTECTED]