SUMMARY: tar: file name too long

From: Daniel Hurtubise (daniel@CANR.Hydro.Qc.CA)
Date: Thu Aug 20 1992 - 14:14:34 CDT


Hello sun managers,

Here is the summary to my tar problem. First of all the "file name too
long" message is a known problem which is clearly mentioned in the
man pages for tar in the BUGS section:

        "Files with names longer than 100 characters cannot be pro-
     cessed."

Consequently, I'm sorry to have bothered everybody when I should have
thought of reading the man pages first.

In addition, here the file structure for tar found in "man 5 tar":

          #define TBLOCK 512
          #define NAMSIZ 100
          union hblock {
               char dummy[TBLOCK];
               struct header {
                    char name[NAMSIZ];
                    char mode[8];
                    char uid[8];
                    char gid[8];
                    char size[12];
                    char mtime[12];
                    char chksum[8];
                    char linkflag;
                    char linkname[NAMSIZ];
               } dbuf;
          };

However, I did get some good information on alternatives to tar.
While waiting for you responses, I used dump/restore which is one
solution that most everybody mentioned. The other solutions are:

1) Use GNUtar which has a limit of around 255 characters, maybe more.
   Here is an explanation of how GNUtar works from
   johnb@edge.cis.mcmaster.ca (John Benjamins):

"My solution has been to use the GNU version of tar. When GNU tar gets
to a file with a "too long" name, it saves it as ./MaNgLeD.xxx where
xxx is an integer, unique to each file in the archive. It also
appends a file ././MaNgLeD_NaMeS at the end of the archive. This is
used by GNU tar to restore the file names when they are subsequently
extracted from the archive. Note that GNU tar is needed to get the
files back with the correct names, using ordinary tar will give you
files with the MaNgLeD names."

2) Use bar

3) Use /usr/5bin/pax under 4.1.1 (haven't checked for 4.1.2)

4) Use dump/restore, which can be used in a pipe as explained by
   Koper.Jamgocyan@rcvie.co.at (Koper Jamgocyan):

   "Use dump and restore in a pipe. Note that dump can also dump any
   subfilesystem and not only the whole filesystem. That is:

   mounted filesystem: ("4.2"): /mnt/test/from-dir (/mnt is the mount point)
   you need the from-dir (recursively) somewhere else.

   cd /mnt
   dump 0f - test/from-dir | (cd /somewhere-else ; restore xf -)

   The disadvantages: 1) you must be root
                      2) /somewhere-else/test/from-dir is created, you have
                         to move from-dir up."

5) Use cpio. Here is an interesting suggestion from
   dwf@mlb.semi.harris.com (Denis Faas):

If you use cpio, which requiere a list of files, you can use awk
to check the length ahead of time.
(something like)
awk 'BEGIN{FS="/";s=0;f=0}\
                {a=$1}\
                {for (i=2;i<NF;i++) a=sprintf("%s/%s",a,$i)}\
                {if (length(a)>128){\
                        {s=1}\
                        {if ((s==1)&&(f==0)) printf("\n***** Detected long path *****\n")}\
                        {printf("%s %s\n",a,$NF)}\
                        {f=1}\
                        }\
                }\
                END{if ((s==1)&&(f==1)) printf("***** End of long paths *****\n\n")}\
                ' $listfile1

Daniel Hurtubise
Hydro-Quebec.

Thanks to the many who replied.

Cameron Humphries <cameron@cs.adelaide.edu.au>
blymn@awadi.com.AU (Brett Lymn)
dauns@gandalf.cs.andrews.edu (Frank Dauns)
David Fetrow <fetrow@pike.biostat.washington.edu>
bchivers@smiley.mitre.org (Brent Chivers)
Jim Guyton <guyton@condor.rand.org>
peters@nms.otca.oz.au (Peter Samuel)
johnb@edge.cis.mcmaster.ca (John Benjamins)
seeger@thedon.cis.ufl.edu (F. L. Charles Seeger III)
krm@PRI-MU.Prime.COM (Martin {martlbub} Kraegeloh)
Koper.Jamgocyan@rcvie.co.at (Koper Jamgocyan)
Gerhard.Holzer@rcvie.co.at (Gerhard Holzer)
Mitchum DSouza <mitchum.dsouza@mrc-applied-psychology.cambridge.ac.uk>
Calum Mackay <calum@mrc-biostatistics.cambridge.ac.uk>
Steve_Kilbane@gec-epl.co.uk
Stephan.Edman@eua.ericsson.se (Stephan Edman)
lentz@ody1.uchicago.edu (Gordon Lentz)
dwf@mlb.semi.harris.com (Denis Faas)
svb@cs.purdue.edu (Stephan Bechtolsheim)
Chris Cleary <c23cjc@kocrsv01.delcoelect.com>
matt@wbst845e.xerox.com (Matt Goheen)
"Jon Mellott" <jon@alpha.ee.ufl.edu>
"Lawrence R. Rogers" <lrr@Princeton.EDU>
don@mars.dgrc.doc.ca (Donald McLachlan)
jeff@onion.rain.com (Jeff Beadles)
trinkle@cs.purdue.edu
pbg@cs.brown.edu (Peter Galvin)



This archive was generated by hypermail 2.1.2 : Fri Sep 28 2001 - 23:06:48 CDT