[PATCH 04/11] erofs-utils: lib: change argument order of erofs_io_pread()

Gao Xiang hsiangkao at linux.alibaba.com
Fri Jul 18 16:54:12 AEST 2025


To match pread(), swap the order of `len` and `pos`.

Signed-off-by: Gao Xiang <hsiangkao at linux.alibaba.com>
---
 include/erofs/io.h | 4 ++--
 lib/io.c           | 8 ++++----
 lib/super.c        | 2 +-
 3 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/include/erofs/io.h b/include/erofs/io.h
index 14d6e45f..01a7ff44 100644
--- a/include/erofs/io.h
+++ b/include/erofs/io.h
@@ -26,7 +26,7 @@ extern "C"
 struct erofs_vfile;
 
 struct erofs_vfops {
-	ssize_t (*pread)(struct erofs_vfile *vf, void *buf, u64 offset, size_t len);
+	ssize_t (*pread)(struct erofs_vfile *vf, void *buf, size_t len, u64 offset);
 	ssize_t (*pwrite)(struct erofs_vfile *vf, const void *buf, u64 offset, size_t len);
 	ssize_t (*pwritev)(struct erofs_vfile *vf, const struct iovec *iov,
 			   int iovcnt, u64 pos);
@@ -61,7 +61,7 @@ ssize_t erofs_io_pwritev(struct erofs_vfile *vf, const struct iovec *iov,
 int erofs_io_fsync(struct erofs_vfile *vf);
 int erofs_io_fallocate(struct erofs_vfile *vf, u64 offset, size_t len, bool pad);
 int erofs_io_ftruncate(struct erofs_vfile *vf, u64 length);
-ssize_t erofs_io_pread(struct erofs_vfile *vf, void *buf, u64 offset, size_t len);
+ssize_t erofs_io_pread(struct erofs_vfile *vf, void *buf, size_t len, u64 offset);
 ssize_t erofs_io_read(struct erofs_vfile *vf, void *buf, size_t len);
 off_t erofs_io_lseek(struct erofs_vfile *vf, u64 offset, int whence);
 
diff --git a/lib/io.c b/lib/io.c
index 983d9bf9..b91c93cf 100644
--- a/lib/io.c
+++ b/lib/io.c
@@ -196,7 +196,7 @@ int erofs_io_ftruncate(struct erofs_vfile *vf, u64 length)
 	return ftruncate(vf->fd, length);
 }
 
-ssize_t erofs_io_pread(struct erofs_vfile *vf, void *buf, u64 pos, size_t len)
+ssize_t erofs_io_pread(struct erofs_vfile *vf, void *buf, size_t len, u64 pos)
 {
 	ssize_t ret, read = 0;
 
@@ -204,7 +204,7 @@ ssize_t erofs_io_pread(struct erofs_vfile *vf, void *buf, u64 pos, size_t len)
 		return 0;
 
 	if (vf->ops)
-		return vf->ops->pread(vf, buf, pos, len);
+		return vf->ops->pread(vf, buf, len, pos);
 
 	pos += vf->offset;
 	do {
@@ -403,9 +403,9 @@ ssize_t erofs_dev_read(struct erofs_sb_info *sbi, int device_id,
 		}
 		read = erofs_io_pread(&((struct erofs_vfile) {
 				.fd = sbi->blobfd[device_id - 1],
-			}), buf, offset, len);
+			}), buf, len, offset);
 	} else {
-		read = erofs_io_pread(&sbi->bdev, buf, offset, len);
+		read = erofs_io_pread(&sbi->bdev, buf, len, offset);
 	}
 
 	if (read < 0)
diff --git a/lib/super.c b/lib/super.c
index e5364d27..8c0abafd 100644
--- a/lib/super.c
+++ b/lib/super.c
@@ -78,7 +78,7 @@ int erofs_read_superblock(struct erofs_sb_info *sbi)
 	struct erofs_super_block *dsb;
 	int read, ret;
 
-	read = erofs_io_pread(&sbi->bdev, data, 0, EROFS_MAX_BLOCK_SIZE);
+	read = erofs_io_pread(&sbi->bdev, data, EROFS_MAX_BLOCK_SIZE, 0);
 	if (read < EROFS_SUPER_END) {
 		ret = read < 0 ? read : -EIO;
 		erofs_err("cannot read erofs superblock: %d", ret);
-- 
2.43.5



More information about the Linux-erofs mailing list