[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
tar extraction fails on a CIFS file system, due to a symlink
From: |
Bruno Haible |
Subject: |
tar extraction fails on a CIFS file system, due to a symlink |
Date: |
Sat, 21 Dec 2024 16:18:57 +0100 |
Hi,
This is on Linux 6.8.0, with GNU tar 1.35:
$ uname -srm
Linux 6.8.0-50-generic x86_64
$ tar --version
tar (GNU tar) 1.35
...
The attached file foo.tar was created through
$ tar cvf foo.tar foo/a_symlink_before foo/a_file foo/a_symlink_after
foo/a_symlink_before
foo/a_file
foo/a_symlink_after
When I unpack it on a CIFS file system, 'tar' emits a warning and, at the
end, fails with status 2.
$ stat -f .
File: "."
ID: 0 Namelen: 255 Type: cifs
Block size: 4096 Fundamental block size: 4096
Blocks: Total: 961041617 Free: 22131034 Available: 21999962
Inodes: Total: 244097024 Free: 237015499
$ mount
...
//<NAS>/<SHARE> on <MOUNTPOINT> type cifs
(rw,relatime,vers=1.0,cache=strict,username=bruno,uid=1000,forceuid,gid=1000,forcegid,addr=192.168.178.30,soft,unix,posixpaths,serverino,mapposix,acl,rsize=8192,wsize=8192,bsize=1048576,retrans=1,echo_interval=60,actimeo=1,closetimeo=1)
...
$ tar xf ~/foo.tar
tar: foo/a_symlink_before: Cannot utime: No such file or directory
tar: Exiting with failure status due to previous errors
$ echo $?
2
For analysis, here's the same thing again with system call traces.
$ rm -rf foo
$ strace -o /tmp/tar.log tar xf ~/foo.tar
tar: foo/a_symlink_before: Cannot utime: No such file or directory
tar: Exiting with failure status due to previous errors
Compare the system calls that extract 'foo/a_symlink_before':
symlinkat("a_file", AT_FDCWD, "foo/a_symlink_before") = -1 ENOENT (No such file
or directory)
mkdirat(AT_FDCWD, "foo", 0775) = 0
symlinkat("a_file", AT_FDCWD, "foo/a_symlink_before") = 0
utimensat(AT_FDCWD, "foo/a_symlink_before", [UTIME_OMIT, {tv_sec=1734793193,
tv_nsec=0} /* 2024-12-21T15:59:53+0100 */], AT_SYMLINK_NOFOLLOW) = -1 ENOENT
(No such file or directory)
...
newfstatat(AT_FDCWD, "foo/a_symlink_before", {st_mode=S_IFLNK|0777, st_size=6,
...}, AT_SYMLINK_NOFOLLOW) = 0
fchmodat2(AT_FDCWD, "foo/a_symlink_before", 0775, AT_SYMLINK_NOFOLLOW) = -1
EOPNOTSUPP (Operation not supported)
with those that extract 'foo/a_symlink_after':
symlinkat("a_file", AT_FDCWD, "foo/a_symlink_after") = 0
utimensat(AT_FDCWD, "foo/a_symlink_after", [UTIME_OMIT, {tv_sec=1734793016,
tv_nsec=0} /* 2024-12-21T15:56:56+0100 */], AT_SYMLINK_NOFOLLOW) = 0
newfstatat(AT_FDCWD, "foo/a_symlink_after", {st_mode=S_IFLNK|0777, st_size=6,
...}, AT_SYMLINK_NOFOLLOW) = 0
fchmodat2(AT_FDCWD, "foo/a_symlink_after", 0775, AT_SYMLINK_NOFOLLOW) = -1
EOPNOTSUPP (Operation not supported)
To me, it looks like 'tar' correctly passes the flag AT_SYMLINK_NOFOLLOW but
the utimensat() call ignores it.
Possible suggestion: Report it as a bug to the Linux kernel people?
Alternate suggestion: Delay utimensat() calls until the end of the 'tar' run?
(Then 'tar' would have set wrong time stamps but exited with code 0.)
Bruno
PS: The real file on which I experienced this first is
https://github.com/llvm/llvm-project/releases/download/llvmorg-19.1.5/LLVM-19.1.5-Linux-X64.tar.xz
but I did not want to bother you with a 1.5 GiB test file and
with a 480 MB log file :)
foo.tar
Description: Unix tar archive
tar.log
Description: Text Data
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- tar extraction fails on a CIFS file system, due to a symlink,
Bruno Haible <=