github.com/hanwen/go-fuse@v1.0.0/fuse/nodefs/files_linux.go (about)

     1  // Copyright 2016 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 nodefs
     6  
     7  import (
     8  	"syscall"
     9  	"time"
    10  
    11  	"github.com/hanwen/go-fuse/fuse"
    12  )
    13  
    14  func (f *loopbackFile) Allocate(off uint64, sz uint64, mode uint32) fuse.Status {
    15  	f.lock.Lock()
    16  	err := syscall.Fallocate(int(f.File.Fd()), mode, int64(off), int64(sz))
    17  	f.lock.Unlock()
    18  	if err != nil {
    19  		return fuse.ToStatus(err)
    20  	}
    21  	return fuse.OK
    22  }
    23  
    24  // Utimens - file handle based version of loopbackFileSystem.Utimens()
    25  func (f *loopbackFile) Utimens(a *time.Time, m *time.Time) fuse.Status {
    26  	var ts [2]syscall.Timespec
    27  	ts[0] = fuse.UtimeToTimespec(a)
    28  	ts[1] = fuse.UtimeToTimespec(m)
    29  	f.lock.Lock()
    30  	err := futimens(int(f.File.Fd()), &ts)
    31  	f.lock.Unlock()
    32  	return fuse.ToStatus(err)
    33  }