FreeBSD's "cp" doesn't copy extended attributes (in FreeBSD 12 currently)

FreeBSD's cp command doesn't copy extended attributes at all. I checked it in FreeBSD 12.0-RELEASE-p4. Thus, at this time, extended attributes attached to a file will be lost when copying the file with cp command on FreeBSD.

Someone who thinks “Use -p option, won't you?” is naive. The option just preserves file's mtime, atime, flags, permissions, ACL, UID and GID as manpage says.

For instance, there is a file hasxattr.txt which has two extended attribute (OpusMetaInformation and DOSATTRIB.)

$ ls -al
total 42
drwxr-xr-x   2 Decomo  Decomo    3 10月 22 00:11 .
drwxr-xr-x  56 Decomo  Decomo  190 10月 21 23:43 ..
-rwxr--r--   1 Decomo  Decomo    0 10月 21 23:49 hasxattr.txt
$ lsextattr user *
hasxattr.txt    OpusMetaInformation     DOSATTRIB

Then, copy the file with cp -p.

$ cp -p hasxattr.txt hasxattr_cp-p.txt

…and check extended attributes.

$ lsextattr user *
hasxattr.txt    OpusMetaInformation     DOSATTRIB
hasxattr_cp-p.txt

\(^o^)/ < They've gone.

The destination file's extended attributes surely have been lost when I checked them as a color label with DirectoryOpus filer. (OpusMetaInformation stored the label information.)

As a one of EA lover, it's a pity.

I tried GNU cp provided by sysutils/coreutils ports, but his reply was loveless…

$ gcp --preserve=xattr hasxattr.txt hasxattr_gcp.txt
gcp: 拡張属性を保護できません。cp が xattr サポートなしで作成されています

It seems that rsync -X and mv preserve extended file attributes.

$ rsync -X hasxattr.txt hasxattr_rsync.txt
$ mv hasxattr.txt hasxattr_mv.txt
$ lsextattr user *
hasxattr_cp-p.txt
hasxattr_mv.txt OpusMetaInformation     DOSATTRIB
hasxattr_rsync.txt      OpusMetaInformation     DOSATTRIB

I found a wonderful page which described a support status of extended attributes of each command on FreeBSD, Linux and MacOS: Extended attributes: the good, the not so good, the bad.

At any rate, I wish the coreutils ports could choice a option whether handling extended attributes or not.