fusefrontend: make Utimens symlink-safe

unix.UtimesNanoAt now also exists on Darwin, yay!
This commit is contained in:
Jakob Unterwurzacher 2018-11-04 22:53:41 +01:00
parent abbdaa8ea4
commit a355670ca2
1 changed files with 9 additions and 2 deletions

View File

@ -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.