Hello,

Busybox detects a FAT file system with 65524 clusters as FAT32 while
it should handle it as FAT16. Because of that blkid cannot detect the
uuid or label on a FAT with 65524 clusters.

The attached patch fixes that mistake.

The cluster count values are defined in:
Microsoft Extensible Firmware Initiative
FAT32 File System Specification
FAT: General Overview of On-Disk Format

I used version 1.03 from December 6,2000

The cluster count values are defined in pages 14 and 15 of that specification.

Most users will probably not encounter that bug because the
specification also states that file system creation code should stay
away at least 16 clusters from that cluster count to avoid bugs in
incorrect FAT code.

Kind regards,
Thomas
From 0dd1cb839a8e748c03cf6c9cb118d31481564abc Mon Sep 17 00:00:00 2001
From: Thomas Frauendorfer <[email protected]>
Date: Tue, 5 Mar 2019 17:04:34 +0100
Subject: [PATCH] Fix off by one error in FAT16 <=> FAT32 detection

cluster_count is compared against FAT16_MAX, which is defined as 0xfff4
That is the maximum number of cluster a FAT16 can have.

For reference also check the  hardware whitepaper from Microsoft
FAT: General Overview of On-Disk Format, version 1.03 page 15

Signed-off-by: Thomas Frauendorfer <[email protected]>
---
 util-linux/volume_id/fat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/util-linux/volume_id/fat.c b/util-linux/volume_id/fat.c
index 476d500..f4d666f 100644
--- a/util-linux/volume_id/fat.c
+++ b/util-linux/volume_id/fat.c
@@ -252,7 +252,7 @@ int FAST_FUNC volume_id_probe_vfat(struct volume_id *id /*,uint64_t fat_partitio
 //		strcpy(id->type_version, "FAT32");
 //		goto fat32;
 //	}
-	if (cluster_count >= FAT16_MAX)
+	if (cluster_count > FAT16_MAX)
 		goto fat32;
 
 	/* the label may be an attribute in the root directory */
-- 
1.9.1

_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox

Reply via email to