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-

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 (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 ./ 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):

   "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 (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}\
                {for (i=2;i<NF;i++) a=sprintf("%s/%s",a,$i)}\
                {if (length(a)>128){\
                        {if ((s==1)&&(f==0)) printf("\n***** Detected long path *****\n")}\
                        {printf("%s %s\n",a,$NF)}\
                END{if ((s==1)&&(f==1)) printf("***** End of long paths *****\n\n")}\
                ' $listfile1

Daniel Hurtubise

Thanks to the many who replied.

Cameron Humphries <> (Brett Lymn) (Frank Dauns)
David Fetrow <> (Brent Chivers)
Jim Guyton <> (Peter Samuel) (John Benjamins) (F. L. Charles Seeger III)
krm@PRI-MU.Prime.COM (Martin {martlbub} Kraegeloh) (Koper Jamgocyan) (Gerhard Holzer)
Mitchum DSouza <>
Calum Mackay <> (Stephan Edman) (Gordon Lentz) (Denis Faas) (Stephan Bechtolsheim)
Chris Cleary <> (Matt Goheen)
"Jon Mellott" <>
"Lawrence R. Rogers" <lrr@Princeton.EDU> (Donald McLachlan) (Jeff Beadles) (Peter Galvin)

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