github.com/pachyderm/pachyderm@v1.13.4/src/server/pfs/fuse/files_linux.go (about) 1 // Copyright 2019 the Go-FUSE Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package fuse 6 7 import ( 8 "context" 9 "syscall" 10 "time" 11 "unsafe" 12 13 "github.com/hanwen/go-fuse/v2/fs" 14 "github.com/hanwen/go-fuse/v2/fuse" 15 ) 16 17 func (f *loopbackFile) Allocate(ctx context.Context, off uint64, sz uint64, mode uint32) syscall.Errno { 18 f.mu.Lock() 19 defer f.mu.Unlock() 20 err := syscall.Fallocate(f.fd, mode, int64(off), int64(sz)) 21 if err != nil { 22 return fs.ToErrno(err) 23 } 24 return fs.OK 25 } 26 27 // Utimens - file handle based version of loopbackFileSystem.Utimens() 28 func (f *loopbackFile) utimens(a *time.Time, m *time.Time) syscall.Errno { 29 var ts [2]syscall.Timespec 30 ts[0] = fuse.UtimeToTimespec(a) 31 ts[1] = fuse.UtimeToTimespec(m) 32 err := futimens(int(f.fd), &ts) 33 return fs.ToErrno(err) 34 } 35 36 // futimens - futimens(3) calls utimensat(2) with "pathname" set to null and 37 // "flags" set to zero 38 func futimens(fd int, times *[2]syscall.Timespec) (err error) { 39 _, _, e1 := syscall.Syscall6(syscall.SYS_UTIMENSAT, uintptr(fd), 0, uintptr(unsafe.Pointer(times)), uintptr(0), 0, 0) 40 if e1 != 0 { 41 err = syscall.Errno(e1) 42 } 43 return 44 }