hal/hald/linux block_class_device.c,1.73,1.74

David Zeuthen david at freedesktop.org
Mon Sep 20 02:00:17 PDT 2004


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

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

	* doc/spec/hal-spec.xml.in: Add docs for volume.size

	* hald/linux/block_class_device.c (volume_set_size): Use the 
	BLKSIZEGET64 ioctl to get the size in bytes and populate volume.size
	(block_class_pre_process): Use volume.size when doing volume_id



Index: block_class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/block_class_device.c,v
retrieving revision 1.73
retrieving revision 1.74
diff -u -d -r1.73 -r1.74
--- block_class_device.c	20 Sep 2004 07:52:42 -0000	1.73
+++ block_class_device.c	20 Sep 2004 09:00:14 -0000	1.74
@@ -560,6 +560,7 @@
 	int fd;
 	int num_blocks;
 	int block_size;
+	dbus_uint64_t vol_size;
 	const char *sysfs_path;
 	const char *storudi;
 	const char *device_file;
@@ -588,6 +589,7 @@
 			num_blocks = atoi (attr->value);
 
 			hal_device_property_set_int (d, "volume.num_blocks", num_blocks);
+			HAL_INFO (("volume.num_blocks = %d", num_blocks));
 			sysfs_close_attribute (attr);
 		}
 
@@ -595,7 +597,14 @@
 		if (fd >= 0) {
 			if (ioctl (fd, BLKSSZGET, &block_size) == 0) {
 				hal_device_property_set_int (d, "volume.block_size", block_size);
+				HAL_INFO (("volume.block_size = %d", block_size));
+			}
+
+			if (ioctl (fd, BLKGETSIZE64, &vol_size) == 0) {
+				hal_device_property_set_uint64 (d, "volume.size", vol_size);
+				HAL_INFO (("volume.size = %lld", vol_size));
 			}
+
 			close (fd);
 		}
 	}
@@ -1239,18 +1248,11 @@
 		 * or any of it partitions are not mounted causes the loop.
 		 */
 		if (hal_device_property_get_bool (stordev, "storage.media_check_enabled")) {
-			unsigned long long size = 0;
-			int bcount;
-			int bsize;
+			dbus_uint64_t size = 0;
 			const char *stordev_device_file;
 
 			volume_set_size (d, FALSE);
-
-			bcount = hal_device_property_get_int (d, "volume.num_blocks");
-			bsize = hal_device_property_get_int (d, "volume.block_size");
-
-			if ((bsize > 0)  && (bcount > 0))
-				size = bcount * bsize;
+			size = hal_device_property_get_uint64 (d, "volume.size");
 
 			vid = volume_id_open_node(device_file);
 			if (vid != NULL) {




More information about the hal-commit mailing list