Show pageOld revisionsBacklinksFold/unfold allBack to top This page is read only. You can view the source, but not change it. Ask your administrator if you think this is wrong. ====== 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 [[https://www.freebsd.org/cgi/man.cgi?cp|manpage]] says. For instance, there is a file ''hasxattr.txt'' which has two extended attribute (OpusMetaInformation and DOSATTRIB.) <code> $ 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 </code> Then, copy the file with ''cp -p''. <code> $ cp -p hasxattr.txt hasxattr_cp-p.txt </code> ...and check extended attributes. <code> $ lsextattr user * hasxattr.txt OpusMetaInformation DOSATTRIB hasxattr_cp-p.txt </code> \(^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.) {{:blog:2019:freebsd_cp_losts_xattr.png|}} As a one of EA lover, it's a pity. I tried GNU cp provided by ''sysutils/coreutils'' ports, but his reply was loveless... <code> $ gcp --preserve=xattr hasxattr.txt hasxattr_gcp.txt gcp: 拡張属性を保護できません。cp が xattr サポートなしで作成されています </code> It seems that ''rsync -X'' and ''mv'' preserve extended file attributes. <code> $ 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 </code> I found a wonderful page which described a support status of extended attributes of each command on FreeBSD, Linux and MacOS: [[https://www.lesbonscomptes.com/pages/extattrs.html|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. en/blog/2019/2019-10-22.txt Last modified: 2020-12-24 10:18by Decomo