Questions tagged [xattr]

Use the xattr tag for questions about extended attributes on files in a (Linux or macOS) file system.

Extended attributes are descriptions of the file stored separately from the file data. They are read by special system calls. People often first encounter them as a result of seeing an @ after the permissions in the output from ls -l. (The related symbol, a +, indicates that there are ACLs — access control lists — associated with the file.)

On macOS (or Mac OS X), you find out about the extended attributes with the @ option to ls. For example, a file might have the extra attribute:

$ ls -l@d Cscope
drwxr-xr-x@ 3 someuser  staff  102 Mar  8 21:49 Cscope
    com.apple.quarantine     30 
$

indicating that the directory had been copied from the internet and had not yet been marked as clean/safe. The Time Machine software makes extensive use of extended attributes too.

For macOS, the system calls are listxattr(), flistxattr() getxattr(), fgetxattr(), removexattr(), setxattr(). Linux adds lgetxattr() to this set.

96 questions
3
votes
3 answers

C# xattr file attributes

I'm creating a cross-platform software and I want to know if there is any (easy) way to read/write Unix (Mac OSX/Linux) extended file attributes in C#. I've just read about xattr namespaces, but I haven't found any information about C#…
Salaros
  • 1,444
  • 1
  • 14
  • 34
3
votes
1 answer

Java UserDefinedFileAttributeView null

I'm attempting to use the Files.NIO's UserDefinedFileAttributeView to read & write custom attributes to files (a hash, and two string properties) for use in a media server. I'm running macOS 10.15.4 with APFS, which definitely supports xattr (and I…
flynn06
  • 51
  • 1
  • 4
3
votes
1 answer

Why must a 'user.' be prepended to the name when setting a file's xattr with os.setxattr()?

I am saving data that I guess could be deemed metadata on a JSON serialized file: os.setxattr('/var/tmp/test.json', 'user.keyname', b'value') and I can get the bytes value back via: os.getxattr('/var/tmp/test.json', 'user.keyname') The only way I…
user11924970
3
votes
1 answer

How to add a Finder tag in macOS programmatically using Swift without tagging a file?

I'm building a macOS app which programmatically sets Finder tags for files using extended attributes similar to this answer for Swift 3: Set Finder label color. This works well. However, I'd like to create a tag and make it available in the…
Rckstr
  • 169
  • 7
3
votes
1 answer

How to query target of all Finder aliases?

Mac OSX 10.6 I've got some aliases that are pointing to the wrong volume. I'd like to search my whole hierarchy for such aliases. They're aliases, not symlinks, so I can't just do find / -type l -ls | grep badVolumeName. It seems that aliases have a…
michael
  • 346
  • 4
  • 12
3
votes
2 answers

Maximum size of xattr in OS X

I would like to use xattr to store some meta-data on my files directly on the files. These are essentially tags that I use for the categorization of files when I do searches on them. My goal is to extend the usual Mac OS X tags by associating more…
Rho Phi
  • 1,182
  • 1
  • 12
  • 21
3
votes
1 answer

Tar not preserving extended attributes of 'trusted' namespace

Explanation I am using tar for creating an archive containing a folder and some of its files have extended attributes. Including these: trusted.size=5 trusted.test I created and extracted the archive this way: sudo tar --xattrs…
Yarden
  • 496
  • 1
  • 5
  • 16
3
votes
1 answer

Change "date added" attribute of a file on OSX

I have been using Terminal to change the "date added" attribute of a file without success. What I'm doing is: Display the attributes of a file: mdls file_name Display the "date added" attribute: xattr -p "kMDItemDateAdded" file_name Change it: sudo…
user6877269
3
votes
1 answer

How to change icon of a MAC OS folder using Python Script and Terminal commands?

I am trying to write the Code in Python to Change the Icon of a Mac OS X folder using just the Python Script (Without XCODE or any other API). The procedure is that I have a icon.icns file , I need to change the folder icon to the icon.icns file…
3
votes
0 answers

Is the latest version of xattr (0.6.4) compatible with the latest stable version of Python (2.7.5)?

I'm asking this question because I'm having problems installing Little Snitch 3.1 on Mac OS X Mountain Lion 10.8.3. Indeed, I'm getting the following error: Error removing quarantine on ...: python version 2.7.5 can't run /usr/bin/xattr. Try the…
Olivier
  • 607
  • 1
  • 6
  • 21
3
votes
1 answer

Printing string representations of xattr hex output

I'm trying to write a script to extract the original download URL from disk images downloaded with Safari on OS X using xattr, so that I can rename them but still easily obtain their original names for reference. This command prints the hex…
Jake Petroules
  • 23,472
  • 35
  • 144
  • 225
2
votes
0 answers

anaconda3 install error: raise Exception("dst exists: %r" % dst)

I am trying to install anaconda3 in a CIFS drive (Azure File Share in my case) but i keep getting this error: PREFIX=/monsoondrive/central/anaconda3 installing: python-3.7.3-h0371630_0 ... Python 3.7.3 installing: conda-env-2.6.0-1 ... installing:…
BlimBlam
  • 336
  • 3
  • 11
2
votes
1 answer

xattr: ImportError: No module named pkg_resources

I was trying to run xattr on macOS Catalina 10.15.2 and the error occurred: Traceback (most recent call last): File "/usr/bin/xattr", line 8, in from pkg_resources import load_entry_point ImportError: No module named pkg_resources So…
Francis He
  • 23
  • 4
2
votes
0 answers

How to enabled extended attributes in UBIFS for SELinux?

I am trying to run SELinux chcon command on a UBIFS root filesystem and I get chcon: failed to change context of '/' to 'system_u:object_r:root_t': Operation not supported. I understand SELinux needs filesystem support for extended attributes. For…
uuwen
  • 23
  • 5
2
votes
0 answers

Setting the PDF Content Creator with xattr

I am try to take a Finder selection and assign a specific content creator value to pdf files using applescript and xattr. While the script compiles fine, it doesn't actually modify the metadata item. If I run mdls -n kMDItemCreator test.pdf I still…
GForce
  • 153
  • 2
  • 9