Runtime searching for pci and usb ids

Sjoerd Simons sjoerd at luon.net
Tue Dec 7 07:19:29 PST 2004


Hi,

  Currently hal only checks the location of the ids files at configure time.
  This breaks if the machine hal was build on has these files at another
  locations (or if they are changed for some reason).

  Attached patch changes hal to search these files at boot time. 

  Sjoerd
-- 
Do your part to help preserve life on Earth -- by trying to preserve your own.
-------------- next part --------------
Index: configure.in
===================================================================
RCS file: /cvs/hal/hal/configure.in,v
retrieving revision 1.57
diff -u -r1.57 configure.in
--- configure.in	1 Nov 2004 23:19:04 -0000	1.57
+++ configure.in	7 Dec 2004 15:17:08 -0000
@@ -18,20 +18,6 @@
 
 AC_ARG_WITH(init-scripts,       [  --with-init-scripts=<os> Style of init scripts to install (redhat)])
 AC_ARG_WITH(pid-file,    [  --with-pid-file=<file>  PID file for HAL daemon])
-AC_ARG_WITH(hwdata,[  --with-hwdata=<dir>     where PCI and USB IDs are found (auto)])
-if ! test -z "$with_hwdata" ; then
-   HWDATA_DIR="$with_hwdata"
-else
-   for dir in /usr/share/hwdata /usr/share/misc /usr/share; do
-      AC_CHECK_FILE($dir/pci.ids,HWDATA_DIR=$dir)
-   done
-fi
-if test -z "$HWDATA_DIR"; then
-   AC_ERROR(cannot find pci.ids. Use --with-hwdata to specify location)
-fi
-AC_SUBST(HWDATA_DIR)
-AC_DEFINE_UNQUOTED(HWDATA_DIR,"$HWDATA_DIR", [Where PCI and USB IDs are found])
-
 
 AC_ARG_WITH(hal_user,[  --with-hal-user=<user>  User for running the HAL daemon (haldaemon)])
 if test -z "$with_hal_user" ; then
Index: hald/linux/pci_bus_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/pci_bus_device.c,v
retrieving revision 1.9
diff -u -r1.9 pci_bus_device.c
--- hald/linux/pci_bus_device.c	14 Oct 2004 19:21:41 -0000	1.9
+++ hald/linux/pci_bus_device.c	7 Dec 2004 15:17:09 -0000
@@ -283,7 +283,6 @@
 
 	fp = fopen (path, "r");
 	if (fp == NULL) {
-		HAL_ERROR (("couldn't open PCI database at %s,", path));
 		return FALSE;
 	}
 
@@ -369,11 +368,24 @@
 static void
 pci_device_init (BusDeviceHandler *self)
 {
+	dbus_bool_t ret = FALSE;
+	int i;
+	char *locations[] = { "/usr/share/hwdata/pci.ids",
+                        "/usr/share/misc/pci.ids",
+                        "/usr/share/pci.ids",
+                        "/var/lib/misc/pci.ids",
+                        NULL
+	};
 	/* get all drivers under /sys/bus/pci/drivers */
 	drivers_collect ("pci");
 
 	/* Load /usr/share/hwdata/pci.ids */
-	pci_ids_load (HWDATA_DIR "/pci.ids");
+	for (i=0 ; locations[i] != NULL && !ret ; i++) {
+		ret = pci_ids_load (locations[i]);
+	}
+	if (!ret) {
+		HAL_ERROR (("couldn't open PCI database"));
+	}
 }
 
 /** Shutdown function for PCI handling
Index: hald/linux/usb_bus_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/usb_bus_device.c,v
retrieving revision 1.15
diff -u -r1.15 usb_bus_device.c
--- hald/linux/usb_bus_device.c	14 Oct 2004 18:51:12 -0000	1.15
+++ hald/linux/usb_bus_device.c	7 Dec 2004 15:17:09 -0000
@@ -549,15 +549,26 @@
 static void
 usb_device_init ()
 {
+	dbus_bool_t ret = FALSE;
+	int i;
+	char *locations[] = { "/usr/share/hwdata/usb.ids",
+                        "/usr/share/misc/usb.ids",
+                        "/usr/share/usb.ids",
+                        "/var/lib/misc/usb.ids",
+                        NULL
+	};
 
 	/* get all drivers under /sys/bus/usb/drivers */
 	drivers_collect ("usb");
 
 	/* Load /usr/share/hwdata/usb.ids */
-	usb_ids_load (HWDATA_DIR "/usb.ids");
-
+	for (i=0; locations[i] != NULL && !ret ; i++) {
+		ret = usb_ids_load (locations[i]);
+	}
+	if (!ret) {
+		HAL_ERROR (("couldn't open USB database"));
+	}
 	/* Parse /proc/bus/usb/devices */
-
 	usb_proc_parse ();
 }
 
-------------- next part --------------
_______________________________________________
hal mailing list
hal at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/hal


More information about the Hal mailing list