hal/tools/linux Makefile.am, 1.11, 1.12 hal_dev.c, 1.8, NONE hal_hotplug.c, 1.24, 1.25

David Zeuthen david at freedesktop.org
Tue Jan 18 11:48:15 PST 2005


Update of /cvs/hal/hal/tools/linux
In directory gabe:/tmp/cvs-serv19239/tools/linux

Modified Files:
	Makefile.am hal_hotplug.c 
Removed Files:
	hal_dev.c 
Log Message:
2005-01-18  David Zeuthen  <david at fubar.dk>

	* tools/linux/Makefile.am: Remove hal.dev build rules

	* tools/linux/hal_dev.c: Remove

	* configure.in: Set linux2 as the default backend

	* hald/linux: Remove all files here as they will get reimplemented
	in hald/linux2

	* hald/linux2: Add a bunch of new files

	* hald/linux2/probing: Add some new files

2005-01-18  David Zeuthen  <davidz at redhat.com>

	Merge some more changes from the stable branch (except those
	in hald/linux and doc/spec)

	2005-01-12  David Zeuthen  <davidz at redhat.com>

	* hald/callout.c (callout_timeout_handler): Be tough and kill
	the misbehaving child the hard way - suggestion from Joe Shaw.

	2005-01-12  David Zeuthen  <davidz at redhat.com>

	* hald/linux/osspec.c (HOTPLUG_TIMEOUT): Increase to 25 seconds
	to better cope with callouts timeout of 10 seconds

	* hald/callout.c (iochn_data): Cope with callouts terminating
	and free timeout handler
	(callout_timeout_handler): New function; kill callouts if they
	time out
	(process_next_callout): Setup timeout for callouts - set to
	ten seconds

	2005-01-11  David Zeuthen  <davidz at redhat.com>

	* hald/callout.c: Simplify a lot more by demanding that callouts
	are run sequentially - which they are anyway since everything is
	serialized. Make a mental note to review and stress test this in
	the morning.

	2005-01-11  David Zeuthen  <davidz at redhat.com>

	* hald/callout.c: Fix some craziness adding an idle handler for
	detecting when callouts complete - fixes bug on my new AMD64
	system with device add/remove prior to completion of callouts -
	one visible effect was that fstab-sync was crashing since it
	couldn't retrieve the block.device device as the device was
	removed prior to the completion of the callout

	2005-01-07  David Zeuthen  <davidz at redhat.com>

	* fdi/20freedesktop/ide-drives.fdi: Also check IDE floppies for whether
	they are Zip drives

	2005-01-07  Joe Shaw  <joeshaw at novell.com>

	* configure.in: Check for popt when building fstab-sync and error
	out if it's not found.

	* tools/Makefile.am: Build fstab-sync conditionally based on
	whether --enable-fstab-sync is passed in.

	2005-01-06  David Zeuthen  <davidz at redhat.com>

	* libhal/libhal.c (hal_device_query_capability): Patch from Tim
	Müller <t.i.m at zen.co.uk>. The attached patch fixes a small memory
	leak in libhal's hal_device_query_capability().

	2005-01-03  David Zeuthen  <davidz at redhat.com>

	* configure.in: Added it to ALL_LINGUAS

	* po/it.po: Italien translation from Pier Luigi Fiorini
	<pierluigi.fiorini at mockup.org>

	2004-12-15  David Zeuthen  <davidz at redhat.com>

	* fdi/20freedesktop/usb-zip-drives.fdi: Only match on actual
	harddisks to avoid wrong detection of e.g. "Iomega ZipCD 650 USB CDRW"
	drives (Red Hat bug #143834)

	* fdi/20freedesktop/ide-drives.fdi: ditto



Index: Makefile.am
===================================================================
RCS file: /cvs/hal/hal/tools/linux/Makefile.am,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- Makefile.am	30 Aug 2004 09:29:09 -0000	1.11
+++ Makefile.am	18 Jan 2005 19:48:13 -0000	1.12
@@ -9,12 +9,10 @@
 	-I$(top_srcdir) \
 	@PACKAGE_CFLAGS@
 
-libexec_PROGRAMS = hal.hotplug hal.dev hal-hotplug-map
+libexec_PROGRAMS = hal.hotplug hal-hotplug-map
 
 hal_hotplug_SOURCES = hal_hotplug.c
 
-hal_dev_SOURCES = hal_dev.c
-
 hal_hotplug_map_SOURCES = hal_hotplug_map.c
 hal_hotplug_map_LDADD = @DBUS_LIBS@ $(top_builddir)/libhal/libhal.la
 
@@ -24,8 +22,6 @@
 install-data-local :
 	$(mkinstalldirs) $(DESTDIR)$(LINUX_HOTPLUG_DIR)/default
 	- cd $(DESTDIR)$(LINUX_HOTPLUG_DIR)/default && $(LN_S) $(libexecdir)/hal.hotplug 20-hal.hotplug
-	$(mkinstalldirs) $(DESTDIR)/etc/dev.d/default
-	- cd $(DESTDIR)/etc/dev.d/default && $(LN_S) $(libexecdir)/hal.dev 10-hal.dev
 if HOTPLUG_MAP_ENABLED
 	$(mkinstalldirs) $(DESTDIR)$(SYSCONFDIR)/hal/device.d
 	- cd $(DESTDIR)$(SYSCONFDIR)/hal/device.d && $(LN_S) $(libexecdir)/hal-hotplug-map 40-hal-hotplug-map.hal
@@ -33,7 +29,6 @@
 
 uninstall-local :
 	- rm -f $(DESTDIR)$(LINUX_HOTPLUG_DIR)/default/20-hal.hotplug
-	- rm -f $(DESTDIR)/etc/dev.d/default/10-hal.dev
 if HOTPLUG_MAP_ENABLED
 	- rm -f $(DESTDIR)$(SYSCONFDIR)/hal/device.d/40-hal-hotplug-map.hal
 endif

--- hal_dev.c DELETED ---

Index: hal_hotplug.c
===================================================================
RCS file: /cvs/hal/hal/tools/linux/hal_hotplug.c,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- hal_hotplug.c	18 Oct 2004 22:52:05 -0000	1.24
+++ hal_hotplug.c	18 Jan 2005 19:48:13 -0000	1.25
@@ -45,7 +45,7 @@
 #include <sys/un.h>
 #include <time.h>
 
-#include "../../hald/linux/hald_helper.h"
+#include "../../hald/linux2/hotplug_helper.h"
 
 static char sysfs_mnt_path[PATH_MAX];
 
@@ -85,191 +85,12 @@
 	return ret;
 }
 
-static const char *file_list_net[] = {
-	"ifindex",
-	NULL
-};
-
-static const char *file_list_class_device[] = {
-	"dev",
-	NULL
-};
-
-static const char *file_list_usb[] = {
-	"idProduct",
-	"idVendor",
-	"bcdDevice",
-	"bMaxPower",
-	/*"serial", */
-	"bmAttributes",
-	/*"manufacturer",*/
-	/*"product",*/
-	"bDeviceClass",
-	"bDeviceSubClass",
-	"bDeviceProtocol",
-	"bNumConfigurations",
-	"bConfigurationValue",
-	"bNumInterfaces",
-	NULL
-
-};
-
-static const char *file_list_usbif[] = {
-	"bInterfaceClass",
-	"bInterfaceSubClass",
-	"bInterfaceProtocol",
-	"bInterfaceNumber",
-	NULL
-};
-
-static const char *file_list_scsi[] = { "vendor",
-					"model",
-					"type",
-					NULL };
-
-static const char *file_list_scsi_generic[] = { "device", 
-						NULL };
-
-static const char *file_list_scsi_host[] = { "device",
-					     NULL };
-
-static const char *file_list_block[] = {
-	"dev",
-	"size",
-	/*"removable",*/
-	NULL
-};
-
-static const char *file_list_pci[] = {
-	"device",
-	"vendor",
-	"subsystem_device",
-	"subsystem_vendor",
-	"class",
-	NULL
-};
-
 /* safely strcat() at most the remaining space in 'dst' */
 #define strcat_len(dst, src) do { \
 	dst[sizeof (dst) - 1] = '\0'; \
 	strncat (dst, src, sizeof (dst) - strlen (dst) - 1); \
 } while(0)
 
-static int
-wait_for_sysfs_info (char *devpath, char *hotplug_type, int *net_ifindex)
-{
-	size_t devpath_len;
-	const char **file_list;
-	int timeout;
-	int rc;
-	struct stat stat_buf;
-	int i;
-	char path[PATH_MAX];
-
-	devpath_len = strlen (devpath);
-
-	file_list = NULL;
-
-	if (strcmp (hotplug_type, "pci") == 0) {
-		file_list = file_list_pci;
-	} else if (strcmp (hotplug_type, "usb") == 0) {
-		int is_interface = 0;
-
-		if (strstr (devpath, "class") != NULL) {
-			file_list = file_list_class_device;
-		} else {
-			for (i = devpath_len - 1; devpath[i] != '/' && i > 0; --i) {
-				if (devpath[i] == ':') {
-					is_interface = 1;
-					break;
-				}
-			}
-
-			if (is_interface) {
-				file_list = file_list_usbif;
-			} else
-				file_list = file_list_usb;
-		}
-	} else if (strcmp (hotplug_type, "scsi") == 0) {
-		file_list = file_list_scsi;
-	} else if (strcmp (hotplug_type, "scsi_generic") == 0) {
-		file_list = file_list_scsi_generic;
-	} else if (strcmp (hotplug_type, "scsi_host") == 0) {
-		file_list = file_list_scsi_host;
-	} else if (strcmp (hotplug_type, "block") == 0) {
-		file_list = file_list_block;
-	} else if (strcmp (hotplug_type, "net") == 0) {
-		file_list = file_list_net;
-	}
-
-	if (file_list == NULL) {
-		return -1;
-	}
-
-	timeout = 0;
-
-try_again:
-	if (timeout > 0) {
-		usleep (100 * 1000); /* 100 ms */
-	}
-	timeout += 100 * 1000;
-
-	if (timeout >= 10 * 1000*1000) { /* 10 secs */
-		syslog (LOG_NOTICE, "timout(%d ms) waiting for %s ",
-			timeout / 1000, devpath);
-		return -1;
-	}
-
-
-	/* first, check directory */
-	strncpy (path, sysfs_mnt_path, PATH_MAX);
-	strcat_len (path, devpath);
-
-	/*printf("path0 = %s\n", path); */
-
-	rc = stat (path, &stat_buf);
-	/*printf("rc0 = %d\n", rc); */
-	if (rc != 0)
-		goto try_again;
-
-	/* second, check each requested file */
-	for (i = 0; file_list[i] != NULL; i++) {
-		const char *file;
-
-		file = file_list[i];
-		strncpy (path, sysfs_mnt_path, PATH_MAX);
-		strcat_len (path, devpath);
-		strcat_len (path, "/");
-		strcat_len (path, file);
-		/*printf("path1 = %s\n", path); */
-
-		rc = stat (path, &stat_buf);
-
-		/*printf("rc1 = %d\n", rc); */
-
-		if (rc != 0)
-			goto try_again;
-	}
-	
-	/* lip service for 'net' */
-	if (strcmp (hotplug_type, "net") == 0) {
-		FILE *f;
-		char buf[80];
-
-		strncpy (path, sysfs_mnt_path, PATH_MAX);
-		strcat_len (path, devpath);
-		strcat_len (path, "/ifindex");
-		if ((f = fopen (path, "r")) != NULL) {
-			memset (buf, 0, sizeof (buf));
-			fread (buf, sizeof (buf) - 1, 1, f);
-			fclose (f);
-
-			*net_ifindex = atoi(buf);
-		}		
-	}
-
-	return 0;
-}
 
 /** Entry point
  *
@@ -289,13 +110,17 @@
 	char *devpath;
 	char *action;
 	char *seqnum_str;
+	char *devname;
 	int net_ifindex = -1;
 	unsigned long long seqnum;
 
 	if (argc != 2)
 		return 1;
 
-	openlog ("hal.hotplug", LOG_PID, LOG_USER);
+	openlog ("hal.hotplug2", LOG_PID, LOG_USER);
+
+	syslog (LOG_INFO, "ACTION=%s SUBSYS=%s SEQNUM=%s DEVPATH=%s PHYSDEVPATH=%s", 
+		getenv ("ACTION"), argv[1], getenv ("SEQNUM"), getenv ("DEVPATH"), getenv ("PHYSDEVPATH"));
 
 	if (get_sysfs_mnt_path() != 0) {
 		syslog (LOG_ERR, "could not get mountpoint for sysfs");
@@ -316,7 +141,7 @@
 
 	devpath = getenv ("DEVPATH");
 	if (devpath == NULL) {
-		syslog (LOG_ERR, "DEVPATH is not set");
+		syslog (LOG_ERR, "DEVPATH is not set (subsystem %s)", subsystem);
 		goto out;
 	}
 
@@ -333,9 +158,27 @@
 	}
 	seqnum = strtoull (seqnum_str, NULL, 10);
 
-	/* wait for information to be published in sysfs */
-	if (strcmp (action, "add") == 0)
-		wait_for_sysfs_info (devpath, subsystem, &net_ifindex);
+	devname = getenv ("DEVNAME");
+
+
+	/* pickup ifindex for net as nameif'ing the interface a
+	 * hotplug event handler will screw us otherwise */
+	if (strcmp (subsystem, "net") == 0) {
+		FILE *f;
+		char buf[80];
+		char path[PATH_MAX];
+
+		strncpy (path, sysfs_mnt_path, PATH_MAX);
+		strcat_len (path, devpath);
+		strcat_len (path, "/ifindex");
+		if ((f = fopen (path, "r")) != NULL) {
+			memset (buf, 0, sizeof (buf));
+			fread (buf, sizeof (buf) - 1, 1, f);
+			fclose (f);
+
+			net_ifindex = atoi(buf);
+		}
+	}
 
 	memset (&saddr, 0x00, sizeof(struct sockaddr_un));
 	saddr.sun_family = AF_LOCAL;
@@ -345,11 +188,14 @@
 
 	memset (&msg, 0x00, sizeof (msg));
 	msg.magic = HALD_HELPER_MAGIC; 
-	msg.type = HALD_HOTPLUG;
 	msg.seqnum = seqnum;
 	strncpy (msg.action, action, HALD_HELPER_STRLEN-1);
 	strncpy (msg.subsystem, subsystem, HALD_HELPER_STRLEN-1);
 	strncpy (msg.sysfs_path, devpath, HALD_HELPER_STRLEN-1);
+	if (devname != NULL)
+		strncpy (msg.device_name, devname, HALD_HELPER_STRLEN-1);
+	else
+		msg.device_name[0] = '\0';
 	msg.net_ifindex = net_ifindex;
 	msg.time_stamp = time (NULL);
 




More information about the hal-commit mailing list