github.com/giovannyortegon/go@v0.0.0-20220115155912-8890063f5bdd/src/pkg/mod/golang.org/x/sys@v0.0.0-20210927094055-39ccf1dd6fa6/unix/syscall_darwin.go (about)

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