[PATCH RFC 7/8] fs: ubifs: rely on higher layer to do unaligned read
Qu Wenruo
wqu at suse.com
Tue Jun 28 09:28:07 CEST 2022
Currently ubifs doesn't support unaligned read offset, thanks to the
recent _fs_read() work to handle unaligned read, we only need to
implement ubifs_get_blocksize() to take advantage of it.
Now ubifs can do unaligned read without any problem.
Signed-off-by: Qu Wenruo <wqu at suse.com>
---
fs/fs.c | 2 +-
fs/ubifs/ubifs.c | 13 ++++++++-----
include/ubifs_uboot.h | 1 +
3 files changed, 10 insertions(+), 6 deletions(-)
diff --git a/fs/fs.c b/fs/fs.c
index 337d5711c28c..41943e3a95db 100644
--- a/fs/fs.c
+++ b/fs/fs.c
@@ -302,7 +302,7 @@ static struct fstype_info fstypes[] = {
.exists = ubifs_exists,
.size = ubifs_size,
.read = ubifs_read,
- .get_blocksize = fs_get_blocksize_unsupported,
+ .get_blocksize = ubifs_get_blocksize,
.write = fs_write_unsupported,
.uuid = fs_uuid_unsupported,
.opendir = fs_opendir_unsupported,
diff --git a/fs/ubifs/ubifs.c b/fs/ubifs/ubifs.c
index d3026e310168..a8ab556dd376 100644
--- a/fs/ubifs/ubifs.c
+++ b/fs/ubifs/ubifs.c
@@ -846,11 +846,9 @@ int ubifs_read(const char *filename, void *buf, loff_t offset,
*actread = 0;
- if (offset & (PAGE_SIZE - 1)) {
- printf("ubifs: Error offset must be a multiple of %d\n",
- PAGE_SIZE);
- return -1;
- }
+ /* Higher layer should ensure it always pass page aligned range. */
+ assert(IS_ALIGNED(offset, PAGE_SIZE));
+ assert(IS_ALIGNED(size, PAGE_SIZE));
c->ubi = ubi_open_volume(c->vi.ubi_num, c->vi.vol_id, UBI_READONLY);
/* ubifs_findfile will resolve symlinks, so we know that we get
@@ -920,6 +918,11 @@ out:
return err;
}
+int ubifs_get_blocksize(const char *filename)
+{
+ return PAGE_SIZE;
+}
+
void ubifs_close(void)
{
}
diff --git a/include/ubifs_uboot.h b/include/ubifs_uboot.h
index b025779d59ff..bcd21715314a 100644
--- a/include/ubifs_uboot.h
+++ b/include/ubifs_uboot.h
@@ -29,6 +29,7 @@ int ubifs_exists(const char *filename);
int ubifs_size(const char *filename, loff_t *size);
int ubifs_read(const char *filename, void *buf, loff_t offset,
loff_t size, loff_t *actread);
+int ubifs_get_blocksize(const char *filename);
void ubifs_close(void);
#endif /* __UBIFS_UBOOT_H__ */
--
2.36.1
More information about the U-Boot
mailing list