github.com/docker/docker@v299999999.0.0-20200612211812-aaf470eca7b5+incompatible/pkg/system/utimes_unix.go (about)

     1  // +build linux freebsd
     2  
     3  package system // import "github.com/docker/docker/pkg/system"
     4  
     5  import (
     6  	"syscall"
     7  
     8  	"golang.org/x/sys/unix"
     9  )
    10  
    11  // LUtimesNano is used to change access and modification time of the specified path.
    12  // It's used for symbol link file because unix.UtimesNano doesn't support a NOFOLLOW flag atm.
    13  func LUtimesNano(path string, ts []syscall.Timespec) error {
    14  	uts := []unix.Timespec{
    15  		unix.NsecToTimespec(syscall.TimespecToNsec(ts[0])),
    16  		unix.NsecToTimespec(syscall.TimespecToNsec(ts[1])),
    17  	}
    18  	err := unix.UtimesNanoAt(unix.AT_FDCWD, path, uts, unix.AT_SYMLINK_NOFOLLOW)
    19  	if err != nil && err != unix.ENOSYS {
    20  		return err
    21  	}
    22  
    23  	return nil
    24  }