Skip to content

Commit 164ac21

Browse files
committed
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 <[email protected]> Run-TryBot: Tobias Klauser <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Matt Layher <[email protected]> Reviewed-by: Brad Fitzpatrick <[email protected]>
1 parent f4d4317 commit 164ac21

File tree

1 file changed

+1
-21
lines changed

1 file changed

+1
-21
lines changed

unix/syscall_linux.go

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -168,27 +168,7 @@ func Utimes(path string, tv []Timeval) error {
168168
//sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error)
169169

170170
func UtimesNano(path string, ts []Timespec) error {
171-
if ts == nil {
172-
err := utimensat(AT_FDCWD, path, nil, 0)
173-
if err != ENOSYS {
174-
return err
175-
}
176-
return utimes(path, nil)
177-
}
178-
if len(ts) != 2 {
179-
return EINVAL
180-
}
181-
err := utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
182-
if err != ENOSYS {
183-
return err
184-
}
185-
// If the utimensat syscall isn't available (utimensat was added to Linux
186-
// in 2.6.22, Released, 8 July 2007) then fall back to utimes
187-
var tv [2]Timeval
188-
for i := 0; i < 2; i++ {
189-
tv[i] = NsecToTimeval(TimespecToNsec(ts[i]))
190-
}
191-
return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
171+
return UtimesNanoAt(AT_FDCWD, path, ts, 0)
192172
}
193173

194174
func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error {

0 commit comments

Comments
 (0)