XATTR_NAME_WITH_FLAGS(3)
β¨ xattr_name_with_flags(3): the extended-attribute copying manual β¨
okay so bestie, this manual page is literally called xattr_name_with_flags(3), and itβs all about extended attributes and copying them around without losing the plot. main character energy for libc, no cap. π
π NAME π
The squad on this page is xattr_preserve_for_intent, xattr_name_with_flags, xattr_name_without_flags, xattr_flags_from_name, and xattr_intent_with_flags β all here to obtain properties related to extended attributes, for use in copying. π«Ά
π LIBRARY π
Standard C Library (libc, -lc). iconic. β¨
πΈ SYNOPSIS πΈ
#include <xattr_flags.h>
int
xattr_preserve_for_intent(const char *, xattr_operation_intent_t);
char *
xattr_name_with_flags(const char *, xattr_flags_t);
char *
xattr_name_without_flags(const char *);
xattr_flags_t
xattr_flags_from_name(const char *);
int
xattr_intent_with_flags(xattr_operation_intent_t, xattr_flags_t);
π¦ DESCRIPTION π¦
So these functions are used in conjunction with copying extended attributes from one file to another. Various types of copying β an βintentβ β check flags to determine which is allowed or not. vibe check for your metadata, fr fr.
The xattr_name_with_flags() function returns an extended attribute name with the appropriate flags encoded as a string. The xattr_name_without_flags() undoes this, giving the name of the extended attribute without the flags encoding. The slight inverse of that is xattr_flags_from_name(), which will return the flags encoded in a name. obsessed with the symmetry. π₯
The values returned by xattr_name_with_flags() and xattr_name_without_flags() are allocated using malloc(3), and should be released by the caller, using free(3). yes bestie, you gotta free them β no leaking, periodt. π
These functions also have an internal table of pre-defined names, maintained by the operating system.
The function xattr_intent_with_flags() will return 0 if the flags argument indicates it should not be preserved for the given intent, or 1 if it should. simple as that, no drama.
The function xattr_preserve_for_intent() combines the functions above, and will return non zero if the named extended attribute should be preserved during a copy for the given intent. itβs giving βone function to vibe-check them all.β π
π INTENT π
The type xattr_operation_intent_t is an integral type, which is used to indicate what the intent for the operation is. The following intent values are defined:
XATTR_OPERATION_INTENT_COPYβ Indicates that the intent is to simply copy from the source to the destination. E.g., withcp. Most extended attributes should generally be preserved in this case. copy-paste but make it metadata. πXATTR_OPERATION_INTENT_SAVEβ Indicates that intent is to perform a save (perhaps as in a βsafe saveβ). This differs from a copy in that the content may be changing; the destination may be over-writing or replacing the source, and some extended attributes should not be preserved during this process. highkey delicate situation. π¦XATTR_OPERATION_INTENT_SHAREβ Indicates that the intent is to share, or export, the object. For example, saving as an attachment in an email message, or placing in a public folder. Sensitive information should probably not be preserved in this case. do not let the secrets escape, bestie. πXATTR_OPERATION_INTENT_SYNCβ Indicates that the intent is to sync the object to a service like iCloud Drive. cloud vibes. βοΈXATTR_OPERATION_INTENT_BACKUPβ Indicates that the intent is to backup the object to a service like Time Machine. backup bestie behavior. π«Ά
π FLAGS π
Various flags are defined by the type xattr_flags_t; the currently-defined values for this are:
XATTR_FLAG_NO_EXPORTβ This indicates that the extended attribute should not be exported, or shared. This is used withXATTR_OPERATION_INTENT_SHARE. keep it private, iykyk. πXATTR_FLAG_CONTENT_DEPENDENTβ This indicates that the extended attribute is tied to the contents of the file (or vice versa), such that it should be re-created when the contents are changed. A checksum, for example, should not be copied, and would thus be marked with this flag. itβs literally content-coded. π§XATTR_FLAG_NEVER_PRESERVEβ This indicates that the extended attribute should never be copied from a source object to a destination, no matter what the given intent is. never ever, no exceptions, periodt. πXATTR_FLAG_SYNCABLEβ This indicates that the extended attribute should be copied when the file is synced on services like iCloud Drive. Sync services may enforce additional restrictions on the acceptable size and number of extended attributes. (Note that when used withXATTR_FLAG_CONTENT_DEPENDENT, this may generate conflicts when the file is synced.) β οΈ so cute but also lowkey messy.XATTR_FLAG_ONLY_BACKUPβ This indicates that the extended attribute should only be copied during backup on services like Time Machine. backup-only era. βXATTR_FLAG_ONLY_SAVINGβ This indicates that the extended attribute should only be copied during save/backup. save/backup hive rise. πΈ
π EXAMPLE π
The following example is a simple function that, given an extended attribute name and an operation intent, will return whether or not the extended attribute should be copied. (This essentially does what xattr_preserve_for_intent() does.) itβs giving βDIY but make it exact.β β¨
int
ShouldCopyEA(const char *eaName, xattr_operation_intent_t intent)
{
xattr_flags_t flags = xattr_flags_from_name(eaName);
return xattr_intent_with_flags(intent, flags);
}
β HISTORY β
These functions first appeared in Mac OS in 2013. vintage but still relevant, bestie. π°οΈ
π
thatβs the whole page, bestie β xattr_name_with_flags(3), source/version: Debian, date: December 19, 2023. periodt. π
π¦ where this page comes from
- nixpkgs unstable: copyfile 240
- Copyright (c) 2013 Apple Computer, Inc. All rights reserved
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms