[comp.unix.questions] tar vs. cpio

mellman@ttrdd.UUCP (06/03/87)

What is the difference between tar and cpio - I mean the Essential
Difference.  Why did anyone go to the trouble of writing cpio when
tar is perfectly okay?  What don't I understand about this?  Thanks

T. Mellman

ihnp4!ttrdc!ttrdd!mellman

jrg@hpirs.HP.COM (Jeff Glasson) (06/05/87)

> What is the difference between tar and cpio - I mean the Essential
> Difference.  Why did anyone go to the trouble of writing cpio when
> tar is perfectly okay?  What don't I understand about this?  Thanks

First of all, I think cpio came first.  So your question should be phrased:
"Why did someone go and write tar when cpio seems perfectly OK?"

One advantage cpio has over tar is the ability to archive and re-create
special files (i.e. device files, named pipes, etc.).  Tar only knows
how to handle symbolic links.

But, in my opinion, tar has a much superior user interface so I only use
cpio when I have to deal with restoring device files.

Jeff Glasson

snoopy@doghouse.gwd.tek.com (Snoopy) (06/12/87)

In article <4750008@hpirs.HP.COM> jrg@hpirs.HP.COM (Jeff Glasson) writes:

>One advantage cpio has over tar is the ability to archive and re-create
>special files (i.e. device files, named pipes, etc.).  Tar only knows
>how to handle symbolic links.

I've taught cpio about symbolic links (*), has anyone taught tar
about special files?  About multiple volume media?  Tar's code is
orders of magnitude cleaner than cpio's.

(*) If anyone else tries this, I suggest leaving the default behaviour
the same as it is now, and handling symlinks as symlinks if the 'L'
option is given.  You will want to make use of lstat(2) and readlink(2).
Store the path that the link points to where the contents of a regular
file would be.  Don't add a trailing NULL.  Make the 'file length' the
length of the pathname.  For restoring archives, you will need to use
symlink(2).  Consider carefully which cases need to have the main loop
skip reading the 'file contents'.  Make sure your test cases include
"cpio -it" and pulling individual files out of archives.

Snoopy
tektronix!doghouse.gwd!snoopy
snoopy@doghouse.gwd.tek.com

"cpio : Input not in cpio format. (cpio5)"

roy@phri.UUCP (06/14/87)

	A little while back, somebody asked the $64k question, "what is the
fundemental difference between tar and cpio".  Various people have taken
shots at the answer, but they are all nit-picking.  One handles symlinks,
one handles devices, one takes file patterns, one is more portable.  But,
people, you miss the real point -- the *is* no fundemental difference
between the two.  They both do the same thing (archive files, ostensibly,
but not necessarily, on tape) and the differences between them are
niggling.  It would be straight-forward to take all the nifty features of
either and fit them into the other.
-- 
Roy Smith, {allegra,cmcl2,philabs}!phri!roy
System Administrator, Public Health Research Institute
455 First Avenue, New York, NY 10016