From: Tobias Klauser Date: Wed, 1 Sep 2021 13:24:01 +0000 (+0200) Subject: syscall: drop fallback to utimes in UtimesNano on Linux X-Git-Tag: go1.18beta1~1515 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=17e9d148d3354f8da745e6533213ca5b348b719e;p=gostls13.git syscall: drop fallback to utimes in UtimesNano on Linux The minimum required Linux kernel version for Go 1.18 will be changed to 2.6.32, see #45964. The current minimum required version is 2.6.23 and utimensat was added in 2.6.22, so the fallback isn't even necessary for the current minimum supported version. Remove the fallback to utimes. For #45964 Change-Id: I5536f6ea7a34944dd9165f1533c10692171fb0c5 Reviewed-on: https://go-review.googlesource.com/c/go/+/346790 Trust: Tobias Klauser Run-TryBot: Tobias Klauser TryBot-Result: Go Bot Reviewed-by: Brad Fitzpatrick --- diff --git a/src/syscall/syscall_linux.go b/src/syscall/syscall_linux.go index dfce3d0a4b..a2dba54b97 100644 --- a/src/syscall/syscall_linux.go +++ b/src/syscall/syscall_linux.go @@ -204,18 +204,7 @@ 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])), 0) - if err != ENOSYS { - return err - } - // If the utimensat syscall isn't available (utimensat was added to Linux - // in 2.6.22, Released, 8 July 2007) then fall back to utimes - 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) } func Futimesat(dirfd int, path string, tv []Timeval) (err error) {