From 164ac21ac19debb5bb11421e630ab8c34175ecf7 Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 1 Sep 2021 15:33:06 +0200 Subject: [PATCH] unix: drop fallback to utimes in UtimesNano on Linux Same as CL 346790 does for package syscall. The minimum required Linux kernel version for Go 1.18 will be changed to 2.6.32, see golang/go#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 golang/go#45964 Change-Id: Iaed782d182851c9ccff32f831e1704bae52662a6 Reviewed-on: https://go-review.googlesource.com/c/sys/+/346829 Trust: Tobias Klauser Run-TryBot: Tobias Klauser TryBot-Result: Go Bot Reviewed-by: Matt Layher Reviewed-by: Brad Fitzpatrick --- unix/syscall_linux.go | 22 +--------------------- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/unix/syscall_linux.go b/unix/syscall_linux.go index 2839435e..c16108a9 100644 --- a/unix/syscall_linux.go +++ b/unix/syscall_linux.go @@ -168,27 +168,7 @@ func Utimes(path string, tv []Timeval) error { //sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) func UtimesNano(path string, ts []Timespec) error { - if ts == nil { - err := utimensat(AT_FDCWD, path, nil, 0) - if err != ENOSYS { - return err - } - return utimes(path, nil) - } - 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] = NsecToTimeval(TimespecToNsec(ts[i])) - } - return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) + return UtimesNanoAt(AT_FDCWD, path, ts, 0) } func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error {