Tar在压缩时遇到“无法打开:不是目录”

GiL*_*GiL 5 linux filesystems

我在RHEL-6.4上使用 fakeroot v1.12.4 进行打包和提取。我有两个不同的服务器,我在其中使用 tar v1.23 压缩文件。一台服务器上的压缩失败并出现以下错误:

tar: ./isolinux/etc/modprobe.d/blacklist.conf: Cannot open: Not a directory
tar: Exiting with failure status due to previous errors
Run Code Online (Sandbox Code Playgroud)

如果我检查这个文件的文件类型(作为普通用户),它说它是一个 ASCII 文件:

girishp@~$ file ./isolinux/etc/modprobe.d/blacklist.conf
isolinux/etc/modprobe.d/blacklist.conf: ASCII English text
girishp@~$
Run Code Online (Sandbox Code Playgroud)

但是如果我在 fakeroot 环境中检查文件类型,它说它是目录:

+ file ./isolinux/etc/modprobe.d/blacklist.conf
./isolinux/etc/modprobe.d/blacklist.conf: directory
Run Code Online (Sandbox Code Playgroud)

我用来压缩的命令是:

tar -czf /home/users/girishp/tarfiles/mytar.tgz .
Run Code Online (Sandbox Code Playgroud)

使用*代替.

tar -czf /home/users/girishp/tarfiles/mytar.tgz *
Run Code Online (Sandbox Code Playgroud)

我比较了两台机器的环境变量,环境没有区别。如果我使用sudo而不是fakeroot,它工作正常。straceoftar表示它正在尝试使用O_DIRECTORY选项打开文件。

open("./isolinux/etc/modprobe.d/blacklist.conf", O_RDONLY|O_NONBLOCK|O_LARGEFILE|O_DIRECTORY) = -1 ENOTDIR (Not a directory)
Run Code Online (Sandbox Code Playgroud)

我试图取消设置使用的一些环境变量fakeroot

unset LD_LIBRARY_PATH
unset LD_PRELOAD
Run Code Online (Sandbox Code Playgroud)

Tar 可以很好地处理这个问题。

为什么这个文件会在fakeroot环境中显示为目录?

GiL*_*GiL 0

将 fakeroot 更新到 v1.20.2-1,更新后的 fakeroot 不会出现问题。