]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: really use utimensat for UtimesNano on Solaris
authorTobias Klauser <tklauser@distanz.ch>
Mon, 14 Aug 2017 07:47:58 +0000 (09:47 +0200)
committerIan Lance Taylor <iant@golang.org>
Tue, 15 Aug 2017 16:56:03 +0000 (16:56 +0000)
golang.org/cl/55130 added utimensat for Solaris but didn't use it in
UtimesNano (despite indicating otherwise in the commit message). Fix
this by also using utimensat for UtimesNano on Solaris.

Because all versions of Solaris suppported by Go support utimensat,
there is no need for the fallback logic and utimensat can be called
unconditionally.

This issue was pointed out by Shawn Walker-Salas.

Updates #16480

Change-Id: I114338113a6da3cfcb8bca950674bdc8f5a7a9e5
Reviewed-on: https://go-review.googlesource.com/55141
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/syscall/syscall_solaris.go

index 9a5fbdae53741a7a584509dbcc22793839bb4220..b71cdcfdd7e114c7cc93830119c2407c6bfc048e 100644 (file)
@@ -270,16 +270,11 @@ func Gethostname() (name string, err error) {
        return name, err
 }
 
-func UtimesNano(path string, ts []Timespec) (err error) {
+func UtimesNano(path string, ts []Timespec) error {
        if len(ts) != 2 {
                return EINVAL
        }
-       var tv [2]Timeval
-       for i := 0; i < 2; i++ {
-               tv[i].Sec = ts[i].Sec
-               tv[i].Usec = ts[i].Nsec / 1000
-       }
-       return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
+       return utimensat(_AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
 }
 
 //sys  fcntl(fd int, cmd int, arg int) (val int, err error)