hal/hald/linux block_class_device.c,1.26,1.27

David Zeuthen david at pdx.freedesktop.org
Tue Jun 1 11:47:26 PDT 2004


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

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

	* hald/hald_conf.[ch]: New files, vendor and user specific
	configuration of the HAL daemon

	* hald/Makefile.am (hald_SOURCES): Add hald_conf.[ch]

	* hald/linux/block_class_device.c (block_class_pre_process): Set
	storage.media_check_enabled and storage.automount_enabled to
	default value from HaldConf. Forgot to set volume.is_mounted to
	FALSE when building the device. NOTE: when media_check_enabled is
	set to FALSE use touch /dev/sda (or whatever) to force a poll for
	media. So, now to write a /etc/hal/hald.conf configuration file
	parser :-)
	(cdrom_check): Set storage.cdrom.eject_check_enabled to default
	value from HaldConf
	(detect_media): Disable continous printing of error when no medium
	is in storage device. Respect the storage.media_check_enabled and
	storage.cdrom.eject_check_enabled properties

	* hald/hald.c (main): Remove opt_run_as



Index: block_class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/block_class_device.c,v
retrieving revision 1.26
retrieving revision 1.27
diff -u -d -r1.26 -r1.27
--- a/block_class_device.c	30 May 2004 23:29:44 -0000	1.26
+++ b/block_class_device.c	1 Jun 2004 18:47:23 -0000	1.27
@@ -54,6 +54,7 @@
 #include "../logger.h"
 #include "../device_store.h"
 #include "../callout.h"
+#include "../hald_conf.h"
 #include "class_device.h"
 #include "common.h"
  
@@ -196,6 +197,11 @@
 	hal_device_property_set_bool (d, "storage.cdrom.dvdplusr", FALSE);
 	hal_device_property_set_bool (d, "storage.cdrom.dvdplusrw", FALSE);
 
+	hal_device_property_set_bool (
+		d, 
+		"storage.cdrom.eject_check_enabled", 
+		(hald_get_conf ())->storage_cdrom_eject_check_enabled);
+
 	if (capabilities & CDC_CD_R) {
 		hal_device_property_set_bool (d, "storage.cdrom.cdr", TRUE);
 	}
@@ -408,7 +414,7 @@
  *                              it will only have effect if the device is
  *                              in the GDL and is of capability block and
  *                              is not a volume
- *  @param                      TRUE iff the GDL was modified
+ *  @return                     TRUE iff the GDL was modified
  */
 static dbus_bool_t
 detect_media (HalDevice * d)
@@ -418,6 +424,10 @@
 	const char *device_file;
 	HalDevice *child;
 
+	/* respect policy */
+	if (!hal_device_property_get_bool (d, "storage.media_check_enabled"))
+		return FALSE;
+
 	/* need to be in GDL */
 	if (!hal_device_store_find (hald_get_gdl (),
 				    hal_device_get_udi (d)))
@@ -445,8 +455,8 @@
 
 		if (fd == -1) {
 			/* open failed */
-			HAL_WARNING (("open(\"%s\", O_RDONLY) failed, "
-				      "errno=%d", device_file, errno));
+			/*HAL_WARNING (("open(\"%s\", O_RDONLY) failed, "
+			  "errno=%d", device_file, errno));*/
 
 			if (errno == ENOMEDIUM) {
 				force_unmount_of_all_childs (d);
@@ -472,35 +482,40 @@
 			return FALSE;
 		}
 
-		/* Check whether the 'eject' button is pressed - supposedly
-		 * only works on MMC-2 drivers and higher...
-		 *
-		 * From http://www.ussg.iu.edu/hypermail/linux/kernel/0202.0/att-0603/01-cd_poll.c
-		 */
+		/* respect policy */
+		if (hal_device_property_get_bool (
+			    d, "storage.cdrom.eject_check_enabled")) {
+
+			/* Check whether the 'eject' button is pressed..
+			 * Supposedly only works on MMC-2 drivers or higher.
+			 *
+			 * From http://www.ussg.iu.edu/hypermail/linux/kernel/0202.0/att-0603/01-cd_poll.c
+			 */
 		
-		memset (&cgc, 0, sizeof(struct cdrom_generic_command));
-		memset (buffer, 0, sizeof(buffer));		
-		cgc.cmd[0] = GPCMD_GET_EVENT_STATUS_NOTIFICATION;
-		cgc.cmd[1] = 1;
-		cgc.cmd[4] = 16;
-		cgc.cmd[8] = sizeof (buffer);
-		memset (&sense, 0, sizeof (sense));
-		cgc.timeout = 600;
-		cgc.buffer = buffer;
-		cgc.buflen = sizeof (buffer);
-		cgc.data_direction = CGC_DATA_READ;
-		cgc.sense = &sense;
-		cgc.quiet = 1;
-		ret = ioctl (fd, CDROM_SEND_PACKET, &cgc);
-		if (ret < 0) {
-			HAL_ERROR (("GPCMD_GET_EVENT_STATUS_NOTIFICATION failed, errno=%d", errno));
-		} else {
-			if ((buffer[4]&0x0f) == 0x01) {
-				HAL_INFO (("Eject pressed on udi=%s!", 
-					   hal_device_get_udi (d)));
-				/* handle later */
-				eject_pressed = TRUE;
-				
+			memset (&cgc, 0, sizeof(struct cdrom_generic_command));
+			memset (buffer, 0, sizeof(buffer));		
+			cgc.cmd[0] = GPCMD_GET_EVENT_STATUS_NOTIFICATION;
+			cgc.cmd[1] = 1;
+			cgc.cmd[4] = 16;
+			cgc.cmd[8] = sizeof (buffer);
+			memset (&sense, 0, sizeof (sense));
+			cgc.timeout = 600;
+			cgc.buffer = buffer;
+			cgc.buflen = sizeof (buffer);
+			cgc.data_direction = CGC_DATA_READ;
+			cgc.sense = &sense;
+			cgc.quiet = 1;
+			ret = ioctl (fd, CDROM_SEND_PACKET, &cgc);
+			if (ret < 0) {
+				HAL_ERROR (("GPCMD_GET_EVENT_STATUS_NOTIFICATION failed, errno=%d", errno));
+			} else {
+				if ((buffer[4]&0x0f) == 0x01) {
+					HAL_INFO (("Eject pressed on udi=%s!", 
+						   hal_device_get_udi (d)));
+					/* handle later */
+					eject_pressed = TRUE;
+					
+				}
 			}
 		}
 
@@ -894,6 +909,16 @@
 		hal_device_property_set_string (
 			stordev, "storage.bus", "unknown");
 
+		hal_device_property_set_bool (
+			stordev, 
+			"storage.media_check_enabled", 
+			(hald_get_conf ())->storage_media_check_enabled);
+
+		hal_device_property_set_bool (
+			stordev, 
+			"storage.automount_enabled", 
+			(hald_get_conf ())->storage_automount_enabled);
+
 		hal_device_property_set_string (stordev, 
 						"storage.model", "");
 		hal_device_property_set_string (stordev, 
@@ -967,6 +992,7 @@
 		hal_device_property_set_string (d, "volume.label", "");
 		hal_device_property_set_string (d, "volume.uuid", "");
 		hal_device_property_set_bool (d, "volume.is_disc", FALSE);
+		hal_device_property_set_bool (d, "volume.is_mounted", FALSE);
 
 		/* block device that is a partition; e.g. a storage volume */
 





More information about the hal-commit mailing list