hal/hald/linux block_class_device.c, 1.19, 1.20 linux_dvd_rw_utils.c, 1.4, 1.5 linux_dvd_rw_utils.h, 1.3, 1.4

David Zeuthen david at pdx.freedesktop.org
Wed May 5 13:46:36 PDT 2004


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

Modified Files:
	block_class_device.c linux_dvd_rw_utils.c linux_dvd_rw_utils.h 
Log Message:
2004-05-05  David Zeuthen  <david at fubar.dk>

	* hald/linux/linux_dvd_rw_utils.c (get_dvd_media_type): new function

	* hald/linux/block_class_device.c: rename some properties and ensure
	that all properties for a namespace is always available with default
	values - it's easiest to look at the diff to see what's changed; one
	highlight is the introduction of the volume.* namespace.
	(detect_media): use new utility in linux_dvd_rw_utils.c to get the
	disc type for DVD's.

	* tools/callouts/fstab-update.sh: property names changed

	* fdi/20freedesktop/lexar-media-cf-reader.fdi: propertys name changed

	* fdi/20freedesktop/6in1-card-reader.fdi: property names changed



Index: block_class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/block_class_device.c,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- a/block_class_device.c	4 May 2004 21:56:47 -0000	1.19
+++ b/block_class_device.c	5 May 2004 20:46:34 -0000	1.20
@@ -69,6 +69,8 @@
 
 static void etc_mtab_process_all_block_devices (dbus_bool_t force);
 
+static void detect_fs (HalDevice *d);
+
 typedef struct {
 	HalDevice *device;
 	ClassDeviceHandler *handler;
@@ -171,55 +173,58 @@
 		return;
 	}
 
+	hal_device_property_set_bool (d, "storage.cdrom.cdr", FALSE);
+	hal_device_property_set_bool (d, "storage.cdrom.cdrw", FALSE);
+	hal_device_property_set_bool (d, "storage.cdrom.dvd", FALSE);
+	hal_device_property_set_bool (d, "storage.cdrom.dvdr", FALSE);
+	hal_device_property_set_bool (d, "storage.cdrom.dvdram", FALSE);
+	hal_device_property_set_bool (d, "storage.cdrom.dvdplusr", FALSE);
+	hal_device_property_set_bool (d, "storage.cdrom.dvdplusrw", FALSE);
+
 	if (capabilities & CDC_CD_R) {
-		hal_device_add_capability (d, "storage.cdr");
-		hal_device_property_set_bool (d, "storage.cdr", TRUE);
+		hal_device_property_set_bool (d, "storage.cdrom.cdr", TRUE);
 	}
 	
 	if (capabilities & CDC_CD_RW) {
-		hal_device_add_capability (d, "storage.cdrw");
-		hal_device_property_set_bool (d, "storage.cdrw", TRUE);
+		hal_device_property_set_bool (d, "storage.cdrom.cdrw", TRUE);
 	}
 	if (capabilities & CDC_DVD) {
 		int profile;
 		
-		hal_device_add_capability (d, "storage.dvd");
-		hal_device_property_set_bool (d, "storage.dvd", TRUE);
+		hal_device_property_set_bool (d, "storage.cdrom.dvd", TRUE);
 		
 		profile = get_dvd_r_rw_profile (fd);
 		HAL_INFO (("profile %d\n", profile));
 		if (profile == 2) {
-			hal_device_add_capability (d, "storage.dvdplusr");
-			hal_device_property_set_bool (d, "storage.dvdplusr", TRUE);
-			hal_device_add_capability (d, "storage.dvdplusrw");
-			hal_device_property_set_bool (d, "storage.dvdplusrw", TRUE);
+			hal_device_property_set_bool (d, "storage.cdrom.dvdplusr", TRUE);
+			hal_device_property_set_bool (d, "storage.cdrom.dvdplusrw", TRUE);
 		} else if (profile == 0) {
-			hal_device_add_capability(d, "storage.dvdplusr");
-			hal_device_property_set_bool(d, "storage.dvdplusr",
+			hal_device_property_set_bool(d, "storage.cdrom.dvdplusr",
 					     TRUE);
 		} else if (profile == 1) {
-			hal_device_add_capability (d, "storage.dvdplusrw");
-			hal_device_property_set_bool (d, "storage.dvdplusrw", TRUE);
+			hal_device_property_set_bool (d, "storage.cdrom.dvdplusrw", TRUE);
 		}
 	}
 	if (capabilities & CDC_DVD_R) {
-		hal_device_add_capability (d, "storage.dvdr");
-		hal_device_property_set_bool (d, "storage.dvdr", TRUE);
+		hal_device_property_set_bool (d, "storage.cdrom.dvdr", TRUE);
 	}
 	if (capabilities & CDC_DVD_RAM) {
-		hal_device_add_capability (d, "storage.dvdram");
 		hal_device_property_set_bool (d, "storage.dvdram", TRUE);
 	}
 	
 	/* while we're at it, check if we support media changed */
 	if (ioctl (fd, CDROM_MEDIA_CHANGED) >= 0) {
 		hal_device_property_set_bool (d, "storage.cdrom.support_media_changed", TRUE);
+	} else {
+		hal_device_property_set_bool (d, "storage.cdrom.support_media_changed", FALSE);
 	}
 	
 	if (get_read_write_speed(fd, &read_speed, &write_speed) >= 0) {
 		hal_device_property_set_int (d, "storage.cdrom.read_speed", read_speed);
 		if (write_speed > 0)
 			hal_device_property_set_int(d, "storage.cdrom.write_speed", write_speed);
+		else
+			hal_device_property_set_int(d, "storage.cdrom.write_speed", 0);
 	}
 
 	close (fd);
@@ -242,7 +247,7 @@
 
 	device_file = hal_device_property_get_string (d, "block.device");
 	device_mount_point =
-	    hal_device_property_get_string (d, "block.mount_point");
+	    hal_device_property_get_string (d, "volume.mount_point");
 
 	umount_argv[2] = device_file;
 
@@ -289,16 +294,16 @@
 						      TRUE,
 						      DBUS_TYPE_INVALID);
 
-			/* Woohoo, have to change block.mount_point *afterwards*, other
+			/* Woohoo, have to change volume.mount_point *afterwards*, other
 			 * wise device_mount_point points to garbage and D-BUS throws
 			 * us off the bus, in fact it's doing exiting with code 1
 			 * for us - not nice
 			 */
 			device_property_atomic_update_begin ();
-			hal_device_property_set_string (d, "block.mount_point",
+			hal_device_property_set_string (d, "volume.mount_point",
 						"");
-			hal_device_property_set_string (d, "block.fstype", "");
-			hal_device_property_set_bool (d, "block.is_mounted",
+			hal_device_property_set_string (d, "volume.fstype", "");
+			hal_device_property_set_bool (d, "volume.is_mounted",
 					      FALSE);
 			device_property_atomic_update_end ();
 		}
@@ -404,8 +409,8 @@
 		return FALSE;
 
 	/* we do special treatment for optical discs */
-	is_cdrom = hal_device_has_property (d, "storage.media") &&
-	    strcmp (hal_device_property_get_string (d, "storage.media"),
+	is_cdrom = hal_device_has_property (d, "storage.drive_type") &&
+	    strcmp (hal_device_property_get_string (d, "storage.drive_type"),
 		    "cdrom") == 0
 	    && hal_device_property_get_bool (d,
 				     "storage.cdrom.support_media_changed");
@@ -433,7 +438,7 @@
 
 		if (fd == -1) {
 			/* open failed */
-			HAL_WARNING (("open(\"%s\", O_RDONLY|O_NONBLOCK|O_EXCL) failed, " "errno=%d", device_file, errno));
+			/*HAL_WARNING (("open(\"%s\", O_RDONLY|O_NONBLOCK|O_EXCL) failed, " "errno=%d", device_file, errno));*/
 			return FALSE;
 		}
 
@@ -519,6 +524,15 @@
 			hal_device_property_set_string (child, "info.product",
 						"Disc");
 
+			/* set defaults */
+			hal_device_property_set_string (child, "volume.label", "");
+			hal_device_property_set_string (child, "volume.uuid", "");
+			hal_device_property_set_string (child, "volume.disc_type", "");
+			hal_device_property_set_string (child, "volume.fstype", "");
+			hal_device_property_set_string (child, "volume.mount_point", "");			
+			hal_device_property_set_bool (child, "volume.is_mounted", FALSE);
+
+
 			/* set UDI as appropriate */
 			strncpy (udi,
 				 hal_device_property_get_string (d, "info.udi"),
@@ -529,16 +543,15 @@
 
 			/* set disc media type as appropriate */
 			type = ioctl (fd, CDROM_DISC_STATUS, CDSL_CURRENT);
-			close(fd);
 			switch (type) {
 			case CDS_AUDIO:		/* audio CD */
 				hal_device_property_set_string (child,
-						"storage.cdrom.media_type",
+						"volume.disc_type",
 						"audio");
 				break;
 			case CDS_MIXED:		/* mixed mode CD */
 				hal_device_property_set_string (child,
-						"storage.cdrom.media_type",
+						"volume.disc_type",
 						"mixed");
 				break;
 			case CDS_DATA_1:	/* data CD */
@@ -546,22 +559,75 @@
 			case CDS_XA_2_1:
 			case CDS_XA_2_2:
 				hal_device_property_set_string (child,
-						"storage.cdrom.media_type",
+						"volume.disc_type",
 						"data");
 				break;
 			case CDS_NO_INFO:	/* blank or invalid CD */
 				hal_device_property_set_string (child,
-						"storage.cdrom.media_type",
+						"volume.disc_type",
 						"blank");
 				break;
 
 			default:		/* should never see this */
 				hal_device_property_set_string (child,
-						"storage.cdrom.media_type",
+						"volume.disc_type",
 						"unknown");
 				break;
 			}
 
+			type = get_dvd_media_type (fd);
+			if ((type != -1) && ((type&0xF0) == 0x10)) {
+				switch (type) {
+				case 0x10: /* DVD-ROM */
+					HAL_INFO (("########### huu hey"));
+					hal_device_property_set_string (
+						child, 
+						"volume.disc_type",
+						"dvd_rom");
+					break;
+				case 0x11: /* DVD-R Sequential */
+					hal_device_property_set_string (
+						child, 
+						"volume.disc_type",
+						"dvd_r");
+					break;
+				case 0x12: /* DVD-RAM */
+					hal_device_property_set_string (
+						child, 
+						"volume.disc_type",
+						"dvd_ram");
+					break;
+				case 0x13: /* DVD-RW Restricted Overwrite */
+					hal_device_property_set_string (
+						child, 
+						"volume.disc_type",
+						"dvd_rw_restricted_overwrite");
+					break;
+				case 0x14: /* DVD-RW Sequential */
+					hal_device_property_set_string (
+						child, 
+						"volume.disc_type",
+						"dvd_rw");
+					break;
+				case 0x1A: /* DVD+RW */
+					hal_device_property_set_string (
+						child, 
+						"volume.disc_type",
+						"dvd_plus_rw");
+					break;
+				case 0x1B: /* DVD+R */
+					hal_device_property_set_string (
+						child, 
+						"volume.disc_type",
+						"dvd_plus_r");
+					break;
+				default: 
+					break;
+				}
+			}
+
+			close(fd);
+
 			detect_fs (child);
 
 			/* add new device */
@@ -616,11 +682,11 @@
 	if (rc != 0)
 		return;
 
-	hal_device_property_set_string (d, "block.fstype", vid->fs_name);
+	hal_device_property_set_string (d, "volume.fstype", vid->fs_name);
 	if (vid->label_string[0] != '\0')
-		hal_device_property_set_string (d, "block.volume_label", vid->label_string);
+		hal_device_property_set_string (d, "volume.label", vid->label_string);
 	if (vid->uuid_string[0] != '\0')
-		hal_device_property_set_string (d, "block.volume_uuid", vid->uuid_string);
+		hal_device_property_set_string (d, "volume.uuid", vid->uuid_string);
 
 	volume_id_close(vid);
 
@@ -672,10 +738,14 @@
 		stordev_udi = d->udi;
 		stordev = d;
 
-		/* Default */
+		/* Defaults */
 		hal_device_property_set_string (
 			stordev, "storage.bus", "unknown");
 
+		hal_device_property_set_string (stordev, 
+						"storage.model", "");
+		hal_device_property_set_string (stordev, 
+						"storage.vendor", "");
 
 		/* walk up the device chain to find the physical device, 
 		 * start with our parent. On the way, optionally pick up
@@ -742,6 +812,9 @@
 		hal_device_property_set_bool (d, "info.virtual", TRUE);
 		hal_device_add_capability (d, "volume");
 		hal_device_property_set_string (d, "info.category", "volume");
+		hal_device_property_set_string (d, "volume.label", "");
+		hal_device_property_set_string (d, "volume.uuid", "");
+		hal_device_property_set_string (d, "volume.disc_type", "");
 
 		/* block device that is a partition; e.g. a storage volume */
 
@@ -757,12 +830,6 @@
 		return;
 	} 
 
-	/* be pessimistic */
-	hal_device_property_set_bool (stordev, "storage.cdr", FALSE);
-	hal_device_property_set_bool (stordev, "storage.cdrw", FALSE);
-	hal_device_property_set_bool (stordev, "storage.dvd", FALSE);
-	hal_device_property_set_bool (stordev, "storage.dvdr", FALSE);
-	hal_device_property_set_bool (stordev, "storage.dvdram", FALSE);
 
 	/* We are a disk or cdrom drive; maybe we even offer 
 	 * removable media 
@@ -806,7 +873,7 @@
 					  ide_name);
 		if (media != NULL) {
 			hal_device_property_set_string (stordev, 
-							"storage.media",
+							"storage.drive_type",
 							media);
 			
 			/* Set for removable media */
@@ -836,9 +903,12 @@
 			  "%s/device/vendor", sysfs_path);
 		attr = sysfs_open_attribute (attr_path);
 		if (sysfs_read_attribute (attr) >= 0) {
+			strip_space (attr->value);
 			hal_device_property_set_string (d, "info.vendor",
-							strip_space (attr->
-								     value));
+							attr->value);
+			hal_device_property_set_string (stordev,
+							"storage.vendor",
+							attr->value);
 			sysfs_close_attribute (attr);
 		}
 		
@@ -865,21 +935,21 @@
 			case 0:	/* Disk */
 				hal_device_property_set_string (
 					stordev, 
-					"storage.media", 
+					"storage.drive_type", 
 					"disk");
 				break;
 			case 1:	/* Tape */
 				has_removable_media = TRUE;
 				hal_device_property_set_string (
 					stordev,
-					"storage.media", 
+					"storage.drive_type", 
 					"tape");
 				has_removable_media = TRUE;
 				break;
 			case 5:	/* CD-ROM */
 				hal_device_property_set_string (
 					stordev, 
-					"storage.media", 
+					"storage.drive_type", 
 					"cdrom");
 				has_removable_media = TRUE;
 				break;
@@ -892,16 +962,9 @@
 		}
 	} else {
 		/** @todo block device on non-IDE and non-SCSI device;
-		 *  how to find the name and the media-type? Right now
-		 *  we just assume that the disk is fixed and of type
-		 *  flash.
+		 *  how to find the name and the media-type? 
 		 */
 		
-		hal_device_property_set_string (
-			stordev, 
-			"storage.media",
-			"flash");
-		
 		/* guestimate product name */
 		hal_device_property_set_string (d, "info.product", "Disk");
 		
@@ -912,16 +975,9 @@
 		stordev, 
 		"storage.removable", 
 		has_removable_media);
-	
-	if (has_removable_media) {
-		hal_device_add_capability (
-			stordev, 
-			"storage.removable");
-	}
-
 
-	if (hal_device_has_property (stordev, "storage.media") &&
-	    strcmp (hal_device_property_get_string (stordev, "storage.media"), 
+	if (hal_device_has_property (stordev, "storage.drive_type") &&
+	    strcmp (hal_device_property_get_string (stordev, "storage.drive_type"), 
 		    "cdrom") == 0) {
 		cdrom_check (stordev, device_file);
 	}
@@ -931,11 +987,6 @@
 
 	hal_device_property_set_bool (stordev, "storage.hotpluggable",
 				      is_hotpluggable);
-	if (is_hotpluggable) {
-		hal_device_add_capability (stordev, "storage.hotpluggable");
-	}
-
-
 
 	/* FINALLY, merge information derived from a .fdi file, from the 
 	 * physical device that is backing this block device.
@@ -1211,16 +1262,16 @@
 
 			was_mounted =
 				hal_device_property_get_bool (d,
-							      "block.is_mounted");
+							      "volume.is_mounted");
 
 			/* Yay! Found a mount point; set properties accordingly */
 			hal_device_property_set_string (d,
-							"block.mount_point",
+							"volume.mount_point",
 							mp->mount_point);
-			hal_device_property_set_string (d, "block.fstype",
+			hal_device_property_set_string (d, "volume.fstype",
 							mp->fs_type);
 			hal_device_property_set_bool (d,
-						      "block.is_mounted",
+						      "volume.is_mounted",
 						      TRUE);
 
 			/* only overwrite block.device if it's not set */
@@ -1263,13 +1314,13 @@
 		device_property_atomic_update_begin ();
 		
 		was_mounted =
-			hal_device_property_get_bool (d, "block.is_mounted");
+			hal_device_property_get_bool (d, "volume.is_mounted");
 
-		hal_device_property_set_bool (d, "block.is_mounted",
+		hal_device_property_set_bool (d, "volume.is_mounted",
 					      FALSE);
-		hal_device_property_set_string (d, "block.mount_point",
+		hal_device_property_set_string (d, "volume.mount_point",
 						"");
-		hal_device_property_set_string (d, "block.fstype", "");
+		hal_device_property_set_string (d, "volume.fstype", "");
 
 		device_property_atomic_update_end ();
 

Index: linux_dvd_rw_utils.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/linux_dvd_rw_utils.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- a/linux_dvd_rw_utils.c	3 Mar 2004 17:56:56 -0000	1.4
+++ b/linux_dvd_rw_utils.c	5 May 2004 20:46:34 -0000	1.5
@@ -349,3 +349,31 @@
 
 	return 0;
 }
+
+int
+get_dvd_media_type (int fd)
+{
+	ScsiCommand *cmd;
+	int retval = -1;
+	unsigned char header[8];
+	unsigned char *list;
+	int i, len;
+
+	cmd = scsi_command_new_from_fd (fd);
+
+	scsi_command_init (cmd, 0, 0x46);
+	scsi_command_init (cmd, 1, 1);
+	scsi_command_init (cmd, 8, 8);
+	scsi_command_init (cmd, 9, 0);
+	if (scsi_command_transport (cmd, READ, header, 8)) {
+		/* GET CONFIGURATION failed */
+		scsi_command_free (cmd);
+		return -1;
+	}
+	
+	retval = (header[6]<<8)|(header[7]);
+
+
+	scsi_command_free (cmd);
+	return retval;
+}

Index: linux_dvd_rw_utils.h
===================================================================
RCS file: /cvs/hal/hal/hald/linux/linux_dvd_rw_utils.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- a/linux_dvd_rw_utils.h	3 Mar 2004 17:56:56 -0000	1.3
+++ b/linux_dvd_rw_utils.h	5 May 2004 20:46:34 -0000	1.4
@@ -11,5 +11,6 @@
 
 int get_dvd_r_rw_profile (int fd);
 int get_read_write_speed (int fd, int *read_speed, int *write_speed);
+int get_dvd_media_type (int fd);
 
 #endif				/* LINUX_DVD_RW_UTILS_H */





More information about the hal-commit mailing list