gtsocial-umbx

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README | LICENSE

syscall_darwin.go (24152B)


      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 	"fmt"
     17 	"syscall"
     18 	"unsafe"
     19 )
     20 
     21 //sys	closedir(dir uintptr) (err error)
     22 //sys	readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno)
     23 
     24 func fdopendir(fd int) (dir uintptr, err error) {
     25 	r0, _, e1 := syscall_syscallPtr(libc_fdopendir_trampoline_addr, uintptr(fd), 0, 0)
     26 	dir = uintptr(r0)
     27 	if e1 != 0 {
     28 		err = errnoErr(e1)
     29 	}
     30 	return
     31 }
     32 
     33 var libc_fdopendir_trampoline_addr uintptr
     34 
     35 //go:cgo_import_dynamic libc_fdopendir fdopendir "/usr/lib/libSystem.B.dylib"
     36 
     37 func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
     38 	// Simulate Getdirentries using fdopendir/readdir_r/closedir.
     39 	// We store the number of entries to skip in the seek
     40 	// offset of fd. See issue #31368.
     41 	// It's not the full required semantics, but should handle the case
     42 	// of calling Getdirentries or ReadDirent repeatedly.
     43 	// It won't handle assigning the results of lseek to *basep, or handle
     44 	// the directory being edited underfoot.
     45 	skip, err := Seek(fd, 0, 1 /* SEEK_CUR */)
     46 	if err != nil {
     47 		return 0, err
     48 	}
     49 
     50 	// We need to duplicate the incoming file descriptor
     51 	// because the caller expects to retain control of it, but
     52 	// fdopendir expects to take control of its argument.
     53 	// Just Dup'ing the file descriptor is not enough, as the
     54 	// result shares underlying state. Use Openat to make a really
     55 	// new file descriptor referring to the same directory.
     56 	fd2, err := Openat(fd, ".", O_RDONLY, 0)
     57 	if err != nil {
     58 		return 0, err
     59 	}
     60 	d, err := fdopendir(fd2)
     61 	if err != nil {
     62 		Close(fd2)
     63 		return 0, err
     64 	}
     65 	defer closedir(d)
     66 
     67 	var cnt int64
     68 	for {
     69 		var entry Dirent
     70 		var entryp *Dirent
     71 		e := readdir_r(d, &entry, &entryp)
     72 		if e != 0 {
     73 			return n, errnoErr(e)
     74 		}
     75 		if entryp == nil {
     76 			break
     77 		}
     78 		if skip > 0 {
     79 			skip--
     80 			cnt++
     81 			continue
     82 		}
     83 
     84 		reclen := int(entry.Reclen)
     85 		if reclen > len(buf) {
     86 			// Not enough room. Return for now.
     87 			// The counter will let us know where we should start up again.
     88 			// Note: this strategy for suspending in the middle and
     89 			// restarting is O(n^2) in the length of the directory. Oh well.
     90 			break
     91 		}
     92 
     93 		// Copy entry into return buffer.
     94 		s := unsafe.Slice((*byte)(unsafe.Pointer(&entry)), reclen)
     95 		copy(buf, s)
     96 
     97 		buf = buf[reclen:]
     98 		n += reclen
     99 		cnt++
    100 	}
    101 	// Set the seek offset of the input fd to record
    102 	// how many files we've already returned.
    103 	_, err = Seek(fd, cnt, 0 /* SEEK_SET */)
    104 	if err != nil {
    105 		return n, err
    106 	}
    107 
    108 	return n, nil
    109 }
    110 
    111 // SockaddrDatalink implements the Sockaddr interface for AF_LINK type sockets.
    112 type SockaddrDatalink struct {
    113 	Len    uint8
    114 	Family uint8
    115 	Index  uint16
    116 	Type   uint8
    117 	Nlen   uint8
    118 	Alen   uint8
    119 	Slen   uint8
    120 	Data   [12]int8
    121 	raw    RawSockaddrDatalink
    122 }
    123 
    124 // SockaddrCtl implements the Sockaddr interface for AF_SYSTEM type sockets.
    125 type SockaddrCtl struct {
    126 	ID   uint32
    127 	Unit uint32
    128 	raw  RawSockaddrCtl
    129 }
    130 
    131 func (sa *SockaddrCtl) sockaddr() (unsafe.Pointer, _Socklen, error) {
    132 	sa.raw.Sc_len = SizeofSockaddrCtl
    133 	sa.raw.Sc_family = AF_SYSTEM
    134 	sa.raw.Ss_sysaddr = AF_SYS_CONTROL
    135 	sa.raw.Sc_id = sa.ID
    136 	sa.raw.Sc_unit = sa.Unit
    137 	return unsafe.Pointer(&sa.raw), SizeofSockaddrCtl, nil
    138 }
    139 
    140 // SockaddrVM implements the Sockaddr interface for AF_VSOCK type sockets.
    141 // SockaddrVM provides access to Darwin VM sockets: a mechanism that enables
    142 // bidirectional communication between a hypervisor and its guest virtual
    143 // machines.
    144 type SockaddrVM struct {
    145 	// CID and Port specify a context ID and port address for a VM socket.
    146 	// Guests have a unique CID, and hosts may have a well-known CID of:
    147 	//  - VMADDR_CID_HYPERVISOR: refers to the hypervisor process.
    148 	//  - VMADDR_CID_LOCAL: refers to local communication (loopback).
    149 	//  - VMADDR_CID_HOST: refers to other processes on the host.
    150 	CID  uint32
    151 	Port uint32
    152 	raw  RawSockaddrVM
    153 }
    154 
    155 func (sa *SockaddrVM) sockaddr() (unsafe.Pointer, _Socklen, error) {
    156 	sa.raw.Len = SizeofSockaddrVM
    157 	sa.raw.Family = AF_VSOCK
    158 	sa.raw.Port = sa.Port
    159 	sa.raw.Cid = sa.CID
    160 
    161 	return unsafe.Pointer(&sa.raw), SizeofSockaddrVM, nil
    162 }
    163 
    164 func anyToSockaddrGOOS(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
    165 	switch rsa.Addr.Family {
    166 	case AF_SYSTEM:
    167 		pp := (*RawSockaddrCtl)(unsafe.Pointer(rsa))
    168 		if pp.Ss_sysaddr == AF_SYS_CONTROL {
    169 			sa := new(SockaddrCtl)
    170 			sa.ID = pp.Sc_id
    171 			sa.Unit = pp.Sc_unit
    172 			return sa, nil
    173 		}
    174 	case AF_VSOCK:
    175 		pp := (*RawSockaddrVM)(unsafe.Pointer(rsa))
    176 		sa := &SockaddrVM{
    177 			CID:  pp.Cid,
    178 			Port: pp.Port,
    179 		}
    180 		return sa, nil
    181 	}
    182 	return nil, EAFNOSUPPORT
    183 }
    184 
    185 // Some external packages rely on SYS___SYSCTL being defined to implement their
    186 // own sysctl wrappers. Provide it here, even though direct syscalls are no
    187 // longer supported on darwin.
    188 const SYS___SYSCTL = SYS_SYSCTL
    189 
    190 // Translate "kern.hostname" to []_C_int{0,1,2,3}.
    191 func nametomib(name string) (mib []_C_int, err error) {
    192 	const siz = unsafe.Sizeof(mib[0])
    193 
    194 	// NOTE(rsc): It seems strange to set the buffer to have
    195 	// size CTL_MAXNAME+2 but use only CTL_MAXNAME
    196 	// as the size. I don't know why the +2 is here, but the
    197 	// kernel uses +2 for its own implementation of this function.
    198 	// I am scared that if we don't include the +2 here, the kernel
    199 	// will silently write 2 words farther than we specify
    200 	// and we'll get memory corruption.
    201 	var buf [CTL_MAXNAME + 2]_C_int
    202 	n := uintptr(CTL_MAXNAME) * siz
    203 
    204 	p := (*byte)(unsafe.Pointer(&buf[0]))
    205 	bytes, err := ByteSliceFromString(name)
    206 	if err != nil {
    207 		return nil, err
    208 	}
    209 
    210 	// Magic sysctl: "setting" 0.3 to a string name
    211 	// lets you read back the array of integers form.
    212 	if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil {
    213 		return nil, err
    214 	}
    215 	return buf[0 : n/siz], nil
    216 }
    217 
    218 func direntIno(buf []byte) (uint64, bool) {
    219 	return readInt(buf, unsafe.Offsetof(Dirent{}.Ino), unsafe.Sizeof(Dirent{}.Ino))
    220 }
    221 
    222 func direntReclen(buf []byte) (uint64, bool) {
    223 	return readInt(buf, unsafe.Offsetof(Dirent{}.Reclen), unsafe.Sizeof(Dirent{}.Reclen))
    224 }
    225 
    226 func direntNamlen(buf []byte) (uint64, bool) {
    227 	return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
    228 }
    229 
    230 func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) }
    231 func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) }
    232 func PtraceDenyAttach() (err error)    { return ptrace(PT_DENY_ATTACH, 0, 0, 0) }
    233 
    234 //sysnb	pipe(p *[2]int32) (err error)
    235 
    236 func Pipe(p []int) (err error) {
    237 	if len(p) != 2 {
    238 		return EINVAL
    239 	}
    240 	var x [2]int32
    241 	err = pipe(&x)
    242 	if err == nil {
    243 		p[0] = int(x[0])
    244 		p[1] = int(x[1])
    245 	}
    246 	return
    247 }
    248 
    249 func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
    250 	var _p0 unsafe.Pointer
    251 	var bufsize uintptr
    252 	if len(buf) > 0 {
    253 		_p0 = unsafe.Pointer(&buf[0])
    254 		bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
    255 	}
    256 	return getfsstat(_p0, bufsize, flags)
    257 }
    258 
    259 func xattrPointer(dest []byte) *byte {
    260 	// It's only when dest is set to NULL that the OS X implementations of
    261 	// getxattr() and listxattr() return the current sizes of the named attributes.
    262 	// An empty byte array is not sufficient. To maintain the same behaviour as the
    263 	// linux implementation, we wrap around the system calls and pass in NULL when
    264 	// dest is empty.
    265 	var destp *byte
    266 	if len(dest) > 0 {
    267 		destp = &dest[0]
    268 	}
    269 	return destp
    270 }
    271 
    272 //sys	getxattr(path string, attr string, dest *byte, size int, position uint32, options int) (sz int, err error)
    273 
    274 func Getxattr(path string, attr string, dest []byte) (sz int, err error) {
    275 	return getxattr(path, attr, xattrPointer(dest), len(dest), 0, 0)
    276 }
    277 
    278 func Lgetxattr(link string, attr string, dest []byte) (sz int, err error) {
    279 	return getxattr(link, attr, xattrPointer(dest), len(dest), 0, XATTR_NOFOLLOW)
    280 }
    281 
    282 //sys	fgetxattr(fd int, attr string, dest *byte, size int, position uint32, options int) (sz int, err error)
    283 
    284 func Fgetxattr(fd int, attr string, dest []byte) (sz int, err error) {
    285 	return fgetxattr(fd, attr, xattrPointer(dest), len(dest), 0, 0)
    286 }
    287 
    288 //sys	setxattr(path string, attr string, data *byte, size int, position uint32, options int) (err error)
    289 
    290 func Setxattr(path string, attr string, data []byte, flags int) (err error) {
    291 	// The parameters for the OS X implementation vary slightly compared to the
    292 	// linux system call, specifically the position parameter:
    293 	//
    294 	//  linux:
    295 	//      int setxattr(
    296 	//          const char *path,
    297 	//          const char *name,
    298 	//          const void *value,
    299 	//          size_t size,
    300 	//          int flags
    301 	//      );
    302 	//
    303 	//  darwin:
    304 	//      int setxattr(
    305 	//          const char *path,
    306 	//          const char *name,
    307 	//          void *value,
    308 	//          size_t size,
    309 	//          u_int32_t position,
    310 	//          int options
    311 	//      );
    312 	//
    313 	// position specifies the offset within the extended attribute. In the
    314 	// current implementation, only the resource fork extended attribute makes
    315 	// use of this argument. For all others, position is reserved. We simply
    316 	// default to setting it to zero.
    317 	return setxattr(path, attr, xattrPointer(data), len(data), 0, flags)
    318 }
    319 
    320 func Lsetxattr(link string, attr string, data []byte, flags int) (err error) {
    321 	return setxattr(link, attr, xattrPointer(data), len(data), 0, flags|XATTR_NOFOLLOW)
    322 }
    323 
    324 //sys	fsetxattr(fd int, attr string, data *byte, size int, position uint32, options int) (err error)
    325 
    326 func Fsetxattr(fd int, attr string, data []byte, flags int) (err error) {
    327 	return fsetxattr(fd, attr, xattrPointer(data), len(data), 0, 0)
    328 }
    329 
    330 //sys	removexattr(path string, attr string, options int) (err error)
    331 
    332 func Removexattr(path string, attr string) (err error) {
    333 	// We wrap around and explicitly zero out the options provided to the OS X
    334 	// implementation of removexattr, we do so for interoperability with the
    335 	// linux variant.
    336 	return removexattr(path, attr, 0)
    337 }
    338 
    339 func Lremovexattr(link string, attr string) (err error) {
    340 	return removexattr(link, attr, XATTR_NOFOLLOW)
    341 }
    342 
    343 //sys	fremovexattr(fd int, attr string, options int) (err error)
    344 
    345 func Fremovexattr(fd int, attr string) (err error) {
    346 	return fremovexattr(fd, attr, 0)
    347 }
    348 
    349 //sys	listxattr(path string, dest *byte, size int, options int) (sz int, err error)
    350 
    351 func Listxattr(path string, dest []byte) (sz int, err error) {
    352 	return listxattr(path, xattrPointer(dest), len(dest), 0)
    353 }
    354 
    355 func Llistxattr(link string, dest []byte) (sz int, err error) {
    356 	return listxattr(link, xattrPointer(dest), len(dest), XATTR_NOFOLLOW)
    357 }
    358 
    359 //sys	flistxattr(fd int, dest *byte, size int, options int) (sz int, err error)
    360 
    361 func Flistxattr(fd int, dest []byte) (sz int, err error) {
    362 	return flistxattr(fd, xattrPointer(dest), len(dest), 0)
    363 }
    364 
    365 //sys	utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error)
    366 
    367 /*
    368  * Wrapped
    369  */
    370 
    371 //sys	fcntl(fd int, cmd int, arg int) (val int, err error)
    372 
    373 //sys	kill(pid int, signum int, posix int) (err error)
    374 
    375 func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(signum), 1) }
    376 
    377 //sys	ioctl(fd int, req uint, arg uintptr) (err error)
    378 //sys	ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) = SYS_IOCTL
    379 
    380 func IoctlCtlInfo(fd int, ctlInfo *CtlInfo) error {
    381 	return ioctlPtr(fd, CTLIOCGINFO, unsafe.Pointer(ctlInfo))
    382 }
    383 
    384 // IfreqMTU is struct ifreq used to get or set a network device's MTU.
    385 type IfreqMTU struct {
    386 	Name [IFNAMSIZ]byte
    387 	MTU  int32
    388 }
    389 
    390 // IoctlGetIfreqMTU performs the SIOCGIFMTU ioctl operation on fd to get the MTU
    391 // of the network device specified by ifname.
    392 func IoctlGetIfreqMTU(fd int, ifname string) (*IfreqMTU, error) {
    393 	var ifreq IfreqMTU
    394 	copy(ifreq.Name[:], ifname)
    395 	err := ioctlPtr(fd, SIOCGIFMTU, unsafe.Pointer(&ifreq))
    396 	return &ifreq, err
    397 }
    398 
    399 // IoctlSetIfreqMTU performs the SIOCSIFMTU ioctl operation on fd to set the MTU
    400 // of the network device specified by ifreq.Name.
    401 func IoctlSetIfreqMTU(fd int, ifreq *IfreqMTU) error {
    402 	return ioctlPtr(fd, SIOCSIFMTU, unsafe.Pointer(ifreq))
    403 }
    404 
    405 //sys	sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL
    406 
    407 func Uname(uname *Utsname) error {
    408 	mib := []_C_int{CTL_KERN, KERN_OSTYPE}
    409 	n := unsafe.Sizeof(uname.Sysname)
    410 	if err := sysctl(mib, &uname.Sysname[0], &n, nil, 0); err != nil {
    411 		return err
    412 	}
    413 
    414 	mib = []_C_int{CTL_KERN, KERN_HOSTNAME}
    415 	n = unsafe.Sizeof(uname.Nodename)
    416 	if err := sysctl(mib, &uname.Nodename[0], &n, nil, 0); err != nil {
    417 		return err
    418 	}
    419 
    420 	mib = []_C_int{CTL_KERN, KERN_OSRELEASE}
    421 	n = unsafe.Sizeof(uname.Release)
    422 	if err := sysctl(mib, &uname.Release[0], &n, nil, 0); err != nil {
    423 		return err
    424 	}
    425 
    426 	mib = []_C_int{CTL_KERN, KERN_VERSION}
    427 	n = unsafe.Sizeof(uname.Version)
    428 	if err := sysctl(mib, &uname.Version[0], &n, nil, 0); err != nil {
    429 		return err
    430 	}
    431 
    432 	// The version might have newlines or tabs in it, convert them to
    433 	// spaces.
    434 	for i, b := range uname.Version {
    435 		if b == '\n' || b == '\t' {
    436 			if i == len(uname.Version)-1 {
    437 				uname.Version[i] = 0
    438 			} else {
    439 				uname.Version[i] = ' '
    440 			}
    441 		}
    442 	}
    443 
    444 	mib = []_C_int{CTL_HW, HW_MACHINE}
    445 	n = unsafe.Sizeof(uname.Machine)
    446 	if err := sysctl(mib, &uname.Machine[0], &n, nil, 0); err != nil {
    447 		return err
    448 	}
    449 
    450 	return nil
    451 }
    452 
    453 func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
    454 	if raceenabled {
    455 		raceReleaseMerge(unsafe.Pointer(&ioSync))
    456 	}
    457 	var length = int64(count)
    458 	err = sendfile(infd, outfd, *offset, &length, nil, 0)
    459 	written = int(length)
    460 	return
    461 }
    462 
    463 func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) {
    464 	var value IPMreqn
    465 	vallen := _Socklen(SizeofIPMreqn)
    466 	errno := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
    467 	return &value, errno
    468 }
    469 
    470 func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) {
    471 	return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq))
    472 }
    473 
    474 // GetsockoptXucred is a getsockopt wrapper that returns an Xucred struct.
    475 // The usual level and opt are SOL_LOCAL and LOCAL_PEERCRED, respectively.
    476 func GetsockoptXucred(fd, level, opt int) (*Xucred, error) {
    477 	x := new(Xucred)
    478 	vallen := _Socklen(SizeofXucred)
    479 	err := getsockopt(fd, level, opt, unsafe.Pointer(x), &vallen)
    480 	return x, err
    481 }
    482 
    483 func GetsockoptTCPConnectionInfo(fd, level, opt int) (*TCPConnectionInfo, error) {
    484 	var value TCPConnectionInfo
    485 	vallen := _Socklen(SizeofTCPConnectionInfo)
    486 	err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
    487 	return &value, err
    488 }
    489 
    490 func SysctlKinfoProc(name string, args ...int) (*KinfoProc, error) {
    491 	mib, err := sysctlmib(name, args...)
    492 	if err != nil {
    493 		return nil, err
    494 	}
    495 
    496 	var kinfo KinfoProc
    497 	n := uintptr(SizeofKinfoProc)
    498 	if err := sysctl(mib, (*byte)(unsafe.Pointer(&kinfo)), &n, nil, 0); err != nil {
    499 		return nil, err
    500 	}
    501 	if n != SizeofKinfoProc {
    502 		return nil, EIO
    503 	}
    504 	return &kinfo, nil
    505 }
    506 
    507 func SysctlKinfoProcSlice(name string, args ...int) ([]KinfoProc, error) {
    508 	mib, err := sysctlmib(name, args...)
    509 	if err != nil {
    510 		return nil, err
    511 	}
    512 
    513 	// Find size.
    514 	n := uintptr(0)
    515 	if err := sysctl(mib, nil, &n, nil, 0); err != nil {
    516 		return nil, err
    517 	}
    518 	if n == 0 {
    519 		return nil, nil
    520 	}
    521 	if n%SizeofKinfoProc != 0 {
    522 		return nil, fmt.Errorf("sysctl() returned a size of %d, which is not a multiple of %d", n, SizeofKinfoProc)
    523 	}
    524 
    525 	// Read into buffer of that size.
    526 	buf := make([]KinfoProc, n/SizeofKinfoProc)
    527 	if err := sysctl(mib, (*byte)(unsafe.Pointer(&buf[0])), &n, nil, 0); err != nil {
    528 		return nil, err
    529 	}
    530 	if n%SizeofKinfoProc != 0 {
    531 		return nil, fmt.Errorf("sysctl() returned a size of %d, which is not a multiple of %d", n, SizeofKinfoProc)
    532 	}
    533 
    534 	// The actual call may return less than the original reported required
    535 	// size so ensure we deal with that.
    536 	return buf[:n/SizeofKinfoProc], nil
    537 }
    538 
    539 //sys	sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error)
    540 
    541 //sys	shmat(id int, addr uintptr, flag int) (ret uintptr, err error)
    542 //sys	shmctl(id int, cmd int, buf *SysvShmDesc) (result int, err error)
    543 //sys	shmdt(addr uintptr) (err error)
    544 //sys	shmget(key int, size int, flag int) (id int, err error)
    545 
    546 /*
    547  * Exposed directly
    548  */
    549 //sys	Access(path string, mode uint32) (err error)
    550 //sys	Adjtime(delta *Timeval, olddelta *Timeval) (err error)
    551 //sys	Chdir(path string) (err error)
    552 //sys	Chflags(path string, flags int) (err error)
    553 //sys	Chmod(path string, mode uint32) (err error)
    554 //sys	Chown(path string, uid int, gid int) (err error)
    555 //sys	Chroot(path string) (err error)
    556 //sys	ClockGettime(clockid int32, time *Timespec) (err error)
    557 //sys	Close(fd int) (err error)
    558 //sys	Clonefile(src string, dst string, flags int) (err error)
    559 //sys	Clonefileat(srcDirfd int, src string, dstDirfd int, dst string, flags int) (err error)
    560 //sys	Dup(fd int) (nfd int, err error)
    561 //sys	Dup2(from int, to int) (err error)
    562 //sys	Exchangedata(path1 string, path2 string, options int) (err error)
    563 //sys	Exit(code int)
    564 //sys	Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
    565 //sys	Fchdir(fd int) (err error)
    566 //sys	Fchflags(fd int, flags int) (err error)
    567 //sys	Fchmod(fd int, mode uint32) (err error)
    568 //sys	Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
    569 //sys	Fchown(fd int, uid int, gid int) (err error)
    570 //sys	Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
    571 //sys	Fclonefileat(srcDirfd int, dstDirfd int, dst string, flags int) (err error)
    572 //sys	Flock(fd int, how int) (err error)
    573 //sys	Fpathconf(fd int, name int) (val int, err error)
    574 //sys	Fsync(fd int) (err error)
    575 //sys	Ftruncate(fd int, length int64) (err error)
    576 //sys	Getcwd(buf []byte) (n int, err error)
    577 //sys	Getdtablesize() (size int)
    578 //sysnb	Getegid() (egid int)
    579 //sysnb	Geteuid() (uid int)
    580 //sysnb	Getgid() (gid int)
    581 //sysnb	Getpgid(pid int) (pgid int, err error)
    582 //sysnb	Getpgrp() (pgrp int)
    583 //sysnb	Getpid() (pid int)
    584 //sysnb	Getppid() (ppid int)
    585 //sys	Getpriority(which int, who int) (prio int, err error)
    586 //sysnb	Getrlimit(which int, lim *Rlimit) (err error)
    587 //sysnb	Getrusage(who int, rusage *Rusage) (err error)
    588 //sysnb	Getsid(pid int) (sid int, err error)
    589 //sysnb	Gettimeofday(tp *Timeval) (err error)
    590 //sysnb	Getuid() (uid int)
    591 //sysnb	Issetugid() (tainted bool)
    592 //sys	Kqueue() (fd int, err error)
    593 //sys	Lchown(path string, uid int, gid int) (err error)
    594 //sys	Link(path string, link string) (err error)
    595 //sys	Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error)
    596 //sys	Listen(s int, backlog int) (err error)
    597 //sys	Mkdir(path string, mode uint32) (err error)
    598 //sys	Mkdirat(dirfd int, path string, mode uint32) (err error)
    599 //sys	Mkfifo(path string, mode uint32) (err error)
    600 //sys	Mknod(path string, mode uint32, dev int) (err error)
    601 //sys	Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error)
    602 //sys	Open(path string, mode int, perm uint32) (fd int, err error)
    603 //sys	Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error)
    604 //sys	Pathconf(path string, name int) (val int, err error)
    605 //sys	pread(fd int, p []byte, offset int64) (n int, err error)
    606 //sys	pwrite(fd int, p []byte, offset int64) (n int, err error)
    607 //sys	read(fd int, p []byte) (n int, err error)
    608 //sys	Readlink(path string, buf []byte) (n int, err error)
    609 //sys	Readlinkat(dirfd int, path string, buf []byte) (n int, err error)
    610 //sys	Rename(from string, to string) (err error)
    611 //sys	Renameat(fromfd int, from string, tofd int, to string) (err error)
    612 //sys	Revoke(path string) (err error)
    613 //sys	Rmdir(path string) (err error)
    614 //sys	Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
    615 //sys	Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
    616 //sys	Setattrlist(path string, attrlist *Attrlist, attrBuf []byte, options int) (err error)
    617 //sys	Setegid(egid int) (err error)
    618 //sysnb	Seteuid(euid int) (err error)
    619 //sysnb	Setgid(gid int) (err error)
    620 //sys	Setlogin(name string) (err error)
    621 //sysnb	Setpgid(pid int, pgid int) (err error)
    622 //sys	Setpriority(which int, who int, prio int) (err error)
    623 //sys	Setprivexec(flag int) (err error)
    624 //sysnb	Setregid(rgid int, egid int) (err error)
    625 //sysnb	Setreuid(ruid int, euid int) (err error)
    626 //sysnb	Setsid() (pid int, err error)
    627 //sysnb	Settimeofday(tp *Timeval) (err error)
    628 //sysnb	Setuid(uid int) (err error)
    629 //sys	Symlink(path string, link string) (err error)
    630 //sys	Symlinkat(oldpath string, newdirfd int, newpath string) (err error)
    631 //sys	Sync() (err error)
    632 //sys	Truncate(path string, length int64) (err error)
    633 //sys	Umask(newmask int) (oldmask int)
    634 //sys	Undelete(path string) (err error)
    635 //sys	Unlink(path string) (err error)
    636 //sys	Unlinkat(dirfd int, path string, flags int) (err error)
    637 //sys	Unmount(path string, flags int) (err error)
    638 //sys	write(fd int, p []byte) (n int, err error)
    639 //sys	mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
    640 //sys	munmap(addr uintptr, length uintptr) (err error)
    641 //sys	readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
    642 //sys	writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
    643 
    644 /*
    645  * Unimplemented
    646  */
    647 // Profil
    648 // Sigaction
    649 // Sigprocmask
    650 // Getlogin
    651 // Sigpending
    652 // Sigaltstack
    653 // Ioctl
    654 // Reboot
    655 // Execve
    656 // Vfork
    657 // Sbrk
    658 // Sstk
    659 // Ovadvise
    660 // Mincore
    661 // Setitimer
    662 // Swapon
    663 // Select
    664 // Sigsuspend
    665 // Readv
    666 // Writev
    667 // Nfssvc
    668 // Getfh
    669 // Quotactl
    670 // Csops
    671 // Waitid
    672 // Add_profil
    673 // Kdebug_trace
    674 // Sigreturn
    675 // Atsocket
    676 // Kqueue_from_portset_np
    677 // Kqueue_portset
    678 // Getattrlist
    679 // Getdirentriesattr
    680 // Searchfs
    681 // Delete
    682 // Copyfile
    683 // Watchevent
    684 // Waitevent
    685 // Modwatch
    686 // Fsctl
    687 // Initgroups
    688 // Posix_spawn
    689 // Nfsclnt
    690 // Fhopen
    691 // Minherit
    692 // Semsys
    693 // Msgsys
    694 // Shmsys
    695 // Semctl
    696 // Semget
    697 // Semop
    698 // Msgctl
    699 // Msgget
    700 // Msgsnd
    701 // Msgrcv
    702 // Shm_open
    703 // Shm_unlink
    704 // Sem_open
    705 // Sem_close
    706 // Sem_unlink
    707 // Sem_wait
    708 // Sem_trywait
    709 // Sem_post
    710 // Sem_getvalue
    711 // Sem_init
    712 // Sem_destroy
    713 // Open_extended
    714 // Umask_extended
    715 // Stat_extended
    716 // Lstat_extended
    717 // Fstat_extended
    718 // Chmod_extended
    719 // Fchmod_extended
    720 // Access_extended
    721 // Settid
    722 // Gettid
    723 // Setsgroups
    724 // Getsgroups
    725 // Setwgroups
    726 // Getwgroups
    727 // Mkfifo_extended
    728 // Mkdir_extended
    729 // Identitysvc
    730 // Shared_region_check_np
    731 // Shared_region_map_np
    732 // __pthread_mutex_destroy
    733 // __pthread_mutex_init
    734 // __pthread_mutex_lock
    735 // __pthread_mutex_trylock
    736 // __pthread_mutex_unlock
    737 // __pthread_cond_init
    738 // __pthread_cond_destroy
    739 // __pthread_cond_broadcast
    740 // __pthread_cond_signal
    741 // Setsid_with_pid
    742 // __pthread_cond_timedwait
    743 // Aio_fsync
    744 // Aio_return
    745 // Aio_suspend
    746 // Aio_cancel
    747 // Aio_error
    748 // Aio_read
    749 // Aio_write
    750 // Lio_listio
    751 // __pthread_cond_wait
    752 // Iopolicysys
    753 // __pthread_kill
    754 // __pthread_sigmask
    755 // __sigwait
    756 // __disable_threadsignal
    757 // __pthread_markcancel
    758 // __pthread_canceled
    759 // __semwait_signal
    760 // Proc_info
    761 // sendfile
    762 // Stat64_extended
    763 // Lstat64_extended
    764 // Fstat64_extended
    765 // __pthread_chdir
    766 // __pthread_fchdir
    767 // Audit
    768 // Auditon
    769 // Getauid
    770 // Setauid
    771 // Getaudit
    772 // Setaudit
    773 // Getaudit_addr
    774 // Setaudit_addr
    775 // Auditctl
    776 // Bsdthread_create
    777 // Bsdthread_terminate
    778 // Stack_snapshot
    779 // Bsdthread_register
    780 // Workq_open
    781 // Workq_ops
    782 // __mac_execve
    783 // __mac_syscall
    784 // __mac_get_file
    785 // __mac_set_file
    786 // __mac_get_link
    787 // __mac_set_link
    788 // __mac_get_proc
    789 // __mac_set_proc
    790 // __mac_get_fd
    791 // __mac_set_fd
    792 // __mac_get_pid
    793 // __mac_get_lcid
    794 // __mac_get_lctx
    795 // __mac_set_lctx
    796 // Setlcid
    797 // Read_nocancel
    798 // Write_nocancel
    799 // Open_nocancel
    800 // Close_nocancel
    801 // Wait4_nocancel
    802 // Recvmsg_nocancel
    803 // Sendmsg_nocancel
    804 // Recvfrom_nocancel
    805 // Accept_nocancel
    806 // Fcntl_nocancel
    807 // Select_nocancel
    808 // Fsync_nocancel
    809 // Connect_nocancel
    810 // Sigsuspend_nocancel
    811 // Readv_nocancel
    812 // Writev_nocancel
    813 // Sendto_nocancel
    814 // Pread_nocancel
    815 // Pwrite_nocancel
    816 // Waitid_nocancel
    817 // Poll_nocancel
    818 // Msgsnd_nocancel
    819 // Msgrcv_nocancel
    820 // Sem_wait_nocancel
    821 // Aio_suspend_nocancel
    822 // __sigwait_nocancel
    823 // __semwait_signal_nocancel
    824 // __mac_mount
    825 // __mac_get_mount
    826 // __mac_getfsstat