我正在使用GNU tar
(v1.29)创建一个存档,并xxd
像这样检查它:
(
cd "$(mktemp -d)"
touch -d@0 1.txt 2.txt 3.txt
tar \
--format=pax \
--numeric-owner \
--owner=0 \
--group=0 \
--pax-option="exthdr.name=%d/PaxHeaders.0/%f,delete=atime,delete=ctime" \
--mtime=@0 \
-cf ../123.tar \
1.txt 2.txt 3.txt
xxd ../123.tar | grep -C1 ustar
rm -rf $PWD
)
这给了我这个:
000000f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000100: 0075 7374 6172 0030 3000 0000 0000 0000 .ustar.00.......
00000110: 0000 0000 0000 0000 0000 0000 0000 0000 ................
--
000002f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000300: 0075 7374 6172 0030 3000 0000 0000 0000 .ustar.00.......
00000310: 0000 0000 0000 0000 0000 0000 0000 0000 ................
--
000004f0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000500: 0075 7374 6172 0030 3000 0000 0000 0000 .ustar.00.......
00000510: 0000 0000 0000 0000 0000 0000 0000 0000 ................
为什么要tar --format=pax
生成其中的存档ustar
?
-x pax格式产生的pax存档磁带或文件应包含一系列块。档案的物理布局应与ustar交换格式中描述的ustar格式相同。
“ ustar”后跟1个零/ NUL字节是magic
指示存档类型的字段的值:
该
magic
字段是此归档文件以该归档文件格式输出的规范。如果此字段包含ustar(ISO / IEC 646:1991标准IRV中的五个字符,后跟NUL,则显示),…
当然,这仅适用于任何符合标准的pax
实用程序,但是我希望pax
GNUtar
创建的格式档案可以以与符合标准的pax
实现相同的方式创建档案。