summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJakob Unterwurzacher2018-11-04 22:53:41 +0100
committerJakob Unterwurzacher2019-01-01 16:24:25 +0100
commita355670ca2a5563d6c67b271ddeb6c0020a5fd00 (patch)
tree0ee144b31d8c396725dffd7907827f7ff970bbd4
parentabbdaa8ea4ca28b50304170986f0b6a271cda341 (diff)
fusefrontend: make Utimens symlink-safe
unix.UtimesNanoAt now also exists on Darwin, yay!
-rw-r--r--internal/fusefrontend/fs.go11
1 files changed, 9 insertions, 2 deletions
diff --git a/internal/fusefrontend/fs.go b/internal/fusefrontend/fs.go
index e41b9fa..3f35eb1 100644
--- a/internal/fusefrontend/fs.go
+++ b/internal/fusefrontend/fs.go
@@ -359,15 +359,22 @@ func (fs *FS) Truncate(path string, offset uint64, context *fuse.Context) (code
}
// Utimens - FUSE call. Set the timestamps on file "path".
+//
+// Symlink-safe through UtimesNanoAt.
func (fs *FS) Utimens(path string, a *time.Time, m *time.Time, context *fuse.Context) (code fuse.Status) {
if fs.isFiltered(path) {
return fuse.EPERM
}
- cPath, err := fs.encryptPath(path)
+ dirfd, cName, err := fs.openBackingDir(path)
if err != nil {
return fuse.ToStatus(err)
}
- return fs.FileSystem.Utimens(cPath, a, m, context)
+ defer syscall.Close(dirfd)
+ ts := make([]unix.Timespec, 2)
+ ts[0] = unix.Timespec(fuse.UtimeToTimespec(a))
+ ts[1] = unix.Timespec(fuse.UtimeToTimespec(m))
+ err = unix.UtimesNanoAt(dirfd, cName, ts, unix.AT_SYMLINK_NOFOLLOW)
+ return fuse.ToStatus(err)
}
// StatFs - FUSE call. Returns information about the filesystem.