hal/hald/linux block_class_device.c,1.30,1.31

Joe Shaw joe at pdx.freedesktop.org
Wed Jun 9 11:54:00 PDT 2004


Update of /cvs/hal/hal/hald/linux
In directory pdx:/tmp/cvs-serv12992/hald/linux

Modified Files:
	block_class_device.c 
Log Message:
2004-06-09  Joe Shaw  <joeshaw at novell.com>

	* hald/linux/block_class_device.c (detect_media): Set info.product
	to volume.label if it's set.
	(block_class_pre_process): Set info.product to volume.label if
	it's set, otherwise try to append the fstype to "Volume".

Index: block_class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/block_class_device.c,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- a/block_class_device.c	9 Jun 2004 18:11:59 -0000	1.30
+++ b/block_class_device.c	9 Jun 2004 18:53:58 -0000	1.31
@@ -789,6 +789,19 @@
 
 			detect_fs (child);
 
+			/* If we have a nice volume label, set it */
+			if (hal_device_has_property (child, "volume.label")) {
+				const char *label;
+
+				label = hal_device_property_get_string (
+					child, "volume.label");
+
+				if (label != NULL && label[0] != '\0') {
+					hal_device_property_set_string (
+						child, "info.product", label);
+				}
+			}
+
 			/* add new device */
 			g_signal_connect (child, "callouts_finished",
 					  G_CALLBACK (device_move_from_tdl_to_gdl), NULL);
@@ -978,6 +991,8 @@
 					stordev_udi);
 
 	if (hal_device_property_get_bool (d, "block.is_volume")) {
+		char *volume_name;
+
 		/* We are a volume */
 		find_and_set_physical_device (d);
 		hal_device_property_set_bool (d, "info.virtual", TRUE);
@@ -990,12 +1005,34 @@
 
 		/* block device that is a partition; e.g. a storage volume */
 
-		/** @todo  Guestimate product name; use volume label */
-		hal_device_property_set_string (d, "info.product", "Volume");
-		
 		/* Detect filesystem and volume label */
 		detect_fs (d);
 
+		volume_name = g_strdup (
+			hal_device_property_get_string (d, "volume.label"));
+
+		if (volume_name == NULL || volume_name[0] == '\0') {
+			const char *fstype;
+
+			g_free (volume_name);
+
+			fstype = hal_device_property_get_string (
+				d,
+				"volume.fstype");
+
+			if (fstype == NULL || fstype[0] == '\0')
+				volume_name = g_strdup ("Volume");
+			else {
+				volume_name = g_strdup_printf ("Volume (%s)",
+							       fstype);
+			}
+		}
+
+		hal_device_property_set_string (d, "info.product",
+						volume_name);
+
+		g_free (volume_name);
+
 		/* Not much to do for volumes; our parent already set the
 		 * appropriate values for the storage device backing us */
 





More information about the hal-commit mailing list