syscall: add more stubs as needed for Go 1.20 support

This commit is contained in:
Ayke van Laethem
2023-02-02 20:29:06 +01:00
committed by Ayke
parent 1996fad075
commit d8b1fac690
6 changed files with 117 additions and 0 deletions
+14
View File
@@ -146,6 +146,8 @@ func Unlink(path string) (err error) {
return
}
func Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
func Kill(pid int, sig Signal) (err error) {
return ENOSYS // TODO
}
@@ -290,6 +292,18 @@ func Environ() []string {
return envs
}
// BytePtrFromString returns a pointer to a NUL-terminated array of
// bytes containing the text of s. If s contains a NUL byte at any
// location, it returns (nil, EINVAL).
func BytePtrFromString(s string) (*byte, error) {
for i := 0; i < len(s); i++ {
if s[i] == 0 {
return nil, EINVAL
}
}
return &cstring(s)[0], nil
}
// cstring converts a Go string to a C string.
func cstring(s string) []byte {
data := make([]byte, len(s)+1)