I was very surprised to see that neither 'cp -p' nor 'cp -a' preserve the extended attributes of a file. example: root@freenas[/test]# lsextattr user A.txt A.txt DosStream.com.apple.TextEncoding:$DATA DosStream.AFP_Resource:$DATA DosStream.AFP_AfpInfo:$DATA DOSATTRIB DosStream.com.apple.lastuseddate#PS:$DATA root@freenas[/test]# cp -a A.txt A2.txt root@freenas[/test]# lsextattr user A2.txt A2.txt EAs sometimes contain important data, and there should surely be some kind of option to preserve them when copying a file. In contrast, macOS's cp -p does preserve EAs. See also #240146 for related bug against the cp man page for saying nothing.
We don't have a good "Related" bug field and 240146 doesn't have a blocking relationship with this one, so I just stuck it in the URL field for easier lookup.
Some time ago I saw patches for find(1) and cp(1). If someone wants to look at, you can find them here: https://gist.github.com/scifinder https://rxlab.org/text/?id=33
It seems they have created github repos for the modified versions: https://github.com/scifinder/cp https://github.com/scifinder/find
...although the git repos are less useful than than just the patches.
(In reply to Conrad Meyer from comment #4) I'm new to this project and I'd love to work on this. I applied the patch mentioned in the above conversation to the current source code. I ran the 'cp' tests and all 11 of them succeeded. I was going to start writing tests for verifying that extended attributes are copied but I can't seem to find any shell commands that interact with them. I've read some of the documentation and it seems that you can use the 'zfs' command to figure out if a file system has extended attributes turned on but it doesn't allow you to set them on a per file basis. Does anyone have any advice on what I should be using?
(In reply to John Higgins from comment #5) Initial post shows lsextattr command, you can lookup other related commands doing `man lsextattr`.
(In reply to Yuri from comment #6) Thanks for the help :) I got a test working for the scifinder patch using Kyua. The only problem is that I'm not sure what to do when extended attributes are not enabled for the current file system. Is there a way to conditionally run tests or should I set the test to automatically succeed if the system doesn't support extended attributes?