erofs-utils: mkfs: strip overlay origin xattrs with --ovlfs-strip
PATCH 1/1 erofs-utils: mkfs: strip overlay origin xattrs with --ovlfs-strip
Fix --ovlfs-strip failing to remove trusted.overlay.origin from output inodes. Also consolidate the opaque and origin xattr helpers.
Fixes dd40232ee060 ("erofs-utils: mkfs: add `--ovlfs-strip` option")
Fixes 8286289d1959 ("erofs-utils: lib: avoid duplicate overlay origin xattrs")
Assisted-by Codex:gpt-6-astra
Signed-off-by Yifan Zhao <[email protected]>
--- include/erofs/xattr.h | 16 ++++++++----- lib/inode.c | 9 ++++---- lib/rebuild.c | 3 ++- lib/tar.c | 9 ++++---- lib/xattr.c | 53 +++++++++++++++++++++---------------------- 5 files changed, 48 insertions(+), 42 deletions(-)
include/erofs/xattr.h +10 -6
@@ -23,6 +23,11 @@ static inline unsigned int inlinexattr_header_size(struct erofs_inode *vi)struct erofs_importer ; +enum erofs_ovl_xattr { +EROFS_OVL_XATTR_OPAQUE , +EROFS_OVL_XATTR_ORIGIN , +}; +ssize_t erofs_sys_lsetxattr (const char *path,const char *name,void *value,size_t size);
@@ -45,12 +50,11 @@ int erofs_setxattr(struct erofs_inode *inode, int index, const char *name, const void *value, size_t size);int erofs_vfs_setxattr (struct erofs_inode *inode,const char *name,const void *value,size_t size); -bool erofs_is_opaque_xattr (const char *name); -int erofs_set_opaque_xattr (struct erofs_inode *inode); -void erofs_clear_opaque_xattr (struct erofs_inode *inode); -bool erofs_get_opaque_from_disk (struct erofs_inode *inode); -bool erofs_is_origin_xattr (const char *name); -int erofs_set_origin_xattr (struct erofs_inode *inode); +bool erofs_is_ovl_xattr (const char *name,enum erofs_ovl_xattr type); +int erofs_set_ovl_xattr (struct erofs_inode *inode,enum erofs_ovl_xattr type, +const void *value,size_t size); +void erofs_clear_ovl_xattr (struct erofs_inode *inode,enum erofs_ovl_xattr type); +bool erofs_has_ovl_xattr (struct erofs_inode *inode,enum erofs_ovl_xattr type);int erofs_read_xattrs_from_disk (struct erofs_inode *inode); bool erofs_xattr_prefix_matches(const char *key, unsigned int *index,
lib/inode.c +5 -4
@@ -2139,10 +2139,11 @@ static int erofs_mkfs_handle_inode(const struct erofs_mkfs_btctx *ctx, }/* strip all unnecessary overlayfs xattrs when ovlfs_strip is enabled */ -if (params->ovlfs_strip) -erofs_clear_opaque_xattr (inode); -else if (inode->whiteouts) { - ret =erofs_set_origin_xattr (inode); +if (params->ovlfs_strip) { +erofs_clear_ovl_xattr (inode,EROFS_OVL_XATTR_OPAQUE ); +erofs_clear_ovl_xattr (inode,EROFS_OVL_XATTR_ORIGIN ); + }else if (inode->whiteouts) { + ret =erofs_set_ovl_xattr (inode,EROFS_OVL_XATTR_ORIGIN ,NULL ,0 );if (ret)return ret; }
lib/rebuild.c +2 -1
@@ -486,7 +486,8 @@ static int erofs_rebuild_dirent_iter(struct erofs_dir_context *ctx) }if (!S_ISDIR (src.i_mode)) goto out; - mergedir->opaque |=erofs_get_opaque_from_disk (&src); + mergedir->opaque |=erofs_has_ovl_xattr (&src, +EROFS_OVL_XATTR_OPAQUE );erofs_inode_free_xattrs (&src); inode = dir = &src; }else {
lib/tar.c +5 -4
@@ -419,11 +419,12 @@ int tarerofs_apply_xattrs(struct erofs_inode *inode, struct list_head *xattrs)erofs_dbg ("Recording xattr(%s)=\"%.*s\" (of %u bytes) to file %s" , item->kv, vsz, v, vsz, inode->i_srcpath);/* a .wh..wh..opq preceds trusted.overlay.opaque xattr */ -if (inode->opaque &&erofs_is_opaque_xattr (item->kv)) +if (inode->opaque && +erofs_is_ovl_xattr (item->kv,EROFS_OVL_XATTR_OPAQUE ))continue ; -if (erofs_is_origin_xattr (item->kv)) +if (erofs_is_ovl_xattr (item->kv,EROFS_OVL_XATTR_ORIGIN )) inode->origin = true; -if (erofs_is_opaque_xattr (item->kv)) +if (erofs_is_ovl_xattr (item->kv,EROFS_OVL_XATTR_OPAQUE )) inode->opaque |=S_ISDIR (inode->i_mode); ret =erofs_vfs_setxattr (inode, item->kv, v, vsz);if (ret == -ENODATA )
@@ -1087,7 +1088,7 @@ out_eot:* needed if the tar tree is used soon, thus we have no chance * to generate it from xattrs. No impact to mergefs. */ - ret =erofs_set_opaque_xattr (d->inode); + ret =erofs_set_ovl_xattr (d->inode,EROFS_OVL_XATTR_OPAQUE ,"y" ,1 ); goto out; }else if (th->typeflag =='1' ) {/* hard link cases */ struct erofs_dentry *d2;
lib/xattr.c +26 -27
90 lines not on this page · raw message
Signature · 1 line
2.56.0