[Pkg-utopia-commits] r987 - in packages/unstable/hal/debian: . patches

Sjoerd Simons sjoerd at costa.debian.org
Mon Sep 4 13:24:35 UTC 2006


Author: sjoerd
Date: 2006-09-04 13:24:34 +0000 (Mon, 04 Sep 2006)
New Revision: 987

Added:
   packages/unstable/hal/debian/patches/22_recognize_partitions.patch
Modified:
   packages/unstable/hal/debian/changelog
Log:
* debian/patches/22_recognize_partitions.patch
  - Added. More robust recognition that a block device is a partition. Fixes
  detecting scsi cdrom drives as partitions (From upstream git) 

Modified: packages/unstable/hal/debian/changelog
===================================================================
--- packages/unstable/hal/debian/changelog	2006-09-03 17:28:18 UTC (rev 986)
+++ packages/unstable/hal/debian/changelog	2006-09-04 13:24:34 UTC (rev 987)
@@ -1,3 +1,11 @@
+hal (0.5.7.1-2) unstable; urgency=low
+
+  * debian/patches/22_recognize_partitions.patch
+    - Added. More robust recognition that a block device is a partition. Fixes
+    detecting scsi cdrom drives as partitions (From upstream git) 
+
+ -- Sjoerd Simons <sjoerd at debian.org>  Mon,  4 Sep 2006 14:51:47 +0200
+
 hal (0.5.7.1-1) unstable; urgency=low
 
   [ Sjoerd Simons ]

Added: packages/unstable/hal/debian/patches/22_recognize_partitions.patch
===================================================================
--- packages/unstable/hal/debian/patches/22_recognize_partitions.patch	                        (rev 0)
+++ packages/unstable/hal/debian/patches/22_recognize_partitions.patch	2006-09-04 13:24:34 UTC (rev 987)
@@ -0,0 +1,97 @@
+diff -Naur hal-0.5.7.1.vanilla/hald/linux2/blockdev.c hal-0.5.7.1/hald/linux2/blockdev.c
+--- hal-0.5.7.1.vanilla/hald/linux2/blockdev.c	2006-09-04 14:46:58.000000000 +0200
++++ hal-0.5.7.1/hald/linux2/blockdev.c	2006-09-04 15:16:21.000000000 +0200
+@@ -1036,11 +1036,11 @@
+ }
+ 
+ void
+-hotplug_event_begin_remove_blockdev (const gchar *sysfs_path, gboolean is_partition, void *end_token)
++hotplug_event_begin_remove_blockdev (const gchar *sysfs_path, void *end_token)
+ {
+ 	HalDevice *d;
+ 
+-	HAL_INFO (("block_rem: sysfs_path=%s is_part=%d", sysfs_path, is_partition));
++	HAL_INFO (("block_rem: sysfs_path=%s", sysfs_path));
+ 
+ 	d = hal_device_store_match_key_value_string (hald_get_gdl (), "linux.sysfs_path", sysfs_path);
+ 	if (d == NULL) {
+@@ -1050,6 +1050,7 @@
+ 		const char *stor_udi;
+ 		HalDevice *stor_dev;
+ 		gboolean is_fakevolume;
++		gboolean is_partition;
+ 
+ 		is_partition = hal_device_property_get_bool (d, "volume.is_partition");
+ 
+diff -Naur hal-0.5.7.1.vanilla/hald/linux2/blockdev.h hal-0.5.7.1/hald/linux2/blockdev.h
+--- hal-0.5.7.1.vanilla/hald/linux2/blockdev.h	2006-09-04 14:46:58.000000000 +0200
++++ hal-0.5.7.1/hald/linux2/blockdev.h	2006-09-04 15:14:46.000000000 +0200
+@@ -30,7 +30,7 @@
+ 
+ void hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const char *device_file, gboolean is_partition, HalDevice *parent, void *end_token);
+ 
+-void hotplug_event_begin_remove_blockdev (const gchar *sysfs_path, gboolean is_partition, void *end_token);
++void hotplug_event_begin_remove_blockdev (const gchar *sysfs_path, void *end_token);
+ 
+ gboolean blockdev_rescan_device (HalDevice *d);
+ 
+diff -Naur hal-0.5.7.1.vanilla/hald/linux2/hotplug.c hal-0.5.7.1/hald/linux2/hotplug.c
+--- hal-0.5.7.1.vanilla/hald/linux2/hotplug.c	2006-09-04 14:46:58.000000000 +0200
++++ hal-0.5.7.1/hald/linux2/hotplug.c	2006-09-04 15:16:49.000000000 +0200
+@@ -103,7 +103,7 @@
+ 			
+ 			g_snprintf (path, HAL_PATH_MAX, "%s/class/net" , get_hal_sysfs_path());
+ 			if ((dir = g_dir_open (path, 0, &err)) == NULL) {
+-				HAL_ERROR (("Unable to open %/class/net: %s", get_hal_sysfs_path(), err->message));
++				HAL_ERROR (("Unable to open %s/class/net: %s", get_hal_sysfs_path(), err->message));
+ 				g_error_free (err);
+ 				goto out;
+ 			}
+@@ -278,17 +278,31 @@
+ 							     (void *) hotplug_event);
+ 		}
+ 	} else if (hotplug_event->type == HOTPLUG_EVENT_SYSFS_BLOCK) {
+-		gboolean is_partition;
+-		size_t len;
+-
+-		len = strlen(hotplug_event->sysfs.sysfs_path);
+-		is_partition = isdigit(hotplug_event->sysfs.sysfs_path[len - 1]) ||
+-			       strstr (hotplug_event->sysfs.sysfs_path, "/fakevolume") ;
+-
+ 		if (hotplug_event->action == HOTPLUG_ACTION_ADD) {
+ 			HalDevice *parent = NULL;
++			int range;
++			gboolean is_partition;
++			gboolean is_fakevolume;
++			
++			/* it's a partition if and only if it doesn't have the range file...
++			 *
++			 * notably the device mapper partitions do have a range file, but that's
++			 * fine, we don't count them as partitions anyway...
++			 *
++			 * also, if the sysfs ends with "fakevolume" the hotplug event is synthesized
++			 * from within HAL for partitions on the main block device
++			 */
++			is_fakevolume = FALSE;
++			if (strcmp (hal_util_get_last_element (hotplug_event->sysfs.sysfs_path), "fakevolume") == 0) {
++				is_fakevolume = TRUE;
++			}
++			is_partition = TRUE;
++			if (is_fakevolume ||
++			    hal_util_get_int_from_file (hotplug_event->sysfs.sysfs_path, "range", &range, 0)) {
++				is_partition = FALSE;
++			}
+ 
+-			if (is_partition) {
++			if (is_partition || is_fakevolume) {
+ 				gchar *parent_path;
+ 
+ 				parent_path = hal_util_get_parent_path (hotplug_event->sysfs.sysfs_path);
+@@ -321,7 +335,6 @@
+ 							  (void *) hotplug_event);
+ 		} else if (hotplug_event->action == HOTPLUG_ACTION_REMOVE) {
+ 			hotplug_event_begin_remove_blockdev (hotplug_event->sysfs.sysfs_path,
+-							     is_partition,
+ 							     (void *) hotplug_event);
+ 		}
+ 	} else {




More information about the Pkg-utopia-commits mailing list