@@ -1299,6 +1299,19 @@ int fat_read_file(const char *filename, void *buf, loff_t offset, loff_t len,
return ret;
}
+int fat_get_blocksize(const char *filename)
+{
+ fsdata fsdata = {0};
+ int ret;
+
+ ret = get_fs_info(&fsdata);
+ if (ret)
+ return ret;
+
+ free(fsdata.fatbuf);
+ return fsdata.sect_size;
+}
+
typedef struct {
struct fs_dir_stream parent;
struct fs_dirent dirent;
@@ -208,7 +208,7 @@ static struct fstype_info fstypes[] = {
.exists = fat_exists,
.size = fat_size,
.read = fat_read_file,
- .get_blocksize = fs_get_blocksize_unsupported,
+ .get_blocksize = fat_get_blocksize,
#if CONFIG_IS_ENABLED(FAT_WRITE)
.write = file_fat_write,
.unlink = fat_unlink,
@@ -201,6 +201,7 @@ int file_fat_detectfs(void);
int fat_exists(const char *filename);
int fat_size(const char *filename, loff_t *size);
int file_fat_read(const char *filename, void *buffer, int maxsize);
+int fat_get_blocksize(const char *filename);
int fat_set_blk_dev(struct blk_desc *rbdd, struct disk_partition *info);
int fat_register_device(struct blk_desc *dev_desc, int part_no);
Just implement fat_get_blocksize() for fat, so that fat_read_file() always get a block aligned read range. Unfortunately I'm not experienced enough to cleanup the fat code, thus further cleanup is appreciated. Cc: Tom Rini <trini@konsulko.com> Signed-off-by: Qu Wenruo <wqu@suse.com> --- fs/fat/fat.c | 13 +++++++++++++ fs/fs.c | 2 +- include/fat.h | 1 + 3 files changed, 15 insertions(+), 1 deletion(-)