]> Cypherpunks repositories - gostls13.git/commitdiff
syscall: drop fallback to utimes in UtimesNano on Linux
authorTobias Klauser <tklauser@distanz.ch>
Wed, 1 Sep 2021 13:24:01 +0000 (15:24 +0200)
committerTobias Klauser <tobias.klauser@gmail.com>
Thu, 2 Sep 2021 09:24:59 +0000 (09:24 +0000)
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 <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
src/syscall/syscall_linux.go

index dfce3d0a4bac336618108e00b7ef0927afbb7029..a2dba54b97ddf89ffda4b88ab209be924f128cb8 100644 (file)
@@ -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) {