Chinaunix首页 | 论坛 | 博客
  • 博客访问: 550243
  • 博文数量: 155
  • 博客积分: 7055
  • 博客等级: 少将
  • 技术积分: 1700
  • 用 户 组: 普通用户
  • 注册时间: 2004-11-22 11:40














2007-02-27 15:08:51

From: Daniel Hurtubise ()
Date: Thu Aug 20 1992 - 14:14:34 CDT

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 require 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                 {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


==pax说明 (AS4.0)==
pax (pax) 3.0
pax: Known -x formats are: bcpio cpio sv4cpio sv4crc tar ustar

//生成k.tar, 包含文件a,b
pax -w -f k.tar a b
//从k.tar里解出a,b 放于本目录
pax -r -f k.tar
阅读(2685) | 评论(0) | 转发(0) |