From 363966dc60c196bff2f9feeb7d249245265d5f12 Mon Sep 17 00:00:00 2001 From: Jingbo Xu Date: Fri, 9 Jun 2023 17:02:25 +0800 Subject: [PATCH] erofs-utils: mkfs: twist calculation of shared_xattr_id The on-disk format specifies that share xattr can be addressed by: xattr offset = xattr_blkaddr * block_size + 4 * shared_xattr_id That is, the shared_xattr_id is calculated from the xattr offset (starting from xattr_blkaddr) divided by 4. Make this semantics explicitly by calculating the divisor from 'sizeof(__le32)'. It has no logic change. Signed-off-by: Jingbo Xu Reviewed-by: Gao Xiang Link: https://lore.kernel.org/r/20230609090225.91890-1-jefflexu@linux.alibaba.com Signed-off-by: Gao Xiang --- lib/xattr.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/lib/xattr.c b/lib/xattr.c index 5e9e4135..7d7dc54c 100644 --- a/lib/xattr.c +++ b/lib/xattr.c @@ -722,8 +722,7 @@ int erofs_build_shared_xattrs_from_path(const char *path) }; item->next_shared_xattr = sorted_n[i + 1]; - item->shared_xattr_id = (off + p) / - sizeof(struct erofs_xattr_entry); + item->shared_xattr_id = (off + p) / sizeof(__le32); memcpy(buf + p, &entry, sizeof(entry)); p += sizeof(struct erofs_xattr_entry);