From e4effe9918199b30754a602ebcf4d301f4371820 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sybren=20A=2E=20St=C3=BCvel?= Date: Mon, 1 May 2023 17:55:54 +0200 Subject: [PATCH] Fix #104191: Manager build error on ARM64 Reimplement the `touch()` function on Linux to avoid depending on the `syscall` package, and use the `sys/unix` package instead. This is slightly higher level, and seems to build on AMD64 and ARM64. --- pkg/shaman/touch/touch_linux.go | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/pkg/shaman/touch/touch_linux.go b/pkg/shaman/touch/touch_linux.go index d3543f41..a6cb7b59 100644 --- a/pkg/shaman/touch/touch_linux.go +++ b/pkg/shaman/touch/touch_linux.go @@ -23,21 +23,21 @@ package touch import ( - "syscall" - "unsafe" + "os" + + "golang.org/x/sys/unix" ) -// touch is the same as syscall.utimes, but passes NULL as timestamp pointer (instead of a -// pointer to a concrete time). +// touch uses uni.UtimesNano() in order to pass the special 'now' timestamps +// available in that package. func touch(path string) (err error) { - var _p0 *byte - _p0, err = syscall.BytePtrFromString(path) - if err != nil { - return + now := unix.Timespec{ + Sec: 0, + Nsec: unix.UTIME_NOW, } - _, _, e1 := syscall.Syscall(syscall.SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(0), 0) - if e1 != 0 { - err = syscall.Errno(e1) + utimes := []unix.Timespec{now, now} + if e := unix.UtimesNano(path, utimes); e != nil { + return &os.PathError{Op: "chtimes", Path: path, Err: e} } - return + return nil } -- 2.30.2