fs: exfat: Rework exfat_fs_readdir() to behave like exfat_fs_ls()
authorMarek Vasut <marex@denx.de>
Sun, 13 Apr 2025 08:55:01 +0000 (10:55 +0200)
committerTom Rini <trini@konsulko.com>
Mon, 21 Apr 2025 17:07:04 +0000 (11:07 -0600)
commit01a8121b7daa68767fe88fa92d436b95a1662bed
tree034e114a3bd148a8477ac9db75cd44fd37287ebe
parent21b04b3d72cfea587a8b616410371a191768c5e7
fs: exfat: Rework exfat_fs_readdir() to behave like exfat_fs_ls()

The exfat_fs_readdir() depends on state created in exfat_fs_opendir(),
but that state may be disrupted by fs_close() called by the FS layer
in fs_opendir(), because exfat porting layer unmounts the filesystem
in ->close() callback.

To avoid this disruption, avoid creating state in exfat_fs_opendir(),
cache only the directory name to list there, and rework exfat_fs_readdir()
to work in a similar way to exfat_fs_ls(). That is, make exfat_fs_readdir()
open the directory, look up specific entry, extract its properties to be
reported to FS layer, and close the directory. This is slow, but avoids
the disruption. The slowness does not affect regular 'ls' command, which
uses exfat_fs_ls() fast path.

Fixes: b86a651b646c ("fs: exfat: Add U-Boot porting layer")
Signed-off-by: Marek Vasut <marex@denx.de>
fs/exfat/io.c