hal/hald/linux block_class_device.c, 1.86, 1.86.2.1 common.h, 1.10, 1.10.2.1 platform_bus_device.c, 1.6, 1.6.2.1

David Zeuthen david at freedesktop.org
Mon Nov 22 13:53:52 PST 2004


Update of /cvs/hal/hal/hald/linux
In directory gabe:/tmp/cvs-serv19436/hald/linux

Modified Files:
      Tag: hal-0_4-stable-branch
	block_class_device.c common.h platform_bus_device.c 
Log Message:
2004-11-22  David Zeuthen  <david at fubar.dk>

	* hald/linux/volume_id/volume_id.c (volume_id_probe): Add some
	logging of what size we call volume_id_probe with

	* hald/linux/block_class_device.c (force_unmount): Only attempt to
	'umount -l' if some hal policy piece are performing policy on the
	device

2004-11-22  David Zeuthen  <davidz at redhat.com>

	* libhal-storage/libhal-storage.c (hal_drive_from_udi): Detect Zip
	and Jaz drives
	(hal_drive_policy_compute_display_name): Fix an ugly bug where
	CD-ROM drives were being named "CD-R" instead of "CD-ROM"

	* libhal-storage/libhal-storage.h: Add enums for Zip and Jaz drives

	* hald/linux/platform_bus_device.c (platform_device_in_gdl): New
	function. Actually check the /etc/mtab for whether the floppy is
	mounted

	* hald/linux/common.h: Add prototype for 
	etc_mtab_process_all_block_devices

	* hald/linux/block_class_device.c (block_class_visit): Never add
	child real childs (e.g. /dev/hdd4) if storage.no_partitions_hint is
	set (for IDE Zip Drives)
	(detect_media): Actually set child to what we find in the TDL
	(mtab_handle_storage): Match on device file before attempting to
	match on major/minor
	(mtab_handle_volume): -do-

	* hald/device_info.c (handle_match): Add the contains and 
	contains_ncase matching operators.

	* fdi/90defaultpolicy/storage-policy.fdi: Add some policy pieces for
	IDE Zip, Jaz and USB Zip drives

	* fdi/20freedesktop/usb-zip-drives.fdi: New file to identify USB
	Zip Drives

	* fdi/20freedesktop/ide-drives.fdi: New file to identify strange IDE
	drives such as Zip and Jaz drives; note that rewriting the device
	file from e.g. /dev/hdd to /dev/hdd4  is actually sane enough to
	do given the abstraction that hal exports :-)

2004-11-16  David Zeuthen  <davidz at redhat.com>

	* fdi/90defaultpolicy/storage-policy.fdi: Remove the "ro" option for
	optical drives as it prevents mounting rw DVD-RAM media (RH bug #139600)

	* hald/linux/volume_id/volume_id.h (VOLUME_ID_PARTITIONS_MAX): Increase
	to 256 (RH bug #139227)

	* hald/linux/volume_id/volume_id.c (probe_msdos_part_table): Fix a
	typo ("to many partitions" -> "too many partitions"
	(volume_id_probe): Do not probe for msdos_part_table since that doesn't
	make sense (../block_class_device.c does that instead)



Index: block_class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/block_class_device.c,v
retrieving revision 1.86
retrieving revision 1.86.2.1
diff -u -d -r1.86 -r1.86.2.1
--- block_class_device.c	19 Oct 2004 22:58:03 -0000	1.86
+++ block_class_device.c	22 Nov 2004 21:53:50 -0000	1.86.2.1
@@ -71,8 +71,6 @@
  * @{
  */
 
-static void etc_mtab_process_all_block_devices (dbus_bool_t force);
-
 static char *block_class_compute_udi (HalDevice * d, int append_num);
 
 #if 0
@@ -265,6 +263,15 @@
 		goto out;
 	}
 
+	/* Never add e.g. /dev/hdd4 as child of /dev/hdd if /dev/hdd is without partitions (e.g. zip disks) */
+	if (hal_device_has_property (parent, "storage.no_partitions_hint")) {
+		if (hal_device_property_get_bool (parent, "storage.no_partitions_hint")) {
+			hal_device_store_remove (hald_get_tdl (), d);
+			d = NULL;
+			goto out;			
+		}
+	}
+
 	class_device_got_parent_device (hald_get_tdl (), parent, cad);
 
 out:
@@ -376,6 +383,8 @@
 static void
 force_unmount (HalDevice * d)
 {
+	const char *storudi;
+	HalDevice *stordev;
 	const char *device_file;
 	const char *device_mount_point;
 	const char *umount_argv[4] = { "/bin/umount", "-l", NULL, NULL };
@@ -384,8 +393,19 @@
 	int umount_exitcode;
 
 	device_file = hal_device_property_get_string (d, "block.device");
-	device_mount_point =
-	    hal_device_property_get_string (d, "volume.mount_point");
+	device_mount_point = hal_device_property_get_string (d, "volume.mount_point");
+
+	/* Only attempt to 'umount -l' if some hal policy piece are performing policy on the device */
+	storudi = hal_device_property_get_string (d, "block.storage_device");
+	if (storudi == NULL)
+		return;
+	stordev = hal_device_store_find (hald_get_gdl (), storudi);
+	if (stordev == NULL)
+		return;
+	HAL_INFO (("foo = %d", hal_device_property_get_bool (stordev, "storage.policy.should_mount")));
+	if ((!hal_device_has_property (stordev, "storage.policy.should_mount")) ||
+	    (!hal_device_property_get_bool (stordev, "storage.policy.should_mount")))
+		return;
 
 	umount_argv[2] = device_file;
 
@@ -948,7 +968,7 @@
 
 	child = get_child_device_gdl (d);
 	if (child == NULL) {
-		get_child_device_tdl (d);
+		child = get_child_device_tdl (d);
 	}
 	if (child != NULL) {
 		return FALSE;
@@ -2020,6 +2040,7 @@
 static gboolean
 mtab_handle_storage (HalDevice *d)
 {
+	const char *device_file;
 	HalDevice *child;
 	int major, minor;
 	dbus_bool_t found_mount_point;
@@ -2037,11 +2058,15 @@
 
 	major = hal_device_property_get_int (d, "block.major");
 	minor = hal_device_property_get_int (d, "block.minor");
+	device_file = hal_device_property_get_string (d, "block.device");
+
 
 	/* See if we already got children */
 	child = get_child_device_gdl (d);
-	if (child == NULL)
-		get_child_device_tdl (d);
+
+	if (child == NULL) {
+		child = get_child_device_tdl (d);
+	}
 
 	/* Search all mount points */
 	found_mount_point = FALSE;
@@ -2049,8 +2074,13 @@
 
 		mp = &mount_points[i];
 
-		if (mp->major != major || mp->minor != minor)
-			continue;
+		if (strcmp (device_file, mp->device) == 0) {
+			/* looks good */
+		} else {
+			/* device file don't match; try matching up major/minor numbers */
+			if (mp->major != major || mp->minor != minor)
+				continue;
+		}
 
 		if (child != NULL ) {
 			found_mount_point = TRUE;
@@ -2073,6 +2103,7 @@
 static gboolean
 mtab_handle_volume (HalDevice *d)
 {
+	const char *device_file;
 	int major, minor;
 	dbus_bool_t found_mount_point;
 	struct mount_point_s *mp;
@@ -2082,6 +2113,7 @@
 
 	major = hal_device_property_get_int (d, "block.major");
 	minor = hal_device_property_get_int (d, "block.minor");
+	device_file = hal_device_property_get_string (d, "block.device");
 
 	/* these are handled in mtab_handle_storage */
 	storudi = hal_device_property_get_string (d, "block.storage_device");
@@ -2095,36 +2127,27 @@
 	found_mount_point = FALSE;
 	for (i = 0; i < num_mount_points; i++) {
 		mp = &mount_points[i];
-			
-		if (mp->major == major && mp->minor == minor) {
+
+	
+		/* match on both device file and major/minor numbers */
+		if ((strcmp (device_file, mp->device) == 0) || (mp->major == major && mp->minor == minor)) {
 			const char *existing_block_device;
 			dbus_bool_t was_mounted;
 
 			device_property_atomic_update_begin ();
 
-			existing_block_device =
-				hal_device_property_get_string (d,
-								"block.device");
+			existing_block_device = hal_device_property_get_string (d, "block.device");
 
-			was_mounted =
-				hal_device_property_get_bool (d,
-							      "volume.is_mounted");
+			was_mounted = hal_device_property_get_bool (d, "volume.is_mounted");
 
 			/* Yay! Found a mount point; set properties accordingly */
-			hal_device_property_set_string (d,
-							"volume.mount_point",
-							mp->mount_point);
-			hal_device_property_set_string (d, "volume.fstype",
-							mp->fs_type);
-			hal_device_property_set_bool (d,
-						      "volume.is_mounted",
-						      TRUE);
+			hal_device_property_set_string (d, "volume.mount_point", mp->mount_point);
+			hal_device_property_set_string (d, "volume.fstype", mp->fs_type);
+			hal_device_property_set_bool (d, "volume.is_mounted", TRUE);
 
 			/* only overwrite block.device if it's not set */
-			if (existing_block_device == NULL ||
-			    (existing_block_device != NULL &&
-			     strcmp (existing_block_device,
-				     "") == 0)) {
+			if (existing_block_device == NULL || (existing_block_device != NULL &&
+			     strcmp (existing_block_device, "") == 0)) {
 				hal_device_property_set_string (d,
 								"block.device",
 								mp->
@@ -2239,7 +2262,7 @@
  *
  *  @param  force               Force reading of mtab
  */
-static void
+void
 etc_mtab_process_all_block_devices (dbus_bool_t force)
 {
 	/* Start or continue watching /etc */

Index: common.h
===================================================================
RCS file: /cvs/hal/hal/hald/linux/common.h,v
retrieving revision 1.10
retrieving revision 1.10.2.1
diff -u -d -r1.10 -r1.10.2.1
--- common.h	1 Sep 2004 17:38:58 -0000	1.10
+++ common.h	22 Nov 2004 21:53:50 -0000	1.10.2.1
@@ -93,6 +93,8 @@
 
 dbus_bool_t got_parent (const char *sysfs_path);
 
+void etc_mtab_process_all_block_devices (dbus_bool_t force);
+
 extern char sysfs_mount_path[SYSFS_PATH_MAX];
 
 

Index: platform_bus_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/platform_bus_device.c,v
retrieving revision 1.6
retrieving revision 1.6.2.1
diff -u -d -r1.6 -r1.6.2.1
--- platform_bus_device.c	8 Oct 2004 22:07:27 -0000	1.6
+++ platform_bus_device.c	22 Nov 2004 21:53:50 -0000	1.6.2.1
@@ -204,6 +204,17 @@
 					"storage");
 }
 
+static void 
+platform_device_in_gdl (BusDeviceHandler *self,
+		   	HalDevice *d,
+		   	const char *udi)
+{
+	if (hal_device_has_capability (d, "storage")) {
+		/* Check the mtab to see if the device is mounted */
+		etc_mtab_process_all_block_devices (TRUE);
+	}
+}
+
 
 /** Method specialisations for bustype pci */
 BusDeviceHandler platform_bus_handler = {
@@ -216,7 +227,7 @@
 	platform_device_compute_udi,  /**< UDI computing function */
 	platform_device_pre_process,  /**< add more properties */
 	platform_device_got_udi,      /**< got UDI */
-	bus_device_in_gdl,            /**< in GDL */
+	platform_device_in_gdl,       /**< in GDL */
 	"platform",                   /**< sysfs bus name */
 	"platform"                    /**< namespace */
 };




More information about the hal-commit mailing list