From: Qu Wenruo <wqu@suse.com> To: u-boot@lists.denx.de Cc: marek.behun@nic.cz, linux-btrfs@vger.kernel.org, jnhuang95@gmail.com, linux-erofs@lists.ozlabs.org, trini@konsulko.com, joaomarcos.costa@bootlin.com, thomas.petazzoni@bootlin.com, miquel.raynal@bootlin.com Subject: [PATCH 6/8] fs: fat: rely on higher layer to get block aligned read range Date: Wed, 29 Jun 2022 19:38:27 +0800 [thread overview] Message-ID: <0a30a7118f69bd0636bc2350d53890b99b8c191d.1656502685.git.wqu@suse.com> (raw) In-Reply-To: <cover.1656502685.git.wqu@suse.com> 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(-) diff --git a/fs/fat/fat.c b/fs/fat/fat.c index dcceccbcee0a..e13035e8e6d1 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -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; diff --git a/fs/fs.c b/fs/fs.c index 3cd2c88a4895..09625f52e913 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -207,7 +207,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, diff --git a/include/fat.h b/include/fat.h index a9756fb4cd1b..c03a2bebecef 100644 --- a/include/fat.h +++ b/include/fat.h @@ -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); -- 2.36.1
WARNING: multiple messages have this Message-ID (diff)
From: Qu Wenruo via Linux-erofs <linux-erofs@lists.ozlabs.org> To: u-boot@lists.denx.de Cc: trini@konsulko.com, jnhuang95@gmail.com, joaomarcos.costa@bootlin.com, marek.behun@nic.cz, thomas.petazzoni@bootlin.com, miquel.raynal@bootlin.com, linux-erofs@lists.ozlabs.org, linux-btrfs@vger.kernel.org Subject: [PATCH 6/8] fs: fat: rely on higher layer to get block aligned read range Date: Wed, 29 Jun 2022 19:38:27 +0800 [thread overview] Message-ID: <0a30a7118f69bd0636bc2350d53890b99b8c191d.1656502685.git.wqu@suse.com> (raw) In-Reply-To: <cover.1656502685.git.wqu@suse.com> 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(-) diff --git a/fs/fat/fat.c b/fs/fat/fat.c index dcceccbcee0a..e13035e8e6d1 100644 --- a/fs/fat/fat.c +++ b/fs/fat/fat.c @@ -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; diff --git a/fs/fs.c b/fs/fs.c index 3cd2c88a4895..09625f52e913 100644 --- a/fs/fs.c +++ b/fs/fs.c @@ -207,7 +207,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, diff --git a/include/fat.h b/include/fat.h index a9756fb4cd1b..c03a2bebecef 100644 --- a/include/fat.h +++ b/include/fat.h @@ -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); -- 2.36.1
next prev parent reply other threads:[~2022-06-29 11:39 UTC|newest] Thread overview: 26+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-06-29 11:38 [PATCH 0/8] U-boot: fs: add generic unaligned read offset handling Qu Wenruo 2022-06-29 11:38 ` Qu Wenruo via Linux-erofs 2022-06-29 11:38 ` [PATCH 1/8] fs: fat: unexport file_fat_read_at() Qu Wenruo 2022-06-29 11:38 ` Qu Wenruo via Linux-erofs 2022-07-25 22:28 ` Tom Rini 2022-07-25 22:28 ` Tom Rini 2022-07-26 1:35 ` Qu Wenruo 2022-07-26 1:35 ` Qu Wenruo 2022-07-26 2:12 ` Tom Rini 2022-07-26 2:12 ` Tom Rini 2022-06-29 11:38 ` [PATCH 2/8] fs: btrfs: fix a bug which no data get read if the length is not 0 Qu Wenruo 2022-06-29 11:38 ` Qu Wenruo via Linux-erofs 2022-06-29 11:38 ` [PATCH 3/8] fs: btrfs: fix a crash if specified range is beyond file size Qu Wenruo 2022-06-29 11:38 ` Qu Wenruo via Linux-erofs 2022-06-29 11:38 ` [PATCH 4/8] fs: btrfs: move the unaligned read code to _fs_read() for btrfs Qu Wenruo 2022-06-29 11:38 ` Qu Wenruo via Linux-erofs 2022-06-29 11:38 ` [PATCH 5/8] fs: ext4: rely on _fs_read() to handle leading unaligned block read Qu Wenruo 2022-06-29 11:38 ` Qu Wenruo via Linux-erofs 2022-06-29 11:38 ` Qu Wenruo [this message] 2022-06-29 11:38 ` [PATCH 6/8] fs: fat: rely on higher layer to get block aligned read range Qu Wenruo via Linux-erofs 2022-06-29 11:38 ` [PATCH 7/8] fs: ubifs: rely on higher layer to do unaligned read Qu Wenruo 2022-06-29 11:38 ` Qu Wenruo via Linux-erofs 2022-06-29 11:38 ` [PATCH 8/8] fs: erofs: add unaligned read range handling Qu Wenruo 2022-06-29 11:38 ` Qu Wenruo via Linux-erofs 2022-06-30 12:21 ` Huang Jianan 2022-06-30 12:21 ` Huang Jianan
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=0a30a7118f69bd0636bc2350d53890b99b8c191d.1656502685.git.wqu@suse.com \ --to=wqu@suse.com \ --cc=jnhuang95@gmail.com \ --cc=joaomarcos.costa@bootlin.com \ --cc=linux-btrfs@vger.kernel.org \ --cc=linux-erofs@lists.ozlabs.org \ --cc=marek.behun@nic.cz \ --cc=miquel.raynal@bootlin.com \ --cc=thomas.petazzoni@bootlin.com \ --cc=trini@konsulko.com \ --cc=u-boot@lists.denx.de \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.