Skip to contentSkip to conversation

erofs-utils: mkfs: twist calculation of shared_xattr_id

PATCH In review Jingbo Xu 2 participants 2 messages Jun 9, 2023 Library code

lore
Share & tools
lore

Jingbo Xu

author
#0 lore raw

PATCH 1/1 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.

---
 lib/xattr.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)
lib/xattr.c +1 -2
index dbe0519..1cd04cf 100644
@@ -643,8 +643,7 @@ int erofs_build_shared_xattrs_from_path(const char *path)
 			.e_value_size = cpu_to_le16(item->len[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);
Signature · 1 line
2.19.1.6.gb485710b
Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · Jingbo Xu

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.

Thanks,
Gao Xiang