aboutsummaryrefslogtreecommitdiff
path: root/internal/fusefrontend/file.go
diff options
context:
space:
mode:
authorSebastian Lackner2019-01-16 15:38:32 +0100
committerJakob Unterwurzacher2019-01-16 20:55:20 +0100
commit682e642cfa556c2d72c4050bfb8e38febdec49b3 (patch)
tree5c17005d3a2506da59dacd851eb586c544b239d0 /internal/fusefrontend/file.go
parent1d2ce9c213093c91b86ba6c28537ccda4469fe1f (diff)
fusefrontend: Rework the Utimens handling on macOS.
For Linux, everything effectively stays the same. For both path-based and fd-based Utimens() calls, we use unix.UtimesNanoAt(). To avoid introducing a separate syscall wrapper for futimens() (as done in go-fuse, for example), we instead use the /proc/self/fd - trick. On macOS, this changes quite a lot: * Path-based Utimens() calls were previously completely broken, since unix.UtimensNanoAt() ignores the passed file descriptor. Note that this cannot be fixed easily since there IS no appropriate syscall available on macOS prior to High Sierra (10.13). We emulate this case by using Fchdir() + setattrlist(). * Fd-based Utimens() calls were previously translated to f.GetAttr() (to fill any empty parameters) and syscall.Futimes(), which does not does support nanosecond precision. Both issues can be fixed by switching to fsetattrlist(). Fixes https://github.com/rfjakob/gocryptfs/issues/350
Diffstat (limited to 'internal/fusefrontend/file.go')
-rw-r--r--internal/fusefrontend/file.go6
1 files changed, 2 insertions, 4 deletions
diff --git a/internal/fusefrontend/file.go b/internal/fusefrontend/file.go
index a0b82ba..531274a 100644
--- a/internal/fusefrontend/file.go
+++ b/internal/fusefrontend/file.go
@@ -44,8 +44,6 @@ type File struct {
qIno openfiletable.QIno
// Entry in the open file table
fileTableEntry *openfiletable.Entry
- // go-fuse nodefs.loopbackFile
- loopbackFile nodefs.File
// Store where the last byte was written
lastWrittenOffset int64
// The opCount is used to judge whether "lastWrittenOffset" is still
@@ -75,7 +73,6 @@ func NewFile(fd *os.File, fs *FS) (*File, fuse.Status) {
contentEnc: fs.contentEnc,
qIno: qi,
fileTableEntry: e,
- loopbackFile: nodefs.NewLoopbackFile(fd),
fs: fs,
File: nodefs.NewDefaultFile(),
}, fuse.OK
@@ -474,5 +471,6 @@ func (f *File) GetAttr(a *fuse.Attr) fuse.Status {
func (f *File) Utimens(a *time.Time, m *time.Time) fuse.Status {
f.fdLock.RLock()
defer f.fdLock.RUnlock()
- return f.loopbackFile.Utimens(a, m)
+ err := syscallcompat.FutimesNano(f.intFd(), a, m)
+ return fuse.ToStatus(err)
}