[WIP] [PATCH 05/12] erofs-utils: fuse: use proper expression about inode size

Gao Xiang hsiangkao at aol.com
Sat Oct 17 16:16:14 AEDT 2020


[ let's fold in to the original patch. ]
Cc: Huang Jianan <huangjianan at oppo.com>
Signed-off-by: Gao Xiang <hsiangkao at aol.com>
---
 fuse/namei.c  | 4 ++--
 fuse/read.c   | 2 +-
 fuse/readir.c | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/fuse/namei.c b/fuse/namei.c
index 510fcfda5a76..0b71072027ce 100644
--- a/fuse/namei.c
+++ b/fuse/namei.c
@@ -172,8 +172,8 @@ struct dcache_entry *disk_lookup(struct dcache_entry *parent, const char *name,
 
 	if (v.datalayout == EROFS_INODE_FLAT_INLINE) {
 		uint32_t dir_off = erofs_blkoff(dirsize);
-		off_t dir_addr = nid2addr(dcache_get_nid(parent))
-			+ sizeof(struct erofs_inode_compact) + v.xattr_isize;
+		off_t dir_addr = nid2addr(dcache_get_nid(parent)) +
+			v.inode_isize + v.xattr_isize;
 
 		memset(buf, 0, sizeof(buf));
 		ret = dev_read(buf, dir_off, dir_addr);
diff --git a/fuse/read.c b/fuse/read.c
index dd44adaa1c40..3f2e49c390de 100644
--- a/fuse/read.c
+++ b/fuse/read.c
@@ -65,7 +65,7 @@ size_t erofs_read_data_inline(struct erofs_vnode *vnode, char *buffer,
 	if (!suminline)
 		goto finished;
 
-	addr = nid2addr(vnode->nid) + sizeof(struct erofs_inode_compact)
+	addr = nid2addr(vnode->nid) + vnode->inode_isize +
 		+ vnode->xattr_isize;
 	ret = dev_read(buffer + rdsz, suminline, addr);
 	if (ret < 0 || (size_t)ret != suminline)
diff --git a/fuse/readir.c b/fuse/readir.c
index 9589685c9122..46ceb1d90a7f 100644
--- a/fuse/readir.c
+++ b/fuse/readir.c
@@ -108,7 +108,7 @@ int erofs_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
 	if (v.datalayout == EROFS_INODE_FLAT_INLINE) {
 		off_t addr;
 
-		addr = nid2addr(nid) + sizeof(struct erofs_inode_compact)
+		addr = nid2addr(nid) + v.inode_isize
 			+ v.xattr_isize;
 
 		memset(dirsbuf, 0, sizeof(dirsbuf));
-- 
2.24.0



More information about the Linux-erofs mailing list