hal 0.4.5 "It's going to go 100% failure in 72 hours." releas ed

Schupp Roderich (extern) Com MD PD SWP 2 CM MCH Roderich.Schupp.extern at mch.siemens.de
Mon Jan 17 05:52:16 PST 2005


>   I just upgraded hal (from 0.4.4-1) and noticed, that it 
> doesn't detect
>   the volume label of my usb external drive correctly anymore. I found
>   this bug, and this change seems to be the cause...
> 
>   Both mlabel and udev_volume_id show the correct label 
> ("ICYBOX"), but
>   hal uses "AD", which is pretty useless...

The problem are VFAT extended entries in the root directory.
The one-line change from 0.4.4 will erroneously take the
first extended entry for the volume id.
These extented entries are recognizable by attr = 0x0f
(i.e. readonly + system + hidden + volume_id).

I think there's also an off-by-one error in iterating over
the directory entries. 

Patch (against 0.4.5) for both follows.

Cheers, Roderich

--- hal/hald/linux/volume_id/volume_id.c~	2005-01-15 18:42:48.000000000 +0100
+++ hal/hald/linux/volume_id/volume_id.c	2005-01-15 18:41:54.000000000 +0100
@@ -774,6 +774,7 @@
 #define FAT16_MAX			0xfff5
 #define FAT_ATTR_VOLUME_ID		0x08
 #define FAT_ATTR_DIR			0x10
+#define FAT_ATTR_EXT			0x0f
 #define FAT_ENTRY_FREE			0xe5
 static int probe_vfat(struct volume_id *id, __u64 off)
 {
@@ -956,7 +957,7 @@
 
 	dir = (struct vfat_dir_entry*) buf;
 
-	for (i = 0; i <= root_dir_entries; i++) {
+	for (i = 0; i < root_dir_entries; i++) {
 		/* end marker */
 		if (dir[i].name[0] == 0x00) {
 			dbg("end of dir");
@@ -967,6 +968,10 @@
 		if (dir[i].name[0] == FAT_ENTRY_FREE)
 			continue;
 
+		/* VFAT extended entry */
+		if (dir[i].attr == FAT_ATTR_EXT)
+			continue;
+
 		if ((dir[i].attr & (FAT_ATTR_VOLUME_ID | FAT_ATTR_DIR)) == FAT_ATTR_VOLUME_ID) {
 			dbg("found ATTR_VOLUME_ID id in root dir");
 			label = dir[i].name;
@@ -1015,7 +1020,7 @@
 		count = buf_size / sizeof(struct vfat_dir_entry);
 		dbg("expected entries 0x%x", count);
 
-		for (i = 0; i <= count; i++) {
+		for (i = 0; i < count; i++) {
 			/* end marker */
 			if (dir[i].name[0] == 0x00) {
 				dbg("end of dir");
@@ -1026,6 +1031,10 @@
 			if (dir[i].name[0] == FAT_ENTRY_FREE)
 				continue;
 
+			/* VFAT extended entry */
+			if (dir[i].attr == FAT_ATTR_EXT)
+				continue;
+
 			if ((dir[i].attr & (FAT_ATTR_VOLUME_ID | FAT_ATTR_DIR)) == FAT_ATTR_VOLUME_ID) {
 				dbg("found ATTR_VOLUME_ID id in root dir");
 				label = dir[i].name;
_______________________________________________
hal mailing list
hal at lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/hal



More information about the Hal mailing list