[U-Boot] [U-Boot, v2] fs: fat: fix reading non-cluster-aligned root directory

Tom Rini trini at konsulko.com
Wed Apr 10 12:20:19 UTC 2019


On Wed, Feb 27, 2019 at 12:55:57PM +0200, Anssi Hannula wrote:

> A FAT12/FAT16 root directory location is specified by a sector offset and
> it might not start at a cluster boundary. It also resides before the
> data area (before cluster 2).
> 
> However, the current code assumes that the root directory is located at
> a beginning of a cluster, causing no files to be found if that is not
> the case.
> 
> Since the FAT12/FAT16 root directory is located before the data area
> and is not aligned to clusters, using unsigned cluster numbers to refer
> to the root directory does not work well (the "cluster number" may be
> negative, and even allowing it be signed would not make it properly
> aligned).
> 
> Modify the code to not use the normal cluster numbering when referring to
> the root directory of FAT12/FAT16 and instead use a cluster-sized
> offsets counted from the root directory start sector.
> 
> This is a relatively common case as at least the filesystem formatter on
> Win7 seems to create such filesystems by default on 2GB USB sticks when
> "FAT" is selected (cluster size 64 sectors, rootdir size 32 sectors,
> rootdir starts at half a cluster before cluster 2).
> 
> dosfstools mkfs.vfat does not seem to create affected filesystems.
> 
> Signed-off-by: Anssi Hannula <anssi.hannula at bitwise.fi>
> Reviewed-by: Bernhard Messerklinger <bernhard.messerklinger at br-automation.com>
> Tested-by: Bernhard Messerklinger <bernhard.messerklinger at br-automation.com>

Applied to u-boot/master, thanks!

-- 
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20190410/5d90ca25/attachment.sig>


More information about the U-Boot mailing list