github.com/ssdev-go/moby@v17.12.1-ce-rc2+incompatible/pkg/system/utimes_linux.go (about)

     1  package system
     2  
     3  import (
     4  	"syscall"
     5  	"unsafe"
     6  
     7  	"golang.org/x/sys/unix"
     8  )
     9  
    10  // LUtimesNano is used to change access and modification time of the specified path.
    11  // It's used for symbol link file because unix.UtimesNano doesn't support a NOFOLLOW flag atm.
    12  func LUtimesNano(path string, ts []syscall.Timespec) error {
    13  	atFdCwd := unix.AT_FDCWD
    14  
    15  	var _path *byte
    16  	_path, err := unix.BytePtrFromString(path)
    17  	if err != nil {
    18  		return err
    19  	}
    20  	if _, _, err := unix.Syscall6(unix.SYS_UTIMENSAT, uintptr(atFdCwd), uintptr(unsafe.Pointer(_path)), uintptr(unsafe.Pointer(&ts[0])), unix.AT_SYMLINK_NOFOLLOW, 0, 0); err != 0 && err != unix.ENOSYS {
    21  		return err
    22  	}
    23  
    24  	return nil
    25  }