github.com/Prakhar-Agarwal-byte/moby@v0.0.0-20231027092010-a14e3e8ab87e/pkg/system/utimes_unix.go (about) 1 //go:build linux || freebsd 2 3 package system // import "github.com/Prakhar-Agarwal-byte/moby/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 }