erofs-utils: mkfs: twist calculation of shared_xattr_id
authorJingbo Xu <jefflexu@linux.alibaba.com>
Fri, 9 Jun 2023 09:02:25 +0000 (17:02 +0800)
committerGao Xiang <hsiangkao@linux.alibaba.com>
Mon, 12 Jun 2023 08:46:15 +0000 (16:46 +0800)
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 <jefflexu@linux.alibaba.com>
Reviewed-by: Gao Xiang <hsiangkao@linux.alibaba.com>
Link: https://lore.kernel.org/r/20230609090225.91890-1-jefflexu@linux.alibaba.com
Signed-off-by: Gao Xiang <hsiangkao@linux.alibaba.com>
lib/xattr.c

index 5e9e41357ffca74e13e6d375eb1e2d6c370c972a..7d7dc54c36b3f0e9c5a617dc833ef2e1613dc811 100644 (file)
@@ -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);