修改bindfs上符号链接的日期

mna*_*gel 3 symlink fuse

我有一种感觉,我无法修改 bindfs 上符号链接的日期。请参阅以下我尝试过的记录。

在 EXT4 上:

nailor@needle:~$ mkdir /tmp/ex
nailor@needle:~$ cd /tmp/ex
nailor@needle:/tmp/ex$ touch realfile  
nailor@needle:/tmp/ex$ ln -s realfile linkfile
nailor@needle:/tmp/ex$ stat realfile linkfile
  File: `realfile'
  Size: 0           Blocks: 0          IO Block: 4096   regular empty file
Device: 801h/2049d  Inode: 22678377    Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/  nailor)   Gid: ( 1000/  nailor)
Access: 2013-09-09 00:46:15.356004837 +0200
Modify: 2013-09-09 00:46:15.356004837 +0200
Change: 2013-09-09 00:46:15.356004837 +0200
 Birth: -
  File: `linkfile' -> `realfile'
  Size: 8           Blocks: 0          IO Block: 4096   symbolic link
Device: 801h/2049d  Inode: 22678380    Links: 1
Access: (0777/lrwxrwxrwx)  Uid: ( 1000/  nailor)   Gid: ( 1000/  nailor)
Access: 2013-09-09 00:46:34.299766676 +0200
Modify: 2013-09-09 00:46:27.227855586 +0200
Change: 2013-09-09 00:46:27.227855586 +0200
 Birth: -
nailor@needle:/tmp/ex$ touch -h realfile linkfile
nailor@needle:/tmp/ex$ stat realfile linkfile    
  File: `realfile'
  Size: 0           Blocks: 0          IO Block: 4096   regular empty file
Device: 801h/2049d  Inode: 22678377    Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/  nailor)   Gid: ( 1000/  nailor)
Access: 2013-09-09 00:46:46.931607877 +0200
Modify: 2013-09-09 00:46:46.931607877 +0200
Change: 2013-09-09 00:46:46.931607877 +0200
 Birth: -
  File: `linkfile' -> `realfile'
  Size: 8           Blocks: 0          IO Block: 4096   symbolic link
Device: 801h/2049d  Inode: 22678380    Links: 1
Access: (0777/lrwxrwxrwx)  Uid: ( 1000/  nailor)   Gid: ( 1000/  nailor)
Access: 2013-09-09 00:46:49.899570563 +0200
Modify: 2013-09-09 00:46:46.931607877 +0200
Change: 2013-09-09 00:46:46.931607877 +0200
 Birth: -
Run Code Online (Sandbox Code Playgroud)

在绑定上:

nailor@needle:/tmp/ex$ mkdir sub      
nailor@needle:/tmp/ex$ bindfs -n . sub
nailor@needle:/tmp/ex$ cd sub
nailor@needle:/tmp/ex/sub$ touch -h realfile linkfile 
nailor@needle:/tmp/ex/sub$ stat realfile linkfile 
  File: `realfile'
  Size: 0           Blocks: 0          IO Block: 4096   regular empty file
Device: 17h/23d Inode: 2           Links: 1
Access: (0644/-rw-r--r--)  Uid: ( 1000/  nailor)   Gid: ( 1000/  nailor)
Access: 2013-09-09 00:47:34.000000000 +0200
Modify: 2013-09-09 00:47:34.000000000 +0200
Change: 2013-09-09 00:47:34.755006803 +0200
 Birth: -
  File: `linkfile' -> `realfile'
  Size: 8           Blocks: 0          IO Block: 4096   symbolic link
Device: 17h/23d Inode: 3           Links: 1
Access: (0777/lrwxrwxrwx)  Uid: ( 1000/  nailor)   Gid: ( 1000/  nailor)
Access: 2013-09-09 00:46:49.899570563 +0200
Modify: 2013-09-09 00:46:46.931607877 +0200
Change: 2013-09-09 00:46:46.931607877 +0200
 Birth: -
Run Code Online (Sandbox Code Playgroud)

如您所见,符号链接的时间在 bindfs 上没有改变。这是例如 rsync 的问题,因为这样我得到:

rsync: failed to set times on "link1": No such file or directory (2)
rsync: failed to set times on "link2": No such file or directory (2)
...
Run Code Online (Sandbox Code Playgroud)

我发现这是 sshfs ( http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=640038 ) 的一个已知问题,但没有发现任何提及 bindfs 的问题。现在我想知道是否有任何这样的提及和/或解释缺失的功能和/或答案是否会影响保险丝……

Gil*_*il' 5

无法更改符号链接日期的文件系统很常见。这本身不是 bindfs 或 sshfs 的错误。

Rsync 旨在解决这个问题。如果底层文件系统不支持它,它会忽略更改符号链接的时间和其他元数据的失败。

在 Linux 下,rsync 调用utimensat带有AT_SYMLINK_NOFOLLOW标志来更改符号链接的时间。据我所知,问题在于FUSE API没有对应的utimens(或utime)标志,因此文件系统实现只看到更改时间的请求,而没有指示是否遵循符号链接。缺乏任何特定指示,bindfs 和 sshfs 都以向后兼容的方式运行:它们修改符号链接的目标。对于损坏的符号链接,这会导致 ENOENT 错误。

乍一看,我以为这是 FUSE 中的一个错误:由于 FUSE 无法传递AT_SYMLINK_NOFOLLOW标志,它应该返回错误(EINVAL 或 ENOTSUP)。但是,粗略阅读Linux VFS 代码,看起来文件系统特定代码是在符号链接或其目标上调用的,因此不应遵循任何符号链接。这完全有道理:符号链接的目标可能位于不同的文件系统上。

所以我认为这是 bindfs 和 sshfs(可能在许多其他 FUSE 文件系统中)的错误:如果指示更改符号链接的元数据,它们应该只影响该符号链接,或者如果请求的更改不是,则返回错误可能的。