mirror of
https://github.com/rwinkhart/sys.git
synced 2026-08-31 06:16:41 -04:00
x/sys/unix: fix time/utime/utimes on arm64
In commit "7e44b69 x/sys/unix: fix invalid syscall on linux/arm" a test was added for time/utime syscall. This test exposed that neither time/utime work on arm64, because they call the legacy syscall "utimes". As a new architecture, arm64 doesn't implement any legacy syscalls. Implement by first calling utimensat, using UtimesNano as exampple. Change-Id: Iffed410730c06ac4c8184241d16eebf08c367524 Reviewed-on: https://go-review.googlesource.com/20174 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
This commit is contained in:
committed by
Brad Fitzpatrick
parent
54535356f1
commit
7a56174f00
+12
-1
@@ -92,13 +92,24 @@ func Unlinkat(dirfd int, path string, flags int) error {
|
||||
|
||||
//sys utimes(path string, times *[2]Timeval) (err error)
|
||||
|
||||
func Utimes(path string, tv []Timeval) (err error) {
|
||||
func Utimes(path string, tv []Timeval) error {
|
||||
if tv == nil {
|
||||
err := utimensat(AT_FDCWD, path, nil, 0)
|
||||
if err != ENOSYS {
|
||||
return err
|
||||
}
|
||||
return utimes(path, nil)
|
||||
}
|
||||
if len(tv) != 2 {
|
||||
return EINVAL
|
||||
}
|
||||
var ts [2]Timespec
|
||||
ts[0] = NsecToTimespec(TimevalToNsec(tv[0]))
|
||||
ts[1] = NsecToTimespec(TimevalToNsec(tv[1]))
|
||||
err := utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
|
||||
if err != ENOSYS {
|
||||
return err
|
||||
}
|
||||
return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user