On 28/05/2025 16:14, Gael Donval wrote:
Dear list,
We've unearth an odd behaviour in cp: `cp --preserve=xattr` tries to copy both
attributes of the chattr kind and extended attributes of the getfattr kind with
apparently no way to disable either one of them (it's all or nothing). This is
problematic in tools like mkosi where non-filesystem-specific xattributes need
to be preserved whilst FS-specific attributes must be discarded for
cross-filesystem support.
I have added a MWE at the end of this email after my signature: it creates two
raw partitions as files (one as XFS, one as BTRFS), mounts them in local
folders and creates 3 files in the BTRFS partitions later altered before copy.
Referring to the script, we think there should be an option to copy files foo
(no-attr), bar (setfattr) and baz (chattr), keeping the setfattr's xattr and
discarding chattr's attr. Looking at the code, it seems like cp eventually
defers the actual attribute copying libattr, which seems to handle both, but
separately (which is what we want).
Would it make sense to add a separate `attr` preserve value for the chattr case
and keep `xattr` for getfattr case?
I've not looked in detail at your case,
but it's worth noting that /etc/xattr.conf
gives the facility to skip copying certain xattrs.
Does that suffice to handle your issue?
thanks,
Pádraig