[U-Boot] [PATCH v2] fs: fat: assign rootdir sector when accessing root directory

This fixes problems accessing drives formated under Windows as FAT16.
Changes v2: - unbreak fat32
Change-Id: Ideeca97525d3009b99de35b017707af11fda27c1 Signed-off-by: Thomas RIENOESSL thomas.rienoessl@bachmann.info --- fs/fat/fat.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/fs/fat/fat.c b/fs/fat/fat.c index 4b722fc5ca..7b7d43d997 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -720,7 +720,10 @@ static void *next_cluster(fat_itr *itr) if (itr->last_cluster) return NULL;
- sect = clust_to_sect(itr->fsdata, itr->clust); + if (itr->fsdata->fatsize != 32 && itr->is_root) + sect = mydata->rootdir_sect; + else + sect = clust_to_sect(itr->fsdata, itr->clust);
debug("FAT read(sect=%d), clust_size=%d, DIRENTSPERBLOCK=%zd\n", sect, itr->fsdata->clust_size, DIRENTSPERBLOCK);

On Tue, Nov 13, 2018 at 02:00:59PM +0100, Thomas RIENOESSL wrote:
This fixes problems accessing drives formated under Windows as FAT16.
Changes v2:
- unbreak fat32
Change-Id: Ideeca97525d3009b99de35b017707af11fda27c1 Signed-off-by: Thomas RIENOESSL thomas.rienoessl@bachmann.info
Applied to u-boot/master, thanks!

Hi Thomas
Can you explain what kind of problem this patch is fixing ? This patch is breaking FAT16 reading on stih410-b2260.
I am using a 4GB sdcard with 2 partitions: _ partition 1 FAT16 (100 MB) _ partition 2 ext4 (3.65GB)
Before this patch, fatls output was :
stih410-b2260 => fatls mmc 0:1 b2120/ b2260/ 3678 update_default_boot.sh 7909952 uImage_v4.14 7909888 zImage_v4.14 6475520 zImage_v4.4 52395 stih410-b2120.dtb .Trash-6169/ 18765 stm32429i-eval.dtb 1507 uenv.txt 14262 stm32746g-eval.dtb 16406 stm32f429-disco.dtb 16603 stm32f469-disco.dtb 14037 stm32f746-disco.dtb 13590 stm32f769-disco.dtb 8266 stm32h743i-disco.dtb 8477 stm32h743i-eval.dtb 53081 stih410-b2260_v4.14.dtb 8745536 uImage 44586 stih410-b2120_v4.4.dtb 6475584 uImage_v4.4 8745472 zImage 51774 stih410-b2260.dtb 6468 stm32mp157c-ed1.dtb 6496 stm32mp157c-ev1.dtb 416 extlinux.conf~ extlinux/
23 file(s), 4 dir(s)
After this patch :
stih410-b2260 => fatls mmc 0:1 b2120/ b2260/ 3678 update_default_boot.sh 7909952 uImage_v4.14 7909888 zImage_v4.14 6475520 zImage_v4.4 52395 stih410-b2120.dtb .Trash-6169/ 18765 stm32429i-eval.dtb 1507 uenv.txt 14262 stm32746g-eval.dtb 16406 stm32f429-disco.dtb 16603 stm32f469-disco.dtb 14037 stm32f746-disco.dtb 13590 stm32f769-disco.dtb 8266 stm32h743i-disco.dtb 8477 stm32h743i-eval.dtb 53081 stih410-b2260_v4.14.dtb 8745536 uImage 44586 stih410-b2120_v4.4.dtb 6475584 uImage_v4.4 8745472 zImage 51774 stih410-b2260.dtb 6468 stm32mp157c-ed1.dtb b2120/ b2260/ 3678 update_default_boot.sh 7909952 uImage_v4.14 7909888 zImage_v4.14 6475520 zImage_v4.4 52395 stih410-b2120.dtb .Trash-6169/ 18765 stm32429i-eval.dtb 1507 uenv.txt 14262 stm32746g-eval.dtb 16406 stm32f429-disco.dtb 16603 stm32f469-disco.dtb 14037 stm32f746-disco.dtb 13590 stm32f769-disco.dtb 8266 stm32h743i-disco.dtb 8477 stm32h743i-eval.dtb 53081 stih410-b2260_v4.14.dtb 8745536 uImage 44586 stih410-b2120_v4.4.dtb 6475584 uImage_v4.4 8745472 zImage 51774 stih410-b2260.dtb 6468 stm32mp157c-ed1.dtb b2120/ b2260/ 3678 update_default_boot.sh 7909952 uImage_v4.14 7909888 zImage_v4.14 6475520 zImage_v4.4 52395 stih410-b2120.dtb .Trash-6169/ 18765 stm32429i-eval.dtb 1507 uenv.txt 14262 stm32746g-eval.dtb 16406 stm32f429-disco.dtb 16603 stm32f469-disco.dtb 14037 stm32f746-disco.dtb 13590 stm32f769-disco.dtb 8266 stm32h743i-disco.dtb 8477 stm32h743i-eval.dtb 53081 stih410-b2260_v4.14.dtb 8745536 uImage 44586 stih410-b2120_v4.4.dtb 6475584 uImage_v4.4 8745472 zImage 51774 stih410-b2260.dtb 6468 stm32mp157c-ed1.dtb b2120/ b2260/ 3678 update_default_boot.sh 7909952 uImage_v4.14 7909888 zImage_v4.14 6475520 zImage_v4.4 52395 stih410-b2120.dtb .Trash-6169/ 18765 stm32429i-eval.dtb 1507 uenv.txt 14262 stm32746g-eval.dtb 16406 stm32f429-disco.dtb 16603 stm32f469-disco.dtb 14037 stm32f746-disco.dtb 13590 stm32f769-disco.dtb 8266 stm32h743i-disco.dtb 8477 stm32h743i-eval.dtb 53081 stih410-b2260_v4.14.dtb 8745536 uImage 44586 stih410-b2120_v4.4.dtb 6475584 uImage_v4.4 8745472 zImage 51774 stih410-b2260.dtb 6468 stm32mp157c-ed1.dtb b2120/ b2260/ 3678 update_default_boot.sh 7909952 uImage_v4.14 7909888 zImage_v4.14 6475520 zImage_v4.4 52395 stih410-b2120.dtb .Trash-6169/ 18765 stm32429i-eval.dtb 1507 uenv.txt 14262 stm32746g-eval.dtb 16406 stm32f429-disco.dtb 16603 stm32f469-disco.dtb 14037 stm32f746-disco.dtb 13590 stm32f769-disco.dtb 8266 stm32h743i-disco.dtb 8477 stm32h743i-eval.dtb 53081 stih410-b2260_v4.14.dtb 8745536 uImage 44586 stih410-b2120_v4.4.dtb 6475584 uImage_v4.4 8745472 zImage 51774 stih410-b2260.dtb 6468 stm32mp157c-ed1.dtb b2120/ b2260/ 3678 update_default_boot.sh 7909952 uImage_v4.14 7909888 zImage_v4.14 6475520 zImage_v4.4 52395 stih410-b2120.dtb .Trash-6169/ 18765 stm32429i-eval.dtb 1507 uenv.txt 14262 stm32746g-eval.dtb 16406 stm32f429-disco.dtb 16603 stm32f469-disco.dtb 14037 stm32f746-disco.dtb 13590 stm32f769-disco.dtb 8266 stm32h743i-disco.dtb 8477 stm32h743i-eval.dtb 53081 stih410-b2260_v4.14.dtb 8745536 uImage 44586 stih410-b2120_v4.4.dtb 6475584 uImage_v4.4 8745472 zImage 51774 stih410-b2260.dtb 6468 stm32mp157c-ed1.dtb b2120/ b2260/ 3678 update_default_boot.sh 7909952 uImage_v4.14 7909888 zImage_v4.14 6475520 zImage_v4.4 52395 stih410-b2120.dtb .Trash-6169/ 18765 stm32429i-eval.dtb 1507 uenv.txt 14262 stm32746g-eval.dtb 16406 stm32f429-disco.dtb 16603 stm32f469-disco.dtb 14037 stm32f746-disco.dtb 13590 stm32f769-disco.dtb 8266 stm32h743i-disco.dtb 8477 stm32h743i-eval.dtb 53081 stih410-b2260_v4.14.dtb 8745536 uImage 44586 stih410-b2120_v4.4.dtb 6475584 uImage_v4.4 8745472 zImage 51774 stih410-b2260.dtb 6468 stm32mp157c-ed1.dtb b2120/ b2260/ 3678 update_default_boot.sh 7909952 uImage_v4.14 7909888 zImage_v4.14 6475520 zImage_v4.4 52395 stih410-b2120.dtb .Trash-6169/ 18765 stm32429i-eval.dtb 1507 uenv.txt 14262 stm32746g-eval.dtb 16406 stm32f429-disco.dtb 16603 stm32f469-disco.dtb 14037 stm32f746-disco.dtb 13590 stm32f769-disco.dtb 8266 stm32h743i-disco.dtb 8477 stm32h743i-eval.dtb 53081 stih410-b2260_v4.14.dtb 8745536 uImage 44586 stih410-b2120_v4.4.dtb 6475584 uImage_v4.4 8745472 zImage 51774 stih410-b2260.dtb 6468 stm32mp157c-ed1.dtb
168 file(s), 24 dir(s)
Patrice
On 11/20/18 10:48 PM, Tom Rini wrote:
On Tue, Nov 13, 2018 at 02:00:59PM +0100, Thomas RIENOESSL wrote:
This fixes problems accessing drives formated under Windows as FAT16.
Changes v2:
- unbreak fat32
Change-Id: Ideeca97525d3009b99de35b017707af11fda27c1 Signed-off-by: Thomas RIENOESSL thomas.rienoessl@bachmann.info
Applied to u-boot/master, thanks!
U-Boot mailing list U-Boot@lists.denx.de https://lists.denx.de/listinfo/u-boot
participants (3)
-
Patrice CHOTARD
-
Thomas RIENOESSL
-
Tom Rini