Skip to contentSkip to conversation

fs: fat: assign rootdir sector when accessing root directory

PATCH New Thomas RIENOESSL 3 participants 3 messages Nov 13, 2018 – Dec 20, 2018 VFAT/FAT/msdos filesystem

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 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
---
 fs/fat/fat.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
fs/fat/fat.c +4 -1
index 4b722fc5ca..7b7d43d997 100644
@@ -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);
Signature · 1 line
2.19.1
#1 lore raw

PATCH v2 1/1 fs: fat: assign rootdir sector when accessing root directory

Quoted 8 lines · Thomas RIENOESSL

This fixes problems accessing drives formated under Windows as FAT16.

Changes v2:
- unbreak fat32

Change-Id Ideeca97525d3009b99de35b017707af11fda27c1

Applied to u-boot/master, thanks!

Signature · 8 lines
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/20181120/5bcf0f0d/attachment.sig>
#2 lore raw

PATCH v2 1/1 fs: fat: assign rootdir sector when accessing root directory

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

Quoted 19 lines · Tom Rini
Quoted 8 lines · Thomas RIENOESSL

This fixes problems accessing drives formated under Windows as FAT16.

Changes v2:
- unbreak fat32

Change-Id Ideeca97525d3009b99de35b017707af11fda27c1

Applied to u-boot/master, thanks!

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
https://lists.denx.de/listinfo/u-boot