# Why tar can not handle files which filename is started with "._[A-Za-z]" ?



## uratan (Oct 8, 2020)

With the operation example below, the file "._ccc" is not restored by `tar`.
Is this a specification ? or a bug ?
Is there any option to avoid this ?


```
uratan@silver:~/w % mkdir ttt
uratan@silver:~/w % touch ttt/aaa
uratan@silver:~/w % touch ttt/.bbb
uratan@silver:~/w % touch ttt/._ccc
uratan@silver:~/w % touch ttt/.__ddd

uratan@silver:~/w % ls
ttt/ 

uratan@silver:~/w % find .
.
./ttt
./ttt/aaa
./ttt/.bbb
./ttt/._ccc
./ttt/.__ddd

uratan@silver:~/w % tar cvf s.tar ttt
a ttt
a ttt/aaa
a ttt/.bbb
a ttt/._ccc
a ttt/.__ddd

uratan@silver:~/w % mkdir 2
uratan@silver:~/w % cd 2
uratan@silver:~/w/2 % tar xvf ../s.tar
x ttt/
x ttt/aaa
x ttt/.bbb
x ttt/.__ddd

uratan@silver:~/w/2 % cd ..
uratan@silver:~/w % diff ttt 2/ttt
Only in ttt: ._ccc

uratan@silver:~/w % tar tvf s.tar
drwxr-xr-x  0 uratan zinc        0 Oct  8 22:10 ttt/
-rw-r--r--  0 uratan zinc        0 Oct  8 22:10 ttt/aaa
-rw-r--r--  0 uratan zinc        0 Oct  8 22:10 ttt/.bbb
-rw-r--r--  0 uratan zinc        0 Oct  8 22:10 ttt/.__ddd

uratan@silver:~/w % strings s.tar | grep ttt
ttt/
ttt/aaa
ttt/.bbb
ttt/._ccc
ttt/.__ddd

uratan@silver:~/w % uname -a
FreeBSD silver 10.2-RELEASE FreeBSD 10.2-RELEASE #1: Sun Mar 12 09:07:49 JST 201
7     uratan@silver:/usr/src/sys/i386/compile/OXYGEN  i386

uratan@silver:~/w % which tar
/usr/bin/tar
```


----------



## ekvz (Oct 8, 2020)

I am not sure but at least on 12.1-release i can't reproduce this behavior. Might be time to upgrade i fear.


----------



## olli@ (Oct 8, 2020)

I cannot reproduce that. I typed the exact same commands as you did, and all files were handled correctly, including ._ccc. That’s on FreeBSD stable/12 (as of a few weeks ago). Just out of curiosity, I also tried it on an old FreeBSD 9.3 that I’m running for forensic purposes in a non-networked VM. It also worked fine.

Note that FreeBSD 10.2 went End-Of-Life in 2016, four years ago. It’s not supported anymore and does not receive security fixes.
Please update to a supported release.


----------



## a6h (Oct 8, 2020)

tar(1) works fine here. Are you sure, you are on a FreeBSD maschine? sounds like a Mac OS to me!


----------



## uratan (Oct 9, 2020)

Thank you everyone.

I've found that I can extract the file "._ccc" by GNU tar,
so I did not lose my data fatally, that's very lucky.

 - * - * -


> vigole> sounds like a Mac OS to me!



I am keeping unused old rc files renaming to, for example, "._twmrc".
I've known just now that Mac OS uses files which name is started with '._'
as special, and found that the function `read_mac_metadata_blob()` may do
some selection by it.
 (see /usr/src/contrib/libarchive/libarchive/archive_read_support_format_tar.c)

Also, near calling `read_mac_metadata_blob()`, a comment below is found.
`/* TODO: Should this be disabled on non-Mac platforms? */`

The comment is disappeared with adding some OS-type-selector,
see line number 780 at
https://svnweb.freebsd.org/base/hea...read_support_format_tar.c?r1=285972&r2=299529

I'm convinced that my `tar` has a bug.
 (10.0R--10.3R may have this problem if my guess is correct)

Thanks again.


----------



## olli@ (Oct 9, 2020)

uratan said:


> I'm convinced that my `tar` has a bug.
> (10.0R--10.3R may have this problem if my guess is correct)


Well, then that would be another good reason to update to a supported version.


----------

