When I tar certain files in OS X:
tar cvf foo.tar foo
It produces an extra file ._foo
in the tarball:
./._foo
foo
which only shows up if I extract it on a non-Mac operating system. But ._foo
doesn't exist on my file system! What's going on? How can I get rid of it?
Answer
OS X's tar uses the AppleDouble format to store extended attributes and ACLs.
$ touch file1 file2 file3
$ xattr -w key value file1
$ chmod +a 'admin allow delete' file2
$ ls -le@ *
-rw-r--r--@ 1 lauri staff 0 May 25 07:09 file1
key 5
-rw-r--r--+ 1 lauri staff 0 May 25 07:09 file2
0: group:admin allow delete
-rw-r--r-- 1 lauri staff 0 May 25 07:09 file3
$ tar -cf 1.tar *
$ tar -tf 1.tar
./._file1
file1
./._file2
file2
file3
OS X's tar also knows how to convert the ._ members back to native formats, but the ._ files are usually kept when archives are extracted on other platforms. You can tell tar to not include the metadata by setting COPYFILE_DISABLE to some value:
$ COPYFILE_DISABLE=1 tar -cf 2.tar file*
$ tar -tf 2.tar
file1
file2
file3
- The copyfile functions are described in
man copyfile
ls -l@
shows the keys and sizes of extended attributes,ls -le
prints ACLsxattr -l
lists the keys and values of extended attributesxattr -c
clears all extended attributes (-d can't be used alone)chmod -N
deletes ACLs- Zip files created on OS X use a __MACOSX folder to store similar metadata
Information stored as extended attributes:
- Resource forks (resource forks have been extended attributes since 10.4)
- Custom icons set in Finder and the images of Icon\r files
- Metadata in PSD files
- Objects stored in scpt files, AppleScript Editor window state, descriptions of scripts
- Information about aliases (aliases stop working if extended attributes are removed)
- Quarantine status or source URLs of files downloaded from the internet
- Spotlight comments
- Encoding of files saved with TextEdit
- Caret position of files opened with TextMate
- Skim notes
No comments:
Post a Comment