免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1870 | 回复: 0
打印 上一主题 下一主题

总结 tar: file name too long [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2007-02-27 15:08 |只看该作者 |倒序浏览

From: Daniel Hurtubise (
[email=daniel@CANR.Hydro.Qc.CA?Subject=Re:%20SUMMARY:%20tar:%20file%20name%20too%20long%2526In-Reply-To=%2526lt;86667@netnews.upenn.edu%3E]daniel@CANR.Hydro.Qc.CA[/email]
)
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-
     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
   
[email=johnb@edge.cis.mcmaster.ca?Subject=Re:%20SUMMARY:%20tar:%20file%20name%20too%20long%2526In-Reply-To=%2526lt;86667@netnews.upenn.edu%3E]johnb@edge.cis.mcmaster.ca[/email]
(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
   
[email=Koper.Jamgocyan@rcvie.co.at?Subject=Re:%20SUMMARY:%20tar:%20file%20name%20too%20long%2526In-Reply-To=%2526lt;86667@netnews.upenn.edu%3E]Koper.Jamgocyan@rcvie.co.at[/email]
(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
   
[email=dwf@mlb.semi.harris.com?Subject=Re:%20SUMMARY:%20tar:%20file%20name%20too%20long%2526In-Reply-To=%2526lt;86667@netnews.upenn.edu%3E]dwf@mlb.semi.harris.com[/email]
(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}\
                {a=$1}\
                {for (i=2;i128){\
                        {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
URL出处可以到网上去找,我就不找了.
这里dump/restore,cpio,pax皆是我不熟用的命令.
==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
               
               
               

本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/2355/showart_250638.html
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP