unix/amd64: add Utimensat call, pass 0 for flags

This CL adds the Utimensat syscall and AT_SYMLINK_NOFOLLOW constant.

This is required for setting the access/modification times on symlinks.

In addition, it updates the UtimesNano function to pass 0 as the flags
parameter, to avoid potentially passing junk.

Change-Id: I280645f3f53173628b1e1986bc7a47bac254fcf8
Reviewed-on: https://go-review.googlesource.com/9379
Reviewed-by: Rob Pike <r@golang.org>
This commit is contained in:
Peter Waller
2015-05-05 17:43:46 +00:00
committed by Rob Pike
parent 65705ef9e9
commit 0a2b4af5eb
8 changed files with 27 additions and 12 deletions
+9 -2
View File
@@ -67,13 +67,13 @@ func Utimes(path string, tv []Timeval) (err error) {
return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
}
//sys utimensat(dirfd int, path string, times *[2]Timespec) (err error)
//sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error)
func UtimesNano(path string, ts []Timespec) (err error) {
if len(ts) != 2 {
return EINVAL
}
err = utimensat(_AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])))
err = utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
if err != ENOSYS {
return err
}
@@ -87,6 +87,13 @@ func UtimesNano(path string, ts []Timespec) (err error) {
return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
}
func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) (err error) {
if len(ts) != 2 {
return EINVAL
}
return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags)
}
//sys futimesat(dirfd int, path *byte, times *[2]Timeval) (err error)
func Futimesat(dirfd int, path string, tv []Timeval) (err error) {