how tar and cpio handle symbolic links

Snoopy snoopy at sopwith
Fri Nov 30 16:41:26 AEST 1990


> 	From man tar on my Tektronix 6130 (running a 4.2BSD derivative
> called UTek)
> 
>      h   Force tar to follow symbolic links as if they were
>          normal files or directories. Normally, tar does not
>          follow symbolic links.
> 
> (It normally just records that the entry is a Symbolic Link to a specific
> file, whose name is shown.)

And when extracting, recreates the symbolic link.  Which could possibly
point at a non-existant file.  Hmmm, perhaps there should be an option
which saves the symlink *and* the file it points at.  (To save one the
trouble of finding all the symlinks and making sure what they point to
gets included in the archive.)

> Gnu tar, on systems with symbolic links, can be
> compiled with similar options

This should not be a compile-time option.  It should be a run-time option,
as both methods are useful, depending on what you're doing.

>	From the same Tektronix 6130, the man page for cpio says:
> 
>      Cpio does not know about symbolic links, but since it is
>      usually used with find, there is little danger of getting
>      into loops. Also, instead of archiving or copying symbolic
>      links, cpio copies the files pointed to by the links, if
>      they exist.
> 
>      Only the superuser can copy special files.
> 
> Which all seems to be fairly resonable behavior.  (Of course this is on the
> OS that started symbolic links, so you would hope that they would do it
> right.

Utek's cpio is from System V.2.2, which explains why it didn't originally
understand symlinks.  I added a 'L' option to give cpio the ability to
save and restore the symlink the way tar could.  The default is unchanged
for backwards compatability, and is thus different than tar's default.  -sigh-

If you use cpio on a Tek 6130 you want a version 87/12/08 or newer.
Older versions do not always handle hard links correctly (due a bug)
and don't know about symlinks.  [Use ident(1) to determine the date.]

I used to use cpio.  After looking at the source code for both cpio
and tar I now use tar.  For backing up entire filesystems I recommend
using dump(8)/restore(8).  If you're on a 6130, you want a version of
dump 87/09/15 or later because these are are based on BSD 4.3 rather
than 4.2 and are *much* faster.

Disclaimer: I no longer work for Tektronix, and didn't speak for them
even when I did.
    _____
   /_____\    Snoopy
  /_______\   cse.ogi.edu!sopwith!snoopy
    |___|     sun!nosun!qiclab!sopwith!snoopy
    |___|     uunet!tektronix!nosun!qiclab!sopwith!snoopy



More information about the Comp.unix.internals mailing list