At r1985, "sudo ./grub-probe -t fs -d /dev/fd0" outputs "fat" with a
freshly-formatted VFAT floppy in the drive. At r1986, it spits "error:
unknown filesystem". The cause is this error, repeated three times:

if (! grub_strncmp(something, "FAT12", 5))
  goto fail;

Strncmp does not return a boolean result (i.e. matches or doesn't), but
an _integer_ that is supposed to establish a comparison order between
strings. Thus, a return value of 0 is actually a match. See why I insist
on treating semantic-ints different than semantic-bools even though the
language does not? The correction is obvious (a patch is attached):

if (0 != grub_strncmp(something, "FAT12",5))
  goto fail;

And I remark the 0 != instead of a simple if (strncmp()) test. BTW, I
think the "FATx" constants should be made into macros or SLT... Magic
constants creep me out.


-- Lazy Oblivious, Rational Disaster -- Habbit
Index: fs/fat.c
===================================================================
--- fs/fat.c	(revision 1987)
+++ fs/fat.c	(working copy)
@@ -187,9 +187,9 @@
   if (grub_disk_read (disk, 0, 0, sizeof (bpb), (char *) &bpb))
     goto fail;
 
-  if (! grub_strncmp((const char *) bpb.version_specific.fat12_or_fat16.fstype, "FAT12",5)
-      || ! grub_strncmp((const char *) bpb.version_specific.fat12_or_fat16.fstype, "FAT16",5)
-      || ! grub_strncmp((const char *) bpb.version_specific.fat32.fstype, "FAT32",5))
+  if (0 != grub_strncmp((const char *) bpb.version_specific.fat12_or_fat16.fstype, "FAT12", 5)
+      && 0 != grub_strncmp((const char *) bpb.version_specific.fat12_or_fat16.fstype, "FAT16", 5)
+      && 0 != grub_strncmp((const char *) bpb.version_specific.fat32.fstype, "FAT32", 5))
     goto fail;
   
   /* Get the sizes of logical sectors and clusters.  */

Attachment: signature.asc
Description: Esta parte del mensaje está firmada digitalmente

_______________________________________________
Grub-devel mailing list
Grub-devel@gnu.org
http://lists.gnu.org/mailman/listinfo/grub-devel

Reply via email to