Warm tip: This article is reproduced from serverfault.com, please click

posix-为什么GNU tar --format = pax会生成ustar档案?

(posix - Why does GNU tar --format=pax produce ustar archives?)

发布于 2020-12-16 22:04:48

我正在使用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

Questioner
rubicks
Viewed
22
MemReflect 2020-12-20 10:03:51

pax交换格式

-x pax格式产生的pax存档磁带或文件应包含一系列块。档案的物理布局应与ustar交换格式中描述的ustar格式相同。

“ ustar”后跟1个零/ NUL字节是magic指示存档类型字段的值

magic字段是此归档文件以该归档文件格式输出的规范。如果此字段包含ustar(ISO / IEC 646:1991标准IRV中的五个字符,后跟NUL,则显示),…

当然,这仅适用于任何符合标准的pax实用程序,但是我希望paxGNUtar创建的格式档案可以以与符合标准的pax实现相同的方式创建档案