Extended Attributes Flags in Tahoe
When first introduced in Mac OS X, no provision was made for xattrs to have type-specific preservation, and that was added later using flags suffixed to the xattr’s name. For example, the com.apple.lastuseddate xattr found commonly on edited files is shown with a full name of com.apple.lastuseddate#PS to assign the two flags P and S to it, and the most recent xattr com.apple.fileprovider.pinned, used to mark files in iCloud Drive that have been pinned, has the two flags P and X assigned to it for a the full name of com.apple.fileprovider.pinned#PX.
[…]
It’s further complicated by a set of system tables for some standard xattr types that don’t have flags suffixed, but are treated as if they do.
[…]
When using standard commands such as
cp, macOS will automatically apply these rules when deciding whether to preserve xattrs. However, using a command for a different intent, such ascpfor backing up, won’t normally invoke the behaviour you might want.Code using standard macOS file operations should follow the behaviour expected for its intent, and shouldn’t require any special handling of xattrs. Lower-level operations are likely to differ, though, and may require implementation of equivalent behaviours.
The xattr_intent_with_flags() function will tell you, given an intent and a set of flags, whether you should preserve the xattr.
Previously:
- iCloud Drive Troubleshooting, Metadata, and Custom Icons
- Excluding From iCloud Drive
- xattr Flags and iCloud Drive