2021-08-23 09:14:53 -04:00
|
|
|
//go:build linux || freebsd
|
2019-08-09 09:42:59 -04:00
|
|
|
// +build linux freebsd
|
|
|
|
|
2018-02-05 16:05:59 -05:00
|
|
|
package system // import "github.com/docker/docker/pkg/system"
|
2014-03-20 11:52:00 -04:00
|
|
|
|
|
|
|
import (
|
|
|
|
"syscall"
|
2017-05-23 10:22:32 -04:00
|
|
|
|
|
|
|
"golang.org/x/sys/unix"
|
2014-03-20 11:52:00 -04:00
|
|
|
)
|
|
|
|
|
2015-07-28 12:13:12 -04:00
|
|
|
// LUtimesNano is used to change access and modification time of the specified path.
|
2017-05-23 10:22:32 -04:00
|
|
|
// It's used for symbol link file because unix.UtimesNano doesn't support a NOFOLLOW flag atm.
|
2014-03-20 11:52:00 -04:00
|
|
|
func LUtimesNano(path string, ts []syscall.Timespec) error {
|
2019-08-09 09:42:59 -04:00
|
|
|
uts := []unix.Timespec{
|
|
|
|
unix.NsecToTimespec(syscall.TimespecToNsec(ts[0])),
|
|
|
|
unix.NsecToTimespec(syscall.TimespecToNsec(ts[1])),
|
2014-03-20 11:52:00 -04:00
|
|
|
}
|
2019-08-09 09:42:59 -04:00
|
|
|
err := unix.UtimesNanoAt(unix.AT_FDCWD, path, uts, unix.AT_SYMLINK_NOFOLLOW)
|
|
|
|
if err != nil && err != unix.ENOSYS {
|
2014-03-20 11:52:00 -04:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|