fs/fat: introduce new director iterators

Untangle directory traversal into a simple iterator, to replace the
existing multi-purpose do_fat_read_at() + get_dentfromdir().

Signed-off-by: Rob Clark <robdclark@gmail.com>
Reviewed-by: Łukasz Majewski <lukma@denx.de>
This commit is contained in:
Rob Clark 2017-09-09 13:15:53 -04:00 committed by Tom Rini
parent 45449980f8
commit c6e3baa565
2 changed files with 360 additions and 3 deletions

View file

@ -175,8 +175,15 @@ typedef struct {
int data_begin; /* The sector of the first cluster, can be negative */
int fatbufnum; /* Used by get_fatent, init to -1 */
int rootdir_size; /* Size of root dir for non-FAT32 */
__u32 root_cluster; /* First cluster of root dir for FAT32 */
} fsdata;
/* TODO clean up places that are open-coding this: */
static inline u32 clust_to_sect(fsdata *fsdata, u32 clust)
{
return fsdata->data_begin + clust * fsdata->clust_size;
}
typedef int (file_detectfs_func)(void);
typedef int (file_ls_func)(const char *dir);
typedef int (file_read_func)(const char *filename, void *buffer,