2018-02-05 16:05:59 -05:00
|
|
|
package system // import "github.com/docker/docker/pkg/system"
|
2014-02-21 04:12:25 -05:00
|
|
|
|
|
|
|
import (
|
|
|
|
"syscall"
|
|
|
|
"unsafe"
|
2017-05-23 10:22:32 -04:00
|
|
|
|
|
|
|
"golang.org/x/sys/unix"
|
2014-02-21 04:12:25 -05:00
|
|
|
)
|
|
|
|
|
2015-12-13 11:00:39 -05: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-02-21 04:12:25 -05:00
|
|
|
func LUtimesNano(path string, ts []syscall.Timespec) error {
|
2017-05-23 10:22:32 -04:00
|
|
|
atFdCwd := unix.AT_FDCWD
|
2014-02-21 04:12:25 -05:00
|
|
|
|
|
|
|
var _path *byte
|
2017-05-23 10:22:32 -04:00
|
|
|
_path, err := unix.BytePtrFromString(path)
|
2014-02-21 04:12:25 -05:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
2017-05-23 10:22:32 -04:00
|
|
|
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 {
|
2014-02-21 04:12:25 -05:00
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
|
|
|
}
|