Take the 2-minute tour ×
Ask Different is a question and answer site for power users of Apple hardware and software. It's 100% free, no registration required.

When packing and unpacking a tar file on OS X today, I find myself looking at things like:

tar tzf ../tanuki-3.5.6.tar.gz  
./._.
./ 
./._bin

I don't think I've ever seem these extra files starting with a '.' before. If I x the file, ls -a does not show them. What are they?

share|improve this question
add comment

3 Answers

up vote 4 down vote accepted

They're resource forks. The Mac's filesystem supports multiple forks, and some Mac files have two, a data fork and a resource fork. Most file systems don't support multiple forks, so tools will split the resource fork into a separate file prefixed with ._.

share|improve this answer
1  
Not quite -- they're AppleDouble header files that contain all the interesting additional file attributes that Mac files can have, that other filesystems (and archive formats like tar) don't natively support. In addition to the resource fork (is there is one), this includes Finder flags, type & creator codes, extended attributes, etc. –  Gordon Davisson Nov 16 '10 at 0:47
add comment

I think you'll find that those files (or directories) came packaged within the .tar.gz file. Not normal, but any file can go into a tar.

share|improve this answer
add comment

Behaviour

For the sake of clarity about the issue, the following MWE illustrates what is happening:

cas$ tar --version
bsdtar 2.6.2 - libarchive 2.6.2
cas$ mkdir o
cas$ touch o/a o/b
cas$ tar cv o > /dev/null
a ./._o
a o
a o/._a
a o/a
a o/._b
a o/b

So each file and directory has a ._ file added to the tar file in the same directory, as mipadi said. This tar, let's call it mactar, avoids collisions by ignoring files beginning ._ in the input, e.g, with:

mkdir p && touch p/._a p/._b
cas$ tar cv p p/._b > /dev/null
a ./._p
a p

the existence of the p/._a file is simply ignored by tar, and so is the p/._b file, even though that is explicitly included in the CLI invocation. Thus, no collisions can occur.

Controlling tar

If you have a Unix background, you likely are unhappy about this behaviour. The mactar lacks the expected documentation: the man page is for the regular Free BSD tar and does not mention this idiosyncrasy.

However, the generation of the files for the meta forks can be disabled by setting an environment variable, so: export COPYFILE_DISABLE=true.

History

I'm not quite clear on the timing, but OSX began with the regular Free BSD tar, then Apple circulated an additional utility, tar_hfs that was the ancestor of mactar, and then, I think with Leopard, changed /usr/bin/tar to be mactar.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.