Skip to content

Commit

Permalink
runtime: add fcntl wrapper for syscall
Browse files Browse the repository at this point in the history
Signed-off-by: leongross <[email protected]>
  • Loading branch information
leongross committed Sep 18, 2024
1 parent dcca47f commit 4186397
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/runtime/os_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down Expand Up @@ -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)
7 changes: 7 additions & 0 deletions src/syscall/syscall_libc.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 4186397

Please sign in to comment.