diff options
| author | Tobias Klauser <tklauser@distanz.ch> | 2021-10-25 07:48:12 +0200 |
|---|---|---|
| committer | Tobias Klauser <tobias.klauser@gmail.com> | 2021-10-26 05:05:24 +0000 |
| commit | 23fdd7f0f75bca03a092faeeef60d8b0b804bf8d (patch) | |
| tree | 28ad57de038ef7b972d194dfe306198414f3e365 /src/syscall/syscall_darwin.go | |
| parent | ec6c00418c83aa4f68a5afc9803831f43f8d794f (diff) | |
| download | go-23fdd7f0f75bca03a092faeeef60d8b0b804bf8d.tar.xz | |
syscall: add utimensat libc wrapper on darwin
Add utimensat as a wrapper around the libc function of the same name.
utimensat was added in macOS 10.13 which is the minimum supported
release since Go 1.17 dropped support for macOS 10.12.
This also allows to drop the fallback to setattrlistTimes which was
used to set timestamps with nanosecond resolution before utimensat could
be used, see #22528 and CL 74952.
Updates #22528
Change-Id: I87b6a76acf1d642ceede9254f7d9d06dddc3fd71
Reviewed-on: https://go-review.googlesource.com/c/go/+/358274
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Diffstat (limited to 'src/syscall/syscall_darwin.go')
| -rw-r--r-- | src/syscall/syscall_darwin.go | 53 |
1 files changed, 1 insertions, 52 deletions
diff --git a/src/syscall/syscall_darwin.go b/src/syscall/syscall_darwin.go index a4fe4f1962..5bb34e300c 100644 --- a/src/syscall/syscall_darwin.go +++ b/src/syscall/syscall_darwin.go @@ -72,22 +72,6 @@ func direntNamlen(buf []byte) (uint64, bool) { func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) } func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) } -const ( - attrBitMapCount = 5 - attrCmnModtime = 0x00000400 - attrCmnAcctime = 0x00001000 -) - -type attrList struct { - bitmapCount uint16 - _ uint16 - CommonAttr uint32 - VolAttr uint32 - DirAttr uint32 - FileAttr uint32 - Forkattr uint32 -} - //sysnb pipe(p *[2]int32) (err error) func Pipe(p []int) (err error) { @@ -120,42 +104,7 @@ func libc_getfsstat_trampoline() //go:cgo_import_dynamic libc_getfsstat getfsstat "/usr/lib/libSystem.B.dylib" -func setattrlistTimes(path string, times []Timespec) error { - _p0, err := BytePtrFromString(path) - if err != nil { - return err - } - - var attrList attrList - attrList.bitmapCount = attrBitMapCount - attrList.CommonAttr = attrCmnModtime | attrCmnAcctime - - // order is mtime, atime: the opposite of Chtimes - attributes := [2]Timespec{times[1], times[0]} - const options = 0 - _, _, e1 := syscall6( - abi.FuncPCABI0(libc_setattrlist_trampoline), - uintptr(unsafe.Pointer(_p0)), - uintptr(unsafe.Pointer(&attrList)), - uintptr(unsafe.Pointer(&attributes)), - uintptr(unsafe.Sizeof(attributes)), - uintptr(options), - 0, - ) - if e1 != 0 { - return e1 - } - return nil -} - -func libc_setattrlist_trampoline() - -//go:cgo_import_dynamic libc_setattrlist setattrlist "/usr/lib/libSystem.B.dylib" - -func utimensat(dirfd int, path string, times *[2]Timespec, flag int) error { - // Darwin doesn't support SYS_UTIMENSAT - return ENOSYS -} +//sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) /* * Wrapped |
