hal/hald/linux2 osspec.c,1.40,1.41

Kay Sievers kay at freedesktop.org
Sat Jan 21 11:40:02 PST 2006


Update of /cvs/hal/hal/hald/linux2
In directory gabe:/tmp/cvs-serv12064/hald/linux2

Modified Files:
	osspec.c 
Log Message:
2006-01-21  Kay Sievers  <kay.sievers at vrfy.org>

        Remove hotplug helper and depend on udev passing events over
        a socket.

        * configure.in:
        * hald/linux2/osspec.c: (osspec_init):
        * tools/linux/.cvsignore:
        * tools/linux/90-hal.rules:
        * tools/linux/Makefile.am:
        * tools/linux/hal_hotplug.c:



Index: osspec.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux2/osspec.c,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -d -r1.40 -r1.41
--- osspec.c	21 Jan 2006 02:45:27 -0000	1.40
+++ osspec.c	21 Jan 2006 19:39:58 -0000	1.41
@@ -72,16 +72,11 @@
 
 #include "hotplug.h"
 #include "coldplug.h"
-
-#include "hotplug_helper.h"
-
 #include "ids.h"
-
 #include "acpi.h"
 #include "apm.h"
 #include "pmu.h"
 #include "blockdev.h"
-
 #include "osspec_linux.h"
 
 static char *hal_sysfs_path;
@@ -237,94 +232,6 @@
 }
 
 static gboolean
-hald_helper_data (GIOChannel *source, GIOCondition condition, gpointer user_data)
-{
-	struct hald_helper_msg msg;
-	int fd;
-	int retval;
-	struct msghdr smsg;
-	struct cmsghdr *cmsg;
-	struct iovec iov;
-	struct ucred *cred;
-	char cred_msg[CMSG_SPACE(sizeof(struct ucred))];
-
-	fd = g_io_channel_unix_get_fd (source);
-
-	iov.iov_base = &msg;
-	iov.iov_len = sizeof (struct hald_helper_msg);
-
-	memset(&smsg, 0x00, sizeof (struct msghdr));
-	smsg.msg_iov = &iov;
-	smsg.msg_iovlen = 1;
-	smsg.msg_control = cred_msg;
-	smsg.msg_controllen = sizeof (cred_msg);
-
-	retval = recvmsg (fd, &smsg, 0);
-	if (retval <  0) {
-		if (errno != EINTR)
-			HAL_INFO (("Unable to receive message, errno=%d", errno));
-		goto out;
-	}
-	cmsg = CMSG_FIRSTHDR (&smsg);
-	cred = (struct ucred *) CMSG_DATA (cmsg);
-
-	if (cmsg == NULL || cmsg->cmsg_type != SCM_CREDENTIALS) {
-		HAL_INFO (("No sender credentials received, message ignored"));
-		goto out;
-	}
-
-	if (cred->uid != 0) {
-		HAL_INFO (("Sender uid=%i, message ignored", cred->uid));
-		goto out;
-	}
-
-	if (msg.magic != HALD_HELPER_MAGIC) {
-		HAL_INFO (("Magic is wrong, message ignored", cred->uid));
-		goto out;
-	}
-
-	HAL_INFO (("SEQNUM=%lld, TIMESTAMP=%d, ACTION=%s, SUBSYS=%s, SYSFSPATH=%s, DEVNAME=%s, IFINDEX=%d", 
-		   msg.seqnum, msg.time_stamp, msg.action, msg.subsystem, 
-		   msg.sysfs_path, msg.device_name, msg.net_ifindex));
-
-	if (strcmp (msg.action, "add") == 0) {
-		HotplugEvent *hotplug_event;
-
-		hotplug_event = g_new0 (HotplugEvent, 1);
-		hotplug_event->action = HOTPLUG_ACTION_ADD;
-		hotplug_event->type = HOTPLUG_EVENT_SYSFS;
-		g_strlcpy (hotplug_event->sysfs.subsystem, msg.subsystem, sizeof (hotplug_event->sysfs.subsystem));
-		g_snprintf (hotplug_event->sysfs.sysfs_path, sizeof (hotplug_event->sysfs.sysfs_path), "%s%s", 
-			    hal_sysfs_path, msg.sysfs_path);
-		g_strlcpy (hotplug_event->sysfs.device_file, msg.device_name, sizeof (hotplug_event->sysfs.device_file));
-		hotplug_event->sysfs.net_ifindex = msg.net_ifindex;
-
-		/* queue up and process */
-		hotplug_event_enqueue (hotplug_event);
-		hotplug_event_process_queue ();
-
-	} else if (strcmp (msg.action, "remove") == 0) {
-		HotplugEvent *hotplug_event;
-
-		hotplug_event = g_new0 (HotplugEvent, 1);
-		hotplug_event->action = HOTPLUG_ACTION_REMOVE;
-		hotplug_event->type = HOTPLUG_EVENT_SYSFS;
-		g_strlcpy (hotplug_event->sysfs.subsystem, msg.subsystem, sizeof (hotplug_event->sysfs.subsystem));
-		g_snprintf (hotplug_event->sysfs.sysfs_path, sizeof (hotplug_event->sysfs.sysfs_path), "%s%s", 
-			    hal_sysfs_path, msg.sysfs_path);
-		g_strlcpy (hotplug_event->sysfs.device_file, msg.device_name, sizeof (hotplug_event->sysfs.device_file));
-		hotplug_event->sysfs.net_ifindex = msg.net_ifindex;
-
-		/* queue up and process */
-		hotplug_event_enqueue (hotplug_event);
-		hotplug_event_process_queue ();
-	}
-
-out:
-	return TRUE;
-}
-
-static gboolean
 mount_tree_changed_event (GIOChannel *channel, GIOCondition cond,
 		    gpointer user_data)
 {
@@ -345,9 +252,8 @@
 	int helper_socket;
 	struct sockaddr_un saddr;
 	socklen_t addrlen;
-	GIOChannel *udev_channel;
-	GIOChannel *helper_channel;
 	const int on = 1;
+	GIOChannel *udev_channel;
 	GIOChannel *mounts_channel;
 
 	/*
@@ -376,31 +282,6 @@
 	g_io_channel_unref (udev_channel);
 
 	/*
-	 * setup socket for listening from datagrams from the hal.hotplug helper
-	 */
-	memset(&saddr, 0x00, sizeof(saddr));
-	saddr.sun_family = AF_LOCAL;
-	/* use abstract namespace for socket path */
-	strcpy(&saddr.sun_path[1], HALD_HELPER_SOCKET_PATH);
-	addrlen = offsetof(struct sockaddr_un, sun_path) + strlen(saddr.sun_path+1) + 1;
-
-	helper_socket = socket(AF_LOCAL, SOCK_DGRAM, 0);
-	if (helper_socket == -1) {
-		DIE (("Couldn't open socket"));
-	}
-
-	if (bind(helper_socket, (struct sockaddr *) &saddr, addrlen) < 0) {
-		fprintf (stderr, "Error binding to %s: %s\n", HALD_HELPER_SOCKET_PATH, strerror(errno));
-		exit (1);
-	}
-	/* enable receiving of the sender credentials */
-	setsockopt(helper_socket, SOL_SOCKET, SO_PASSCRED, &on, sizeof(on));
-
-	helper_channel = g_io_channel_unix_new (helper_socket);
-	g_io_add_watch (helper_channel, G_IO_IN, hald_helper_data, NULL);
-	g_io_channel_unref (helper_channel);
-
-	/*
 	 * set mount points for /proc and /sys, possibly overridden for testing
 	 */
 	hal_sysfs_path = getenv ("SYSFS_PATH");




More information about the hal-commit mailing list