diff --git a/src/runtime/os_linux.go b/src/runtime/os_linux.go index df5870a2df..a8bb98f790 100644 --- a/src/runtime/os_linux.go +++ b/src/runtime/os_linux.go @@ -5,7 +5,9 @@ package runtime // This file is for systems that are _actually_ Linux (not systems that pretend // to be Linux, like baremetal systems). -import "unsafe" +import ( + "unsafe" +) const GOOS = "linux" @@ -139,3 +141,7 @@ func hardwareRand() (n uint64, ok bool) { // //export getrandom func libc_getrandom(buf unsafe.Pointer, buflen uintptr, flags uint32) uint32 + +//go:linknam runtime_fcntl syscall/syscall_fcntl +//go:export +func runtime_fcntl(fd, cmd, arg int32) (ret int32, errno int32) diff --git a/src/syscall/syscall_libc.go b/src/syscall/syscall_libc.go index 67cf6681f7..b299fdb06f 100644 --- a/src/syscall/syscall_libc.go +++ b/src/syscall/syscall_libc.go @@ -212,6 +212,13 @@ func Truncate(path string, length int64) (err error) { return } +//go:linkname syscall_fcntl runtime.fcntl +func syscall_fcntl(fd, cmd, arg int32) (ret int32, errno int32) { + // https://cs.opensource.google/go/go/+/master:src/runtime/os_linux.go;l=452?q=runtime.fcntl&ss=go%2Fgo + r, _, err := Syscall6(SYS_FCNTL, uintptr(fd), uintptr(cmd), uintptr(arg), 0, 0, 0) + return int32(r), int32(err) +} + func Faccessat(dirfd int, path string, mode uint32, flags int) (err error) func Kill(pid int, sig Signal) (err error) {