hal: Branch 'master'

David Zeuthen david at kemper.freedesktop.org
Tue Oct 9 10:48:20 PDT 2007


 hald/linux/device.c  |   13 +++++++++++++
 hald/linux/hotplug.c |   12 ++++++++++++
 hald/linux/hotplug.h |    2 ++
 hald/linux/osspec.c  |   17 +++++++++++++++++
 4 files changed, 44 insertions(+)

New commits:
diff-tree 94b60f1a712a84649f2890bcd4060a73d29cb195 (from 66cb813715538818770df7685ab2be4d85d75a07)
Author: Bill Nottingham <notting at redhat.com>
Date:   Tue Oct 9 13:47:50 2007 -0400

    handle 'move' events for network devices
    
    udev emits 'move' events when network interfaces are renamed. This patch
    adds support for hald to handle such events.

diff --git a/hald/linux/device.c b/hald/linux/device.c
index 5b44108..a03be12 100644
--- a/hald/linux/device.c
+++ b/hald/linux/device.c
@@ -582,6 +582,18 @@ error:
 
 	return d;
 }
+
+static gboolean
+net_refresh (HalDevice *d)
+{
+	const gchar *path, *ifname;
+	
+	path = hal_device_property_get_string (d, "linux.sysfs_path");
+	ifname = hal_util_get_last_element (path);
+	hal_device_property_set_string (d, "net.interface", ifname);
+	return TRUE;
+}
+
 static const char *
 net_get_prober (HalDevice *d)
 {
@@ -3372,6 +3384,7 @@ static DevHandler dev_handler_net = 
 { 
 	.subsystem    = "net",
 	.add          = net_add,
+	.refresh      = net_refresh,
 	.get_prober   = net_get_prober,
 	.post_probing = net_post_probing,
 	.compute_udi  = net_compute_udi,
diff --git a/hald/linux/hotplug.c b/hald/linux/hotplug.c
index 38e416c..d57a022 100644
--- a/hald/linux/hotplug.c
+++ b/hald/linux/hotplug.c
@@ -88,6 +88,12 @@ hotplug_event_begin_sysfs (HotplugEvent 
 	d = hal_device_store_match_key_value_string (hald_get_gdl (),
 						     "linux.sysfs_path",
 						     hotplug_event->sysfs.sysfs_path);
+	
+	if (d == NULL && hotplug_event->action == HOTPLUG_ACTION_MOVE) {
+		d = hal_device_store_match_key_value_string(hald_get_gdl (),
+							    "linux.sysfs_path",
+							    hotplug_event->sysfs.sysfs_path_old);
+	}
 
 #if 0
 	/* we should refresh the device when we get "change" uevent */
@@ -176,6 +182,12 @@ hotplug_event_begin_sysfs (HotplugEvent 
                                                    hotplug_event->sysfs.sysfs_path,
                                                    d,
                                                    (void *) hotplug_event);
+		} else if (hotplug_event->action == HOTPLUG_ACTION_MOVE && d != NULL) {
+			hal_device_property_set_string (d, "linux.sysfs_path", hotplug_event->sysfs.sysfs_path);
+			hotplug_event_refresh_dev (hotplug_event->sysfs.subsystem,
+                                                   hotplug_event->sysfs.sysfs_path,
+                                                   d,
+                                                   (void *) hotplug_event);
 		} else {
 			hotplug_event_end ((void *) hotplug_event);
 		}
diff --git a/hald/linux/hotplug.h b/hald/linux/hotplug.h
index f4c60cb..27dc9d5 100644
--- a/hald/linux/hotplug.h
+++ b/hald/linux/hotplug.h
@@ -37,6 +37,7 @@ typedef enum {
 	HOTPLUG_ACTION_ONLINE,
 	HOTPLUG_ACTION_OFFLINE,
 	HOTPLUG_ACTION_CHANGE,
+	HOTPLUG_ACTION_MOVE
 } HotplugActionType;
 
 typedef enum {
@@ -63,6 +64,7 @@ typedef struct
 		struct {
 			char subsystem[HAL_NAME_MAX];		/* Kernel subsystem the device belongs to */
 			char sysfs_path[HAL_PATH_MAX];		/* Kernel device devpath */
+			char sysfs_path_old[HAL_PATH_MAX];	/* Old kernel device devpath (for 'move') */
 			char device_file[HAL_PATH_MAX];	        /* Device node for the device */
 			unsigned long long seqnum;		/* kernel uevent sequence number */
 			int net_ifindex;			/* Kernel ifindex for network devices */
diff --git a/hald/linux/osspec.c b/hald/linux/osspec.c
index b3bb44d..f103d46 100644
--- a/hald/linux/osspec.c
+++ b/hald/linux/osspec.c
@@ -146,6 +146,16 @@ hald_udev_data (GIOChannel *source, GIOC
 
 			g_snprintf (hotplug_event->sysfs.sysfs_path, sizeof (hotplug_event->sysfs.sysfs_path),
 				    "/sys%s", &key[8]);
+		} else if (strncmp(key, "DEVPATH_OLD=", 12) == 0) {
+
+                        /* md devices are handled via looking at /proc/mdstat */
+                        if (g_str_has_prefix (key + 12, "/block/md")) {
+                                HAL_INFO (("skipping md event for %s", key + 8));
+                                goto invalid;
+                        }
+
+			g_snprintf (hotplug_event->sysfs.sysfs_path_old, sizeof (hotplug_event->sysfs.sysfs_path_old),
+				    "/sys%s", &key[12]);
 		} else if (strncmp(key, "SUBSYSTEM=", 10) == 0)
 			g_strlcpy (hotplug_event->sysfs.subsystem, &key[10], sizeof (hotplug_event->sysfs.subsystem));
 		else if (strncmp(key, "DEVNAME=", 8) == 0)
@@ -233,6 +243,13 @@ hald_udev_data (GIOChannel *source, GIOC
 		goto out;
 	}
 
+	if (strcmp (action, "move") == 0) {
+		hotplug_event->action = HOTPLUG_ACTION_MOVE;
+		hotplug_event_enqueue (hotplug_event);
+		hotplug_event_process_queue ();
+		goto out;
+	}
+
 	if (strcmp (action, "remove") == 0) {
 		hotplug_event->action = HOTPLUG_ACTION_REMOVE;
 		hotplug_event_enqueue (hotplug_event);


More information about the hal-commit mailing list