Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/performance/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Unix tar格式的大小令人困惑_Unix_Tar_File Format - Fatal编程技术网

Unix tar格式的大小令人困惑

Unix tar格式的大小令人困惑,unix,tar,file-format,Unix,Tar,File Format,我有这些简单的文件,它们的大小分别为2和29: ➜ /tmp/tmp >ll total 20K -rw-r--r-- 1 root root 2 9月 3 00:51 a.c -rw-r--r-- 1 root root 29 9月 3 00:52 c.c 然后我用焦油包装: tar-cvf a.tar a.c.c--format=ustar Like this: ... 00000400: 632e 6300 0000 0000 0000 0000 0000 0000

我有这些简单的文件,它们的大小分别为2和29:

➜  /tmp/tmp >ll
total 20K
-rw-r--r-- 1 root root   2 9月   3 00:51 a.c
-rw-r--r-- 1 root root  29 9月   3 00:52 c.c
然后我用焦油包装:

tar-cvf a.tar a.c.c--format=ustar

Like this:
...
00000400: 632e 6300 0000 0000 0000 0000 0000 0000  c.c.............
...
00000450: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000460: 0000 0000 3030 3030 3634 3400 3030 3030  ....0000644.0000
00000470: 3030 3000 3030 3030 3030 3000 3030 3030  000.0000000.0000
00000480: 3030 3030 3033 3500 3133 3732 3337 3436  0000035.13723746  <-- here 0000 000035
00000490: 3636 3600 3031 3134 3634 0020 3000 0000  666.011464. 0...
000004a0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
...
00000500: 0075 7374 6172 0030 3072 6f6f 7400 0000  .ustar.00root...
...
使用xxd以十六进制格式查看打包的文件:

xxd a.tar

Like this:
...
00000400: 632e 6300 0000 0000 0000 0000 0000 0000  c.c.............
...
00000450: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000460: 0000 0000 3030 3030 3634 3400 3030 3030  ....0000644.0000
00000470: 3030 3000 3030 3030 3030 3000 3030 3030  000.0000000.0000
00000480: 3030 3030 3033 3500 3133 3732 3337 3436  0000035.13723746  <-- here 0000 000035
00000490: 3636 3600 3031 3134 3634 0020 3000 0000  666.011464. 0...
000004a0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
...
00000500: 0075 7374 6172 0030 3072 6f6f 7400 0000  .ustar.00root...
...
像这样:
...
00000400:632e 63000000立方英尺。。。。。。。。。。。。。
...
00000450: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00000460: 0000 0000 3030 3030 3634 3400 3030 3030  ....0000644.0000
00000470: 3030 3000 3030 3030 3030 3000 3030 3030  000.0000000.0000

00000480:3030 3030 3033 3500 3133 3732 3337 3436 0000035.13723746基10中的29在基8中为35。如果您查找tar文件格式,您将看到文件大小被记录为base-8字符串。