Matteo Scandolo | a6a3aee | 2019-11-26 13:30:14 -0700 | [diff] [blame] | 1 | // Copyright 2009,2010 The Go Authors. All rights reserved. |
| 2 | // Use of this source code is governed by a BSD-style |
| 3 | // license that can be found in the LICENSE file. |
| 4 | |
| 5 | // Darwin system calls. |
| 6 | // This file is compiled as ordinary Go code, |
| 7 | // but it is also input to mksyscall, |
| 8 | // which parses the //sys lines and generates system call stubs. |
| 9 | // Note that sometimes we use a lowercase //sys name and wrap |
| 10 | // it in our own nicer implementation, either here or in |
| 11 | // syscall_bsd.go or syscall_unix.go. |
| 12 | |
| 13 | package unix |
| 14 | |
| 15 | import ( |
| 16 | "errors" |
| 17 | "syscall" |
| 18 | "unsafe" |
| 19 | ) |
| 20 | |
| 21 | const ImplementsGetwd = true |
| 22 | |
| 23 | func Getwd() (string, error) { |
| 24 | buf := make([]byte, 2048) |
| 25 | attrs, err := getAttrList(".", attrList{CommonAttr: attrCmnFullpath}, buf, 0) |
| 26 | if err == nil && len(attrs) == 1 && len(attrs[0]) >= 2 { |
| 27 | wd := string(attrs[0]) |
| 28 | // Sanity check that it's an absolute path and ends |
| 29 | // in a null byte, which we then strip. |
| 30 | if wd[0] == '/' && wd[len(wd)-1] == 0 { |
| 31 | return wd[:len(wd)-1], nil |
| 32 | } |
| 33 | } |
| 34 | // If pkg/os/getwd.go gets ENOTSUP, it will fall back to the |
| 35 | // slow algorithm. |
| 36 | return "", ENOTSUP |
| 37 | } |
| 38 | |
| 39 | // SockaddrDatalink implements the Sockaddr interface for AF_LINK type sockets. |
| 40 | type SockaddrDatalink struct { |
| 41 | Len uint8 |
| 42 | Family uint8 |
| 43 | Index uint16 |
| 44 | Type uint8 |
| 45 | Nlen uint8 |
| 46 | Alen uint8 |
| 47 | Slen uint8 |
| 48 | Data [12]int8 |
| 49 | raw RawSockaddrDatalink |
| 50 | } |
| 51 | |
| 52 | // Translate "kern.hostname" to []_C_int{0,1,2,3}. |
| 53 | func nametomib(name string) (mib []_C_int, err error) { |
| 54 | const siz = unsafe.Sizeof(mib[0]) |
| 55 | |
| 56 | // NOTE(rsc): It seems strange to set the buffer to have |
| 57 | // size CTL_MAXNAME+2 but use only CTL_MAXNAME |
| 58 | // as the size. I don't know why the +2 is here, but the |
| 59 | // kernel uses +2 for its own implementation of this function. |
| 60 | // I am scared that if we don't include the +2 here, the kernel |
| 61 | // will silently write 2 words farther than we specify |
| 62 | // and we'll get memory corruption. |
| 63 | var buf [CTL_MAXNAME + 2]_C_int |
| 64 | n := uintptr(CTL_MAXNAME) * siz |
| 65 | |
| 66 | p := (*byte)(unsafe.Pointer(&buf[0])) |
| 67 | bytes, err := ByteSliceFromString(name) |
| 68 | if err != nil { |
| 69 | return nil, err |
| 70 | } |
| 71 | |
| 72 | // Magic sysctl: "setting" 0.3 to a string name |
| 73 | // lets you read back the array of integers form. |
| 74 | if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil { |
| 75 | return nil, err |
| 76 | } |
| 77 | return buf[0 : n/siz], nil |
| 78 | } |
| 79 | |
Girish Gowdra | 161d27a | 2021-05-05 12:01:44 -0700 | [diff] [blame] | 80 | //sys ptrace(request int, pid int, addr uintptr, data uintptr) (err error) |
Matteo Scandolo | a6a3aee | 2019-11-26 13:30:14 -0700 | [diff] [blame] | 81 | func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) } |
| 82 | func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) } |
| 83 | |
| 84 | const ( |
| 85 | attrBitMapCount = 5 |
| 86 | attrCmnFullpath = 0x08000000 |
| 87 | ) |
| 88 | |
| 89 | type attrList struct { |
| 90 | bitmapCount uint16 |
| 91 | _ uint16 |
| 92 | CommonAttr uint32 |
| 93 | VolAttr uint32 |
| 94 | DirAttr uint32 |
| 95 | FileAttr uint32 |
| 96 | Forkattr uint32 |
| 97 | } |
| 98 | |
| 99 | func getAttrList(path string, attrList attrList, attrBuf []byte, options uint) (attrs [][]byte, err error) { |
| 100 | if len(attrBuf) < 4 { |
| 101 | return nil, errors.New("attrBuf too small") |
| 102 | } |
| 103 | attrList.bitmapCount = attrBitMapCount |
| 104 | |
| 105 | var _p0 *byte |
| 106 | _p0, err = BytePtrFromString(path) |
| 107 | if err != nil { |
| 108 | return nil, err |
| 109 | } |
| 110 | |
| 111 | if err := getattrlist(_p0, unsafe.Pointer(&attrList), unsafe.Pointer(&attrBuf[0]), uintptr(len(attrBuf)), int(options)); err != nil { |
| 112 | return nil, err |
| 113 | } |
| 114 | size := *(*uint32)(unsafe.Pointer(&attrBuf[0])) |
| 115 | |
| 116 | // dat is the section of attrBuf that contains valid data, |
| 117 | // without the 4 byte length header. All attribute offsets |
| 118 | // are relative to dat. |
| 119 | dat := attrBuf |
| 120 | if int(size) < len(attrBuf) { |
| 121 | dat = dat[:size] |
| 122 | } |
| 123 | dat = dat[4:] // remove length prefix |
| 124 | |
| 125 | for i := uint32(0); int(i) < len(dat); { |
| 126 | header := dat[i:] |
| 127 | if len(header) < 8 { |
| 128 | return attrs, errors.New("truncated attribute header") |
| 129 | } |
| 130 | datOff := *(*int32)(unsafe.Pointer(&header[0])) |
| 131 | attrLen := *(*uint32)(unsafe.Pointer(&header[4])) |
| 132 | if datOff < 0 || uint32(datOff)+attrLen > uint32(len(dat)) { |
| 133 | return attrs, errors.New("truncated results; attrBuf too small") |
| 134 | } |
| 135 | end := uint32(datOff) + attrLen |
| 136 | attrs = append(attrs, dat[datOff:end]) |
| 137 | i = end |
| 138 | if r := i % 4; r != 0 { |
| 139 | i += (4 - r) |
| 140 | } |
| 141 | } |
| 142 | return |
| 143 | } |
| 144 | |
| 145 | //sys getattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) |
| 146 | |
Girish Gowdra | 161d27a | 2021-05-05 12:01:44 -0700 | [diff] [blame] | 147 | func SysctlClockinfo(name string) (*Clockinfo, error) { |
| 148 | mib, err := sysctlmib(name) |
| 149 | if err != nil { |
| 150 | return nil, err |
| 151 | } |
| 152 | |
| 153 | n := uintptr(SizeofClockinfo) |
| 154 | var ci Clockinfo |
| 155 | if err := sysctl(mib, (*byte)(unsafe.Pointer(&ci)), &n, nil, 0); err != nil { |
| 156 | return nil, err |
| 157 | } |
| 158 | if n != SizeofClockinfo { |
| 159 | return nil, EIO |
| 160 | } |
| 161 | return &ci, nil |
| 162 | } |
| 163 | |
Matteo Scandolo | a6a3aee | 2019-11-26 13:30:14 -0700 | [diff] [blame] | 164 | //sysnb pipe() (r int, w int, err error) |
| 165 | |
| 166 | func Pipe(p []int) (err error) { |
| 167 | if len(p) != 2 { |
| 168 | return EINVAL |
| 169 | } |
| 170 | p[0], p[1], err = pipe() |
| 171 | return |
| 172 | } |
| 173 | |
| 174 | func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { |
| 175 | var _p0 unsafe.Pointer |
| 176 | var bufsize uintptr |
| 177 | if len(buf) > 0 { |
| 178 | _p0 = unsafe.Pointer(&buf[0]) |
| 179 | bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf)) |
| 180 | } |
| 181 | return getfsstat(_p0, bufsize, flags) |
| 182 | } |
| 183 | |
| 184 | func xattrPointer(dest []byte) *byte { |
| 185 | // It's only when dest is set to NULL that the OS X implementations of |
| 186 | // getxattr() and listxattr() return the current sizes of the named attributes. |
| 187 | // An empty byte array is not sufficient. To maintain the same behaviour as the |
| 188 | // linux implementation, we wrap around the system calls and pass in NULL when |
| 189 | // dest is empty. |
| 190 | var destp *byte |
| 191 | if len(dest) > 0 { |
| 192 | destp = &dest[0] |
| 193 | } |
| 194 | return destp |
| 195 | } |
| 196 | |
| 197 | //sys getxattr(path string, attr string, dest *byte, size int, position uint32, options int) (sz int, err error) |
| 198 | |
| 199 | func Getxattr(path string, attr string, dest []byte) (sz int, err error) { |
| 200 | return getxattr(path, attr, xattrPointer(dest), len(dest), 0, 0) |
| 201 | } |
| 202 | |
| 203 | func Lgetxattr(link string, attr string, dest []byte) (sz int, err error) { |
| 204 | return getxattr(link, attr, xattrPointer(dest), len(dest), 0, XATTR_NOFOLLOW) |
| 205 | } |
| 206 | |
| 207 | //sys fgetxattr(fd int, attr string, dest *byte, size int, position uint32, options int) (sz int, err error) |
| 208 | |
| 209 | func Fgetxattr(fd int, attr string, dest []byte) (sz int, err error) { |
| 210 | return fgetxattr(fd, attr, xattrPointer(dest), len(dest), 0, 0) |
| 211 | } |
| 212 | |
| 213 | //sys setxattr(path string, attr string, data *byte, size int, position uint32, options int) (err error) |
| 214 | |
| 215 | func Setxattr(path string, attr string, data []byte, flags int) (err error) { |
| 216 | // The parameters for the OS X implementation vary slightly compared to the |
| 217 | // linux system call, specifically the position parameter: |
| 218 | // |
| 219 | // linux: |
| 220 | // int setxattr( |
| 221 | // const char *path, |
| 222 | // const char *name, |
| 223 | // const void *value, |
| 224 | // size_t size, |
| 225 | // int flags |
| 226 | // ); |
| 227 | // |
| 228 | // darwin: |
| 229 | // int setxattr( |
| 230 | // const char *path, |
| 231 | // const char *name, |
| 232 | // void *value, |
| 233 | // size_t size, |
| 234 | // u_int32_t position, |
| 235 | // int options |
| 236 | // ); |
| 237 | // |
| 238 | // position specifies the offset within the extended attribute. In the |
| 239 | // current implementation, only the resource fork extended attribute makes |
| 240 | // use of this argument. For all others, position is reserved. We simply |
| 241 | // default to setting it to zero. |
| 242 | return setxattr(path, attr, xattrPointer(data), len(data), 0, flags) |
| 243 | } |
| 244 | |
| 245 | func Lsetxattr(link string, attr string, data []byte, flags int) (err error) { |
| 246 | return setxattr(link, attr, xattrPointer(data), len(data), 0, flags|XATTR_NOFOLLOW) |
| 247 | } |
| 248 | |
| 249 | //sys fsetxattr(fd int, attr string, data *byte, size int, position uint32, options int) (err error) |
| 250 | |
| 251 | func Fsetxattr(fd int, attr string, data []byte, flags int) (err error) { |
| 252 | return fsetxattr(fd, attr, xattrPointer(data), len(data), 0, 0) |
| 253 | } |
| 254 | |
| 255 | //sys removexattr(path string, attr string, options int) (err error) |
| 256 | |
| 257 | func Removexattr(path string, attr string) (err error) { |
| 258 | // We wrap around and explicitly zero out the options provided to the OS X |
| 259 | // implementation of removexattr, we do so for interoperability with the |
| 260 | // linux variant. |
| 261 | return removexattr(path, attr, 0) |
| 262 | } |
| 263 | |
| 264 | func Lremovexattr(link string, attr string) (err error) { |
| 265 | return removexattr(link, attr, XATTR_NOFOLLOW) |
| 266 | } |
| 267 | |
| 268 | //sys fremovexattr(fd int, attr string, options int) (err error) |
| 269 | |
| 270 | func Fremovexattr(fd int, attr string) (err error) { |
| 271 | return fremovexattr(fd, attr, 0) |
| 272 | } |
| 273 | |
| 274 | //sys listxattr(path string, dest *byte, size int, options int) (sz int, err error) |
| 275 | |
| 276 | func Listxattr(path string, dest []byte) (sz int, err error) { |
| 277 | return listxattr(path, xattrPointer(dest), len(dest), 0) |
| 278 | } |
| 279 | |
| 280 | func Llistxattr(link string, dest []byte) (sz int, err error) { |
| 281 | return listxattr(link, xattrPointer(dest), len(dest), XATTR_NOFOLLOW) |
| 282 | } |
| 283 | |
| 284 | //sys flistxattr(fd int, dest *byte, size int, options int) (sz int, err error) |
| 285 | |
| 286 | func Flistxattr(fd int, dest []byte) (sz int, err error) { |
| 287 | return flistxattr(fd, xattrPointer(dest), len(dest), 0) |
| 288 | } |
| 289 | |
| 290 | func setattrlistTimes(path string, times []Timespec, flags int) error { |
| 291 | _p0, err := BytePtrFromString(path) |
| 292 | if err != nil { |
| 293 | return err |
| 294 | } |
| 295 | |
| 296 | var attrList attrList |
| 297 | attrList.bitmapCount = ATTR_BIT_MAP_COUNT |
| 298 | attrList.CommonAttr = ATTR_CMN_MODTIME | ATTR_CMN_ACCTIME |
| 299 | |
| 300 | // order is mtime, atime: the opposite of Chtimes |
| 301 | attributes := [2]Timespec{times[1], times[0]} |
| 302 | options := 0 |
| 303 | if flags&AT_SYMLINK_NOFOLLOW != 0 { |
| 304 | options |= FSOPT_NOFOLLOW |
| 305 | } |
| 306 | return setattrlist( |
| 307 | _p0, |
| 308 | unsafe.Pointer(&attrList), |
| 309 | unsafe.Pointer(&attributes), |
| 310 | unsafe.Sizeof(attributes), |
| 311 | options) |
| 312 | } |
| 313 | |
| 314 | //sys setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error) |
| 315 | |
| 316 | func utimensat(dirfd int, path string, times *[2]Timespec, flags int) error { |
| 317 | // Darwin doesn't support SYS_UTIMENSAT |
| 318 | return ENOSYS |
| 319 | } |
| 320 | |
| 321 | /* |
| 322 | * Wrapped |
| 323 | */ |
| 324 | |
| 325 | //sys kill(pid int, signum int, posix int) (err error) |
| 326 | |
| 327 | func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(signum), 1) } |
| 328 | |
| 329 | //sys ioctl(fd int, req uint, arg uintptr) (err error) |
| 330 | |
Girish Gowdra | 161d27a | 2021-05-05 12:01:44 -0700 | [diff] [blame] | 331 | // ioctl itself should not be exposed directly, but additional get/set |
| 332 | // functions for specific types are permissible. |
| 333 | |
| 334 | // IoctlSetInt performs an ioctl operation which sets an integer value |
| 335 | // on fd, using the specified request number. |
| 336 | func IoctlSetInt(fd int, req uint, value int) error { |
| 337 | return ioctl(fd, req, uintptr(value)) |
| 338 | } |
| 339 | |
| 340 | func ioctlSetWinsize(fd int, req uint, value *Winsize) error { |
| 341 | return ioctl(fd, req, uintptr(unsafe.Pointer(value))) |
| 342 | } |
| 343 | |
| 344 | func ioctlSetTermios(fd int, req uint, value *Termios) error { |
| 345 | return ioctl(fd, req, uintptr(unsafe.Pointer(value))) |
| 346 | } |
| 347 | |
| 348 | // IoctlGetInt performs an ioctl operation which gets an integer value |
| 349 | // from fd, using the specified request number. |
| 350 | func IoctlGetInt(fd int, req uint) (int, error) { |
| 351 | var value int |
| 352 | err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) |
| 353 | return value, err |
| 354 | } |
| 355 | |
| 356 | func IoctlGetWinsize(fd int, req uint) (*Winsize, error) { |
| 357 | var value Winsize |
| 358 | err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) |
| 359 | return &value, err |
| 360 | } |
| 361 | |
| 362 | func IoctlGetTermios(fd int, req uint) (*Termios, error) { |
| 363 | var value Termios |
| 364 | err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) |
| 365 | return &value, err |
| 366 | } |
Matteo Scandolo | a6a3aee | 2019-11-26 13:30:14 -0700 | [diff] [blame] | 367 | |
| 368 | func Uname(uname *Utsname) error { |
| 369 | mib := []_C_int{CTL_KERN, KERN_OSTYPE} |
| 370 | n := unsafe.Sizeof(uname.Sysname) |
| 371 | if err := sysctl(mib, &uname.Sysname[0], &n, nil, 0); err != nil { |
| 372 | return err |
| 373 | } |
| 374 | |
| 375 | mib = []_C_int{CTL_KERN, KERN_HOSTNAME} |
| 376 | n = unsafe.Sizeof(uname.Nodename) |
| 377 | if err := sysctl(mib, &uname.Nodename[0], &n, nil, 0); err != nil { |
| 378 | return err |
| 379 | } |
| 380 | |
| 381 | mib = []_C_int{CTL_KERN, KERN_OSRELEASE} |
| 382 | n = unsafe.Sizeof(uname.Release) |
| 383 | if err := sysctl(mib, &uname.Release[0], &n, nil, 0); err != nil { |
| 384 | return err |
| 385 | } |
| 386 | |
| 387 | mib = []_C_int{CTL_KERN, KERN_VERSION} |
| 388 | n = unsafe.Sizeof(uname.Version) |
| 389 | if err := sysctl(mib, &uname.Version[0], &n, nil, 0); err != nil { |
| 390 | return err |
| 391 | } |
| 392 | |
| 393 | // The version might have newlines or tabs in it, convert them to |
| 394 | // spaces. |
| 395 | for i, b := range uname.Version { |
| 396 | if b == '\n' || b == '\t' { |
| 397 | if i == len(uname.Version)-1 { |
| 398 | uname.Version[i] = 0 |
| 399 | } else { |
| 400 | uname.Version[i] = ' ' |
| 401 | } |
| 402 | } |
| 403 | } |
| 404 | |
| 405 | mib = []_C_int{CTL_HW, HW_MACHINE} |
| 406 | n = unsafe.Sizeof(uname.Machine) |
| 407 | if err := sysctl(mib, &uname.Machine[0], &n, nil, 0); err != nil { |
| 408 | return err |
| 409 | } |
| 410 | |
| 411 | return nil |
| 412 | } |
| 413 | |
| 414 | func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { |
| 415 | if raceenabled { |
| 416 | raceReleaseMerge(unsafe.Pointer(&ioSync)) |
| 417 | } |
| 418 | var length = int64(count) |
| 419 | err = sendfile(infd, outfd, *offset, &length, nil, 0) |
| 420 | written = int(length) |
| 421 | return |
| 422 | } |
| 423 | |
| 424 | //sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error) |
| 425 | |
| 426 | /* |
| 427 | * Exposed directly |
| 428 | */ |
| 429 | //sys Access(path string, mode uint32) (err error) |
| 430 | //sys Adjtime(delta *Timeval, olddelta *Timeval) (err error) |
| 431 | //sys Chdir(path string) (err error) |
| 432 | //sys Chflags(path string, flags int) (err error) |
| 433 | //sys Chmod(path string, mode uint32) (err error) |
| 434 | //sys Chown(path string, uid int, gid int) (err error) |
| 435 | //sys Chroot(path string) (err error) |
| 436 | //sys ClockGettime(clockid int32, time *Timespec) (err error) |
| 437 | //sys Close(fd int) (err error) |
| 438 | //sys Dup(fd int) (nfd int, err error) |
| 439 | //sys Dup2(from int, to int) (err error) |
| 440 | //sys Exchangedata(path1 string, path2 string, options int) (err error) |
| 441 | //sys Exit(code int) |
| 442 | //sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error) |
| 443 | //sys Fchdir(fd int) (err error) |
| 444 | //sys Fchflags(fd int, flags int) (err error) |
| 445 | //sys Fchmod(fd int, mode uint32) (err error) |
| 446 | //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) |
| 447 | //sys Fchown(fd int, uid int, gid int) (err error) |
| 448 | //sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) |
| 449 | //sys Flock(fd int, how int) (err error) |
| 450 | //sys Fpathconf(fd int, name int) (val int, err error) |
| 451 | //sys Fsync(fd int) (err error) |
| 452 | //sys Ftruncate(fd int, length int64) (err error) |
| 453 | //sys Getdtablesize() (size int) |
| 454 | //sysnb Getegid() (egid int) |
| 455 | //sysnb Geteuid() (uid int) |
| 456 | //sysnb Getgid() (gid int) |
| 457 | //sysnb Getpgid(pid int) (pgid int, err error) |
| 458 | //sysnb Getpgrp() (pgrp int) |
| 459 | //sysnb Getpid() (pid int) |
| 460 | //sysnb Getppid() (ppid int) |
| 461 | //sys Getpriority(which int, who int) (prio int, err error) |
| 462 | //sysnb Getrlimit(which int, lim *Rlimit) (err error) |
| 463 | //sysnb Getrusage(who int, rusage *Rusage) (err error) |
| 464 | //sysnb Getsid(pid int) (sid int, err error) |
| 465 | //sysnb Getuid() (uid int) |
| 466 | //sysnb Issetugid() (tainted bool) |
| 467 | //sys Kqueue() (fd int, err error) |
| 468 | //sys Lchown(path string, uid int, gid int) (err error) |
| 469 | //sys Link(path string, link string) (err error) |
| 470 | //sys Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error) |
| 471 | //sys Listen(s int, backlog int) (err error) |
| 472 | //sys Mkdir(path string, mode uint32) (err error) |
| 473 | //sys Mkdirat(dirfd int, path string, mode uint32) (err error) |
| 474 | //sys Mkfifo(path string, mode uint32) (err error) |
| 475 | //sys Mknod(path string, mode uint32, dev int) (err error) |
| 476 | //sys Open(path string, mode int, perm uint32) (fd int, err error) |
| 477 | //sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error) |
| 478 | //sys Pathconf(path string, name int) (val int, err error) |
| 479 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) |
| 480 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) |
| 481 | //sys read(fd int, p []byte) (n int, err error) |
| 482 | //sys Readlink(path string, buf []byte) (n int, err error) |
| 483 | //sys Readlinkat(dirfd int, path string, buf []byte) (n int, err error) |
| 484 | //sys Rename(from string, to string) (err error) |
| 485 | //sys Renameat(fromfd int, from string, tofd int, to string) (err error) |
| 486 | //sys Revoke(path string) (err error) |
| 487 | //sys Rmdir(path string) (err error) |
| 488 | //sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK |
Girish Gowdra | 161d27a | 2021-05-05 12:01:44 -0700 | [diff] [blame] | 489 | //sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) |
Matteo Scandolo | a6a3aee | 2019-11-26 13:30:14 -0700 | [diff] [blame] | 490 | //sys Setegid(egid int) (err error) |
| 491 | //sysnb Seteuid(euid int) (err error) |
| 492 | //sysnb Setgid(gid int) (err error) |
| 493 | //sys Setlogin(name string) (err error) |
| 494 | //sysnb Setpgid(pid int, pgid int) (err error) |
| 495 | //sys Setpriority(which int, who int, prio int) (err error) |
| 496 | //sys Setprivexec(flag int) (err error) |
| 497 | //sysnb Setregid(rgid int, egid int) (err error) |
| 498 | //sysnb Setreuid(ruid int, euid int) (err error) |
| 499 | //sysnb Setrlimit(which int, lim *Rlimit) (err error) |
| 500 | //sysnb Setsid() (pid int, err error) |
| 501 | //sysnb Settimeofday(tp *Timeval) (err error) |
| 502 | //sysnb Setuid(uid int) (err error) |
| 503 | //sys Symlink(path string, link string) (err error) |
| 504 | //sys Symlinkat(oldpath string, newdirfd int, newpath string) (err error) |
| 505 | //sys Sync() (err error) |
| 506 | //sys Truncate(path string, length int64) (err error) |
| 507 | //sys Umask(newmask int) (oldmask int) |
| 508 | //sys Undelete(path string) (err error) |
| 509 | //sys Unlink(path string) (err error) |
| 510 | //sys Unlinkat(dirfd int, path string, flags int) (err error) |
| 511 | //sys Unmount(path string, flags int) (err error) |
| 512 | //sys write(fd int, p []byte) (n int, err error) |
| 513 | //sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) |
| 514 | //sys munmap(addr uintptr, length uintptr) (err error) |
| 515 | //sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ |
| 516 | //sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE |
| 517 | |
| 518 | /* |
| 519 | * Unimplemented |
| 520 | */ |
| 521 | // Profil |
| 522 | // Sigaction |
| 523 | // Sigprocmask |
| 524 | // Getlogin |
| 525 | // Sigpending |
| 526 | // Sigaltstack |
| 527 | // Ioctl |
| 528 | // Reboot |
| 529 | // Execve |
| 530 | // Vfork |
| 531 | // Sbrk |
| 532 | // Sstk |
| 533 | // Ovadvise |
| 534 | // Mincore |
| 535 | // Setitimer |
| 536 | // Swapon |
| 537 | // Select |
| 538 | // Sigsuspend |
| 539 | // Readv |
| 540 | // Writev |
| 541 | // Nfssvc |
| 542 | // Getfh |
| 543 | // Quotactl |
| 544 | // Mount |
| 545 | // Csops |
| 546 | // Waitid |
| 547 | // Add_profil |
| 548 | // Kdebug_trace |
| 549 | // Sigreturn |
| 550 | // Atsocket |
| 551 | // Kqueue_from_portset_np |
| 552 | // Kqueue_portset |
| 553 | // Getattrlist |
| 554 | // Setattrlist |
| 555 | // Getdirentriesattr |
| 556 | // Searchfs |
| 557 | // Delete |
| 558 | // Copyfile |
| 559 | // Watchevent |
| 560 | // Waitevent |
| 561 | // Modwatch |
| 562 | // Fsctl |
| 563 | // Initgroups |
| 564 | // Posix_spawn |
| 565 | // Nfsclnt |
| 566 | // Fhopen |
| 567 | // Minherit |
| 568 | // Semsys |
| 569 | // Msgsys |
| 570 | // Shmsys |
| 571 | // Semctl |
| 572 | // Semget |
| 573 | // Semop |
| 574 | // Msgctl |
| 575 | // Msgget |
| 576 | // Msgsnd |
| 577 | // Msgrcv |
| 578 | // Shmat |
| 579 | // Shmctl |
| 580 | // Shmdt |
| 581 | // Shmget |
| 582 | // Shm_open |
| 583 | // Shm_unlink |
| 584 | // Sem_open |
| 585 | // Sem_close |
| 586 | // Sem_unlink |
| 587 | // Sem_wait |
| 588 | // Sem_trywait |
| 589 | // Sem_post |
| 590 | // Sem_getvalue |
| 591 | // Sem_init |
| 592 | // Sem_destroy |
| 593 | // Open_extended |
| 594 | // Umask_extended |
| 595 | // Stat_extended |
| 596 | // Lstat_extended |
| 597 | // Fstat_extended |
| 598 | // Chmod_extended |
| 599 | // Fchmod_extended |
| 600 | // Access_extended |
| 601 | // Settid |
| 602 | // Gettid |
| 603 | // Setsgroups |
| 604 | // Getsgroups |
| 605 | // Setwgroups |
| 606 | // Getwgroups |
| 607 | // Mkfifo_extended |
| 608 | // Mkdir_extended |
| 609 | // Identitysvc |
| 610 | // Shared_region_check_np |
| 611 | // Shared_region_map_np |
| 612 | // __pthread_mutex_destroy |
| 613 | // __pthread_mutex_init |
| 614 | // __pthread_mutex_lock |
| 615 | // __pthread_mutex_trylock |
| 616 | // __pthread_mutex_unlock |
| 617 | // __pthread_cond_init |
| 618 | // __pthread_cond_destroy |
| 619 | // __pthread_cond_broadcast |
| 620 | // __pthread_cond_signal |
| 621 | // Setsid_with_pid |
| 622 | // __pthread_cond_timedwait |
| 623 | // Aio_fsync |
| 624 | // Aio_return |
| 625 | // Aio_suspend |
| 626 | // Aio_cancel |
| 627 | // Aio_error |
| 628 | // Aio_read |
| 629 | // Aio_write |
| 630 | // Lio_listio |
| 631 | // __pthread_cond_wait |
| 632 | // Iopolicysys |
| 633 | // __pthread_kill |
| 634 | // __pthread_sigmask |
| 635 | // __sigwait |
| 636 | // __disable_threadsignal |
| 637 | // __pthread_markcancel |
| 638 | // __pthread_canceled |
| 639 | // __semwait_signal |
| 640 | // Proc_info |
| 641 | // sendfile |
| 642 | // Stat64_extended |
| 643 | // Lstat64_extended |
| 644 | // Fstat64_extended |
| 645 | // __pthread_chdir |
| 646 | // __pthread_fchdir |
| 647 | // Audit |
| 648 | // Auditon |
| 649 | // Getauid |
| 650 | // Setauid |
| 651 | // Getaudit |
| 652 | // Setaudit |
| 653 | // Getaudit_addr |
| 654 | // Setaudit_addr |
| 655 | // Auditctl |
| 656 | // Bsdthread_create |
| 657 | // Bsdthread_terminate |
| 658 | // Stack_snapshot |
| 659 | // Bsdthread_register |
| 660 | // Workq_open |
| 661 | // Workq_ops |
| 662 | // __mac_execve |
| 663 | // __mac_syscall |
| 664 | // __mac_get_file |
| 665 | // __mac_set_file |
| 666 | // __mac_get_link |
| 667 | // __mac_set_link |
| 668 | // __mac_get_proc |
| 669 | // __mac_set_proc |
| 670 | // __mac_get_fd |
| 671 | // __mac_set_fd |
| 672 | // __mac_get_pid |
| 673 | // __mac_get_lcid |
| 674 | // __mac_get_lctx |
| 675 | // __mac_set_lctx |
| 676 | // Setlcid |
| 677 | // Read_nocancel |
| 678 | // Write_nocancel |
| 679 | // Open_nocancel |
| 680 | // Close_nocancel |
| 681 | // Wait4_nocancel |
| 682 | // Recvmsg_nocancel |
| 683 | // Sendmsg_nocancel |
| 684 | // Recvfrom_nocancel |
| 685 | // Accept_nocancel |
| 686 | // Fcntl_nocancel |
| 687 | // Select_nocancel |
| 688 | // Fsync_nocancel |
| 689 | // Connect_nocancel |
| 690 | // Sigsuspend_nocancel |
| 691 | // Readv_nocancel |
| 692 | // Writev_nocancel |
| 693 | // Sendto_nocancel |
| 694 | // Pread_nocancel |
| 695 | // Pwrite_nocancel |
| 696 | // Waitid_nocancel |
| 697 | // Poll_nocancel |
| 698 | // Msgsnd_nocancel |
| 699 | // Msgrcv_nocancel |
| 700 | // Sem_wait_nocancel |
| 701 | // Aio_suspend_nocancel |
| 702 | // __sigwait_nocancel |
| 703 | // __semwait_signal_nocancel |
| 704 | // __mac_mount |
| 705 | // __mac_get_mount |
| 706 | // __mac_getfsstat |