[U-Boot] [PATCH 4/7] FAT: Fix file contents listed as directory

With: fatls mmc 0 /dir/file dir: regular directory file: regular file
The previous code read the contents of file as if it were directory entries to list. This patch refuses to list file contents as if it were a folder.
Signed-off-by: Benoît Thébaudeau benoit.thebaudeau@advansee.com Cc: Wolfgang Denk wd@denx.de --- .../fs/fat/fat.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git u-boot-66714b1.orig/fs/fat/fat.c u-boot-66714b1/fs/fat/fat.c index fcce412..943cdb6 100644 --- u-boot-66714b1.orig/fs/fat/fat.c +++ u-boot-66714b1/fs/fat/fat.c @@ -1105,11 +1105,11 @@ rootdir_done: goto exit; }
- if (idx >= 0) { - if (!(dentptr->attr & ATTR_DIR)) - goto exit; + if (isdir && !(dentptr->attr & ATTR_DIR)) + goto exit; + + if (idx >= 0) subname = nextname; - } }
ret = get_contents(mydata, dentptr, buffer, maxsize);

With: fatls mmc 0 /dir/file dir: regular directory file: regular file
The previous code read the contents of file as if it were directory entries to list. This patch refuses to list file contents as if it were a folder.
Signed-off-by: Benoît Thébaudeau benoit.thebaudeau@advansee.com Cc: Wolfgang Denk wd@denx.de --- Changes for v2: - Patch renumbering because of the new v2 1/8. - Possible code style changes due to the new v2 1/8.
.../fs/fat/fat.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
diff --git u-boot-66714b1.orig/fs/fat/fat.c u-boot-66714b1/fs/fat/fat.c index fbc2d7d..5d08948 100644 --- u-boot-66714b1.orig/fs/fat/fat.c +++ u-boot-66714b1/fs/fat/fat.c @@ -1103,11 +1103,11 @@ rootdir_done: goto exit; }
- if (idx >= 0) { - if (!(dentptr->attr & ATTR_DIR)) - goto exit; + if (isdir && !(dentptr->attr & ATTR_DIR)) + goto exit; + + if (idx >= 0) subname = nextname; - } }
ret = get_contents(mydata, dentptr, buffer, maxsize);

Dear Benoît Thébaudeau,
In message 2017658963.332562.1342790429735.JavaMail.root@advansee.com you wrote:
With: fatls mmc 0 /dir/file dir: regular directory file: regular file
The previous code read the contents of file as if it were directory entries to list. This patch refuses to list file contents as if it were a folder.
But this means that "fatls" on a plain file stops working?
This doesn't make sense to me. Or what am I missing?
Patch skipped for now.
Best regards,
Wolfgang Denk

Dear Wolfgang Denk,
On Sunday, September 2, 2012 5:21:15 PM, Wolfgang Denk wrote:
Dear Benoît Thébaudeau,
In message 2017658963.332562.1342790429735.JavaMail.root@advansee.com you wrote:
With: fatls mmc 0 /dir/file dir: regular directory file: regular file
The previous code read the contents of file as if it were directory entries to list. This patch refuses to list file contents as if it were a folder.
But this means that "fatls" on a plain file stops working?
This doesn't make sense to me. Or what am I missing?
This already did not work before, because "fatls" is supposed to support only directories:
$ help fatls fatls - list files in a directory (default /)
Usage: fatls <interface> <dev[:part]> [directory] - list files from 'dev' on 'interface' in a 'directory'
Best regards, Benoît

On Mon, Sep 03, 2012 at 04:08:02PM +0200, Beno??t Th??baudeau wrote:
Dear Wolfgang Denk,
On Sunday, September 2, 2012 5:21:15 PM, Wolfgang Denk wrote:
Dear Beno??t Th??baudeau,
In message 2017658963.332562.1342790429735.JavaMail.root@advansee.com you wrote:
With: fatls mmc 0 /dir/file dir: regular directory file: regular file
The previous code read the contents of file as if it were directory entries to list. This patch refuses to list file contents as if it were a folder.
But this means that "fatls" on a plain file stops working?
This doesn't make sense to me. Or what am I missing?
This already did not work before, because "fatls" is supposed to support only directories:
$ help fatls fatls - list files in a directory (default /)
Usage: fatls <interface> <dev[:part]> [directory] - list files from 'dev' on 'interface' in a 'directory'
Note that ext2ls _also_ fails to ls files so we're being consistent as I believe Wolfgang was expecting that *ls of a file would work like real ls does, but that's not the case. Applied to u-boot/master, thanks!
participants (3)
-
Benoît Thébaudeau
-
Tom Rini
-
Wolfgang Denk