From a355670ca2a5563d6c67b271ddeb6c0020a5fd00 Mon Sep 17 00:00:00 2001 From: Jakob Unterwurzacher Date: Sun, 4 Nov 2018 22:53:41 +0100 Subject: fusefrontend: make Utimens symlink-safe unix.UtimesNanoAt now also exists on Darwin, yay! --- internal/fusefrontend/fs.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'internal/fusefrontend') 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. -- cgit v1.2.3