hal/hald/linux block_class_device.c,1.36,1.37

David Zeuthen david at pdx.freedesktop.org
Tue Jul 6 14:36:51 PDT 2004


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

Modified Files:
	block_class_device.c 
Log Message:
2004-07-06  David Zeuthen  <david at fubar.dk>

	* hald/linux/block_class_device.c (detect_media): Fix media detection
	that was broken when introducing support for floppy drives twelwe
	days ago :-/



Index: block_class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/block_class_device.c,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -d -r1.36 -r1.37
--- block_class_device.c	6 Jul 2004 16:35:56 -0000	1.36
+++ block_class_device.c	6 Jul 2004 21:36:49 -0000	1.37
@@ -447,25 +447,22 @@
 				     "storage.cdrom.support_media_changed");
 
 	if (!is_cdrom) {
+		gboolean no_partitions = hal_device_property_get_bool (
+			d, "block.no_partitions");
+
 		fd = open (device_file, O_RDONLY);
 
-		if (fd == -1) {
-			/* open failed */
-			/*HAL_WARNING (("open(\"%s\", O_RDONLY) failed, "
-			  "errno=%d", device_file, errno));*/
+		if (fd == -1 && errno == ENOMEDIUM) {
 
-			if (errno == ENOMEDIUM &&
-			    hal_device_property_get_bool (
-				    d, "block.no_partitions") ) {
-				
+			/* No media */
+
+			if (no_partitions) {
 
 				child = hal_device_store_match_key_value_string (
 					hald_get_gdl (), "info.parent",
 					hal_device_get_udi (d));
 
 				if (child != NULL ) {
-					force_unmount_of_all_childs (d);
-
 					HAL_INFO (("Removing volume for "
 						   "no_partitions device %s", 
 						   device_file));
@@ -473,16 +470,17 @@
 					g_signal_connect (child, "callouts_finished",
 							  G_CALLBACK (volume_remove_from_gdl), NULL);
 					hal_callout_device (child, FALSE);
-					
-					close (fd);
 
 					/* GDL was modified */
 					return TRUE;
 				}
-			} 
-			
-		} else if (hal_device_property_get_bool (
-				   d, "block.no_partitions")) {
+			} else {
+				/* Will cause storm of hotplug remove events */
+				force_unmount_of_all_childs (d);
+			}
+		} else if (fd > 0 && no_partitions) {
+
+			/* Media detected */
 
 			/* For drives with partitions, we simply get hotplug
 			 * events so only do something for e.g. floppies */





More information about the hal-commit mailing list