From mboxrd@z Thu Jan 1 00:00:00 1970 From: Tom Rini Date: Wed, 10 Apr 2019 08:20:19 -0400 Subject: [U-Boot] [U-Boot, v2] fs: fat: fix reading non-cluster-aligned root directory In-Reply-To: <20190227105557.20908-1-anssi.hannula@bitwise.fi> References: <20190227105557.20908-1-anssi.hannula@bitwise.fi> Message-ID: <20190410122019.GL4664@bill-the-cat> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de 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 > Reviewed-by: Bernhard Messerklinger > Tested-by: Bernhard Messerklinger 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: