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.

83 questions
16
votes
3 answers

What does the dot at the end of the permissions in the output of "ls -lah" mean?

I found some Linux files, and when I type ls -lah, it outputs this permissions format: ... drwxr-xr-x. 2 root root ... -rw-rw-r--. 1 root root ... I would like to know, what is the meaning of the dot (-rw-rw-r--.) at the end of the…
miller
  • 1,352
  • 3
  • 21
  • 49
12
votes
2 answers

Xattrs are not supported

I am trying to perform a little testing of XATTRs. I recompiled my kernel with ALL the XATTRs enabled. Now, when I include the header of xattrs : #include I receive an error no such file or directory. I am using UBUNTU 11.10 64 bit…
Karen Tsirunyan
  • 1,728
  • 5
  • 17
  • 29
11
votes
1 answer

where are extended attributes stored?

This is a simple question but I've done some research and can't find any answers... So does anyone know if when we define extended attributes through xattr, those attributes are stored within - as a part of - the file'contents(in the biggining, in…
user2900870
  • 187
  • 2
  • 8
10
votes
3 answers

How to use Extended File Attributes on NFS?

I have an NFS_Server - NFS_Client system. My client is mounted to an NFS_Server directory. I want to change the attribute of NFS_Server directory's files via NFS_Client mounted directory by using Extended File Attributes (xattr). When I tried to set…
Celik
  • 1,825
  • 1
  • 25
  • 45
9
votes
1 answer

Using xattr to set the Mac OSX quarantine property

There is a lot of information on StackOverflow and elsewhere about how to clear the Mac quarantine property. In my case I would like to set it. This is in order to test that my app is properly signed so that the user will hot get the "Untrusted…
Will
  • 327
  • 4
  • 15
7
votes
1 answer

Understanding output of xattr -p com.apple.quarantine

The other day I was messing with some files that had the extended attribute com.apple.quarantine on them. I am aware of its purpose, but I have always been curious what the properties below meant when you output its values. E.g. when I typed in…
Sal Alturaigi
  • 403
  • 7
  • 10
6
votes
1 answer

Using multiple keywords in xattr via _kMDItemUserTags or kMDItemOMUserTags

While reorganizing my images, in anticipation of OSX Mavericks I am writing a script to insert tags into the xattr fields of my image files, so I can search them with Spotlight. (I am also editing the EXIF just to be safe.) My questions are: Which…
beroe
  • 10,382
  • 4
  • 29
  • 69
5
votes
2 answers

How to get extended attributes of a file(UNIX/C)?

When I type ls -l in the command line, sometimes an @ or + symbol comes up alongside the file permissions(btw, I am on OS X), as shown below: -rw-r-----@ 1 john staff 6731 Sep 28 01:10 mutations.txt drwxr-xr-x+ 71 john staff 2414 Mar 25…
Jenna Maiz
  • 754
  • 3
  • 15
  • 32
5
votes
0 answers

modify metadata using xattr (OSX terminal)

I'm trying to use terminal and the xattr to modify an extended metadata entry. It looks simple, but I don't have any success. Currently I tried something like below: xattr -w com.apple.metadata:kMDItemDisplayName 'fileName.localized'…
Andreas Kiel
  • 81
  • 1
  • 1
  • 4
5
votes
3 answers

How to store a hash in extended file attributes on OS X with Java?

Preface I am working on a platform in-depended media database written in java where the media files are identified by a file hash. The user shall be able to move the files around, so I do NOT want to rely on any file path. Once imported, I store the…
IsNull
  • 626
  • 5
  • 10
4
votes
2 answers

Copy Mac com.apple.ResourceFork extended attribute causing "Argument list too long"

I'm trying to copy extended attributes from one file to another using the OSX "xattr" utility. The background is that we are building a backup tool and the files/structure must retain all attributes, ACLs, etc... Everything is working fine except…
Chris
  • 55
  • 1
  • 5
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,394
  • 1
  • 12
  • 33
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
  • 139
  • 6
3
votes
1 answer

Python Module xattr has no attribute list

I wrote a script which sets extended attributes on some files, with the module xattr. I successfully tested it in Ubuntu in python3, but it won't work on my RasperryPi. I had to change a dozens of little errors, mostly like xattr not knowing its…
Henry
  • 98
  • 1
  • 8
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
  • 328
  • 4
  • 12
1
2 3 4 5 6