Source file src/cmd/vendor/golang.org/x/sys/unix/syscall_freebsd.go

     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  // FreeBSD 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  	"sync"
    17  	"unsafe"
    18  )
    19  
    20  const (
    21  	SYS_FSTAT_FREEBSD12         = 551 // { int fstat(int fd, _Out_ struct stat *sb); }
    22  	SYS_FSTATAT_FREEBSD12       = 552 // { int fstatat(int fd, _In_z_ char *path, \
    23  	SYS_GETDIRENTRIES_FREEBSD12 = 554 // { ssize_t getdirentries(int fd, \
    24  	SYS_STATFS_FREEBSD12        = 555 // { int statfs(_In_z_ char *path, \
    25  	SYS_FSTATFS_FREEBSD12       = 556 // { int fstatfs(int fd, \
    26  	SYS_GETFSSTAT_FREEBSD12     = 557 // { int getfsstat( \
    27  	SYS_MKNODAT_FREEBSD12       = 559 // { int mknodat(int fd, _In_z_ char *path, \
    28  )
    29  
    30  // See https://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/versions.html.
    31  var (
    32  	osreldateOnce sync.Once
    33  	osreldate     uint32
    34  )
    35  
    36  // INO64_FIRST from /usr/src/lib/libc/sys/compat-ino64.h
    37  const _ino64First = 1200031
    38  
    39  func supportsABI(ver uint32) bool {
    40  	osreldateOnce.Do(func() { osreldate, _ = SysctlUint32("kern.osreldate") })
    41  	return osreldate >= ver
    42  }
    43  
    44  // SockaddrDatalink implements the Sockaddr interface for AF_LINK type sockets.
    45  type SockaddrDatalink struct {
    46  	Len    uint8
    47  	Family uint8
    48  	Index  uint16
    49  	Type   uint8
    50  	Nlen   uint8
    51  	Alen   uint8
    52  	Slen   uint8
    53  	Data   [46]int8
    54  	raw    RawSockaddrDatalink
    55  }
    56  
    57  func anyToSockaddrGOOS(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
    58  	return nil, EAFNOSUPPORT
    59  }
    60  
    61  // Translate "kern.hostname" to []_C_int{0,1,2,3}.
    62  func nametomib(name string) (mib []_C_int, err error) {
    63  	const siz = unsafe.Sizeof(mib[0])
    64  
    65  	// NOTE(rsc): It seems strange to set the buffer to have
    66  	// size CTL_MAXNAME+2 but use only CTL_MAXNAME
    67  	// as the size. I don't know why the +2 is here, but the
    68  	// kernel uses +2 for its own implementation of this function.
    69  	// I am scared that if we don't include the +2 here, the kernel
    70  	// will silently write 2 words farther than we specify
    71  	// and we'll get memory corruption.
    72  	var buf [CTL_MAXNAME + 2]_C_int
    73  	n := uintptr(CTL_MAXNAME) * siz
    74  
    75  	p := (*byte)(unsafe.Pointer(&buf[0]))
    76  	bytes, err := ByteSliceFromString(name)
    77  	if err != nil {
    78  		return nil, err
    79  	}
    80  
    81  	// Magic sysctl: "setting" 0.3 to a string name
    82  	// lets you read back the array of integers form.
    83  	if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil {
    84  		return nil, err
    85  	}
    86  	return buf[0 : n/siz], nil
    87  }
    88  
    89  func direntIno(buf []byte) (uint64, bool) {
    90  	return readInt(buf, unsafe.Offsetof(Dirent{}.Fileno), unsafe.Sizeof(Dirent{}.Fileno))
    91  }
    92  
    93  func direntReclen(buf []byte) (uint64, bool) {
    94  	return readInt(buf, unsafe.Offsetof(Dirent{}.Reclen), unsafe.Sizeof(Dirent{}.Reclen))
    95  }
    96  
    97  func direntNamlen(buf []byte) (uint64, bool) {
    98  	return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
    99  }
   100  
   101  func Pipe(p []int) (err error) {
   102  	return Pipe2(p, 0)
   103  }
   104  
   105  //sysnb	pipe2(p *[2]_C_int, flags int) (err error)
   106  
   107  func Pipe2(p []int, flags int) error {
   108  	if len(p) != 2 {
   109  		return EINVAL
   110  	}
   111  	var pp [2]_C_int
   112  	err := pipe2(&pp, flags)
   113  	p[0] = int(pp[0])
   114  	p[1] = int(pp[1])
   115  	return err
   116  }
   117  
   118  func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) {
   119  	var value IPMreqn
   120  	vallen := _Socklen(SizeofIPMreqn)
   121  	errno := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
   122  	return &value, errno
   123  }
   124  
   125  func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) {
   126  	return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq))
   127  }
   128  
   129  // GetsockoptXucred is a getsockopt wrapper that returns an Xucred struct.
   130  // The usual level and opt are SOL_LOCAL and LOCAL_PEERCRED, respectively.
   131  func GetsockoptXucred(fd, level, opt int) (*Xucred, error) {
   132  	x := new(Xucred)
   133  	vallen := _Socklen(SizeofXucred)
   134  	err := getsockopt(fd, level, opt, unsafe.Pointer(x), &vallen)
   135  	return x, err
   136  }
   137  
   138  func Accept4(fd, flags int) (nfd int, sa Sockaddr, err error) {
   139  	var rsa RawSockaddrAny
   140  	var len _Socklen = SizeofSockaddrAny
   141  	nfd, err = accept4(fd, &rsa, &len, flags)
   142  	if err != nil {
   143  		return
   144  	}
   145  	if len > SizeofSockaddrAny {
   146  		panic("RawSockaddrAny too small")
   147  	}
   148  	sa, err = anyToSockaddr(fd, &rsa)
   149  	if err != nil {
   150  		Close(nfd)
   151  		nfd = 0
   152  	}
   153  	return
   154  }
   155  
   156  //sys	Getcwd(buf []byte) (n int, err error) = SYS___GETCWD
   157  
   158  func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
   159  	var (
   160  		_p0          unsafe.Pointer
   161  		bufsize      uintptr
   162  		oldBuf       []statfs_freebsd11_t
   163  		needsConvert bool
   164  	)
   165  
   166  	if len(buf) > 0 {
   167  		if supportsABI(_ino64First) {
   168  			_p0 = unsafe.Pointer(&buf[0])
   169  			bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
   170  		} else {
   171  			n := len(buf)
   172  			oldBuf = make([]statfs_freebsd11_t, n)
   173  			_p0 = unsafe.Pointer(&oldBuf[0])
   174  			bufsize = unsafe.Sizeof(statfs_freebsd11_t{}) * uintptr(n)
   175  			needsConvert = true
   176  		}
   177  	}
   178  	var sysno uintptr = SYS_GETFSSTAT
   179  	if supportsABI(_ino64First) {
   180  		sysno = SYS_GETFSSTAT_FREEBSD12
   181  	}
   182  	r0, _, e1 := Syscall(sysno, uintptr(_p0), bufsize, uintptr(flags))
   183  	n = int(r0)
   184  	if e1 != 0 {
   185  		err = e1
   186  	}
   187  	if e1 == 0 && needsConvert {
   188  		for i := range oldBuf {
   189  			buf[i].convertFrom(&oldBuf[i])
   190  		}
   191  	}
   192  	return
   193  }
   194  
   195  func setattrlistTimes(path string, times []Timespec, flags int) error {
   196  	// used on Darwin for UtimesNano
   197  	return ENOSYS
   198  }
   199  
   200  //sys	ioctl(fd int, req uint, arg uintptr) (err error)
   201  
   202  //sys	sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL
   203  
   204  func Uname(uname *Utsname) error {
   205  	mib := []_C_int{CTL_KERN, KERN_OSTYPE}
   206  	n := unsafe.Sizeof(uname.Sysname)
   207  	if err := sysctl(mib, &uname.Sysname[0], &n, nil, 0); err != nil {
   208  		return err
   209  	}
   210  
   211  	mib = []_C_int{CTL_KERN, KERN_HOSTNAME}
   212  	n = unsafe.Sizeof(uname.Nodename)
   213  	if err := sysctl(mib, &uname.Nodename[0], &n, nil, 0); err != nil {
   214  		return err
   215  	}
   216  
   217  	mib = []_C_int{CTL_KERN, KERN_OSRELEASE}
   218  	n = unsafe.Sizeof(uname.Release)
   219  	if err := sysctl(mib, &uname.Release[0], &n, nil, 0); err != nil {
   220  		return err
   221  	}
   222  
   223  	mib = []_C_int{CTL_KERN, KERN_VERSION}
   224  	n = unsafe.Sizeof(uname.Version)
   225  	if err := sysctl(mib, &uname.Version[0], &n, nil, 0); err != nil {
   226  		return err
   227  	}
   228  
   229  	// The version might have newlines or tabs in it, convert them to
   230  	// spaces.
   231  	for i, b := range uname.Version {
   232  		if b == '\n' || b == '\t' {
   233  			if i == len(uname.Version)-1 {
   234  				uname.Version[i] = 0
   235  			} else {
   236  				uname.Version[i] = ' '
   237  			}
   238  		}
   239  	}
   240  
   241  	mib = []_C_int{CTL_HW, HW_MACHINE}
   242  	n = unsafe.Sizeof(uname.Machine)
   243  	if err := sysctl(mib, &uname.Machine[0], &n, nil, 0); err != nil {
   244  		return err
   245  	}
   246  
   247  	return nil
   248  }
   249  
   250  func Stat(path string, st *Stat_t) (err error) {
   251  	var oldStat stat_freebsd11_t
   252  	if supportsABI(_ino64First) {
   253  		return fstatat_freebsd12(AT_FDCWD, path, st, 0)
   254  	}
   255  	err = stat(path, &oldStat)
   256  	if err != nil {
   257  		return err
   258  	}
   259  
   260  	st.convertFrom(&oldStat)
   261  	return nil
   262  }
   263  
   264  func Lstat(path string, st *Stat_t) (err error) {
   265  	var oldStat stat_freebsd11_t
   266  	if supportsABI(_ino64First) {
   267  		return fstatat_freebsd12(AT_FDCWD, path, st, AT_SYMLINK_NOFOLLOW)
   268  	}
   269  	err = lstat(path, &oldStat)
   270  	if err != nil {
   271  		return err
   272  	}
   273  
   274  	st.convertFrom(&oldStat)
   275  	return nil
   276  }
   277  
   278  func Fstat(fd int, st *Stat_t) (err error) {
   279  	var oldStat stat_freebsd11_t
   280  	if supportsABI(_ino64First) {
   281  		return fstat_freebsd12(fd, st)
   282  	}
   283  	err = fstat(fd, &oldStat)
   284  	if err != nil {
   285  		return err
   286  	}
   287  
   288  	st.convertFrom(&oldStat)
   289  	return nil
   290  }
   291  
   292  func Fstatat(fd int, path string, st *Stat_t, flags int) (err error) {
   293  	var oldStat stat_freebsd11_t
   294  	if supportsABI(_ino64First) {
   295  		return fstatat_freebsd12(fd, path, st, flags)
   296  	}
   297  	err = fstatat(fd, path, &oldStat, flags)
   298  	if err != nil {
   299  		return err
   300  	}
   301  
   302  	st.convertFrom(&oldStat)
   303  	return nil
   304  }
   305  
   306  func Statfs(path string, st *Statfs_t) (err error) {
   307  	var oldStatfs statfs_freebsd11_t
   308  	if supportsABI(_ino64First) {
   309  		return statfs_freebsd12(path, st)
   310  	}
   311  	err = statfs(path, &oldStatfs)
   312  	if err != nil {
   313  		return err
   314  	}
   315  
   316  	st.convertFrom(&oldStatfs)
   317  	return nil
   318  }
   319  
   320  func Fstatfs(fd int, st *Statfs_t) (err error) {
   321  	var oldStatfs statfs_freebsd11_t
   322  	if supportsABI(_ino64First) {
   323  		return fstatfs_freebsd12(fd, st)
   324  	}
   325  	err = fstatfs(fd, &oldStatfs)
   326  	if err != nil {
   327  		return err
   328  	}
   329  
   330  	st.convertFrom(&oldStatfs)
   331  	return nil
   332  }
   333  
   334  func Getdents(fd int, buf []byte) (n int, err error) {
   335  	return Getdirentries(fd, buf, nil)
   336  }
   337  
   338  func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
   339  	if supportsABI(_ino64First) {
   340  		if basep == nil || unsafe.Sizeof(*basep) == 8 {
   341  			return getdirentries_freebsd12(fd, buf, (*uint64)(unsafe.Pointer(basep)))
   342  		}
   343  		// The freebsd12 syscall needs a 64-bit base. On 32-bit machines
   344  		// we can't just use the basep passed in. See #32498.
   345  		var base uint64 = uint64(*basep)
   346  		n, err = getdirentries_freebsd12(fd, buf, &base)
   347  		*basep = uintptr(base)
   348  		if base>>32 != 0 {
   349  			// We can't stuff the base back into a uintptr, so any
   350  			// future calls would be suspect. Generate an error.
   351  			// EIO is allowed by getdirentries.
   352  			err = EIO
   353  		}
   354  		return
   355  	}
   356  
   357  	// The old syscall entries are smaller than the new. Use 1/4 of the original
   358  	// buffer size rounded up to DIRBLKSIZ (see /usr/src/lib/libc/sys/getdirentries.c).
   359  	oldBufLen := roundup(len(buf)/4, _dirblksiz)
   360  	oldBuf := make([]byte, oldBufLen)
   361  	n, err = getdirentries(fd, oldBuf, basep)
   362  	if err == nil && n > 0 {
   363  		n = convertFromDirents11(buf, oldBuf[:n])
   364  	}
   365  	return
   366  }
   367  
   368  func Mknod(path string, mode uint32, dev uint64) (err error) {
   369  	var oldDev int
   370  	if supportsABI(_ino64First) {
   371  		return mknodat_freebsd12(AT_FDCWD, path, mode, dev)
   372  	}
   373  	oldDev = int(dev)
   374  	return mknod(path, mode, oldDev)
   375  }
   376  
   377  func Mknodat(fd int, path string, mode uint32, dev uint64) (err error) {
   378  	var oldDev int
   379  	if supportsABI(_ino64First) {
   380  		return mknodat_freebsd12(fd, path, mode, dev)
   381  	}
   382  	oldDev = int(dev)
   383  	return mknodat(fd, path, mode, oldDev)
   384  }
   385  
   386  // round x to the nearest multiple of y, larger or equal to x.
   387  //
   388  // from /usr/include/sys/param.h Macros for counting and rounding.
   389  // #define roundup(x, y)   ((((x)+((y)-1))/(y))*(y))
   390  func roundup(x, y int) int {
   391  	return ((x + y - 1) / y) * y
   392  }
   393  
   394  func (s *Stat_t) convertFrom(old *stat_freebsd11_t) {
   395  	*s = Stat_t{
   396  		Dev:     uint64(old.Dev),
   397  		Ino:     uint64(old.Ino),
   398  		Nlink:   uint64(old.Nlink),
   399  		Mode:    old.Mode,
   400  		Uid:     old.Uid,
   401  		Gid:     old.Gid,
   402  		Rdev:    uint64(old.Rdev),
   403  		Atim:    old.Atim,
   404  		Mtim:    old.Mtim,
   405  		Ctim:    old.Ctim,
   406  		Btim:    old.Btim,
   407  		Size:    old.Size,
   408  		Blocks:  old.Blocks,
   409  		Blksize: old.Blksize,
   410  		Flags:   old.Flags,
   411  		Gen:     uint64(old.Gen),
   412  	}
   413  }
   414  
   415  func (s *Statfs_t) convertFrom(old *statfs_freebsd11_t) {
   416  	*s = Statfs_t{
   417  		Version:     _statfsVersion,
   418  		Type:        old.Type,
   419  		Flags:       old.Flags,
   420  		Bsize:       old.Bsize,
   421  		Iosize:      old.Iosize,
   422  		Blocks:      old.Blocks,
   423  		Bfree:       old.Bfree,
   424  		Bavail:      old.Bavail,
   425  		Files:       old.Files,
   426  		Ffree:       old.Ffree,
   427  		Syncwrites:  old.Syncwrites,
   428  		Asyncwrites: old.Asyncwrites,
   429  		Syncreads:   old.Syncreads,
   430  		Asyncreads:  old.Asyncreads,
   431  		// Spare
   432  		Namemax: old.Namemax,
   433  		Owner:   old.Owner,
   434  		Fsid:    old.Fsid,
   435  		// Charspare
   436  		// Fstypename
   437  		// Mntfromname
   438  		// Mntonname
   439  	}
   440  
   441  	sl := old.Fstypename[:]
   442  	n := clen(*(*[]byte)(unsafe.Pointer(&sl)))
   443  	copy(s.Fstypename[:], old.Fstypename[:n])
   444  
   445  	sl = old.Mntfromname[:]
   446  	n = clen(*(*[]byte)(unsafe.Pointer(&sl)))
   447  	copy(s.Mntfromname[:], old.Mntfromname[:n])
   448  
   449  	sl = old.Mntonname[:]
   450  	n = clen(*(*[]byte)(unsafe.Pointer(&sl)))
   451  	copy(s.Mntonname[:], old.Mntonname[:n])
   452  }
   453  
   454  func convertFromDirents11(buf []byte, old []byte) int {
   455  	const (
   456  		fixedSize    = int(unsafe.Offsetof(Dirent{}.Name))
   457  		oldFixedSize = int(unsafe.Offsetof(dirent_freebsd11{}.Name))
   458  	)
   459  
   460  	dstPos := 0
   461  	srcPos := 0
   462  	for dstPos+fixedSize < len(buf) && srcPos+oldFixedSize < len(old) {
   463  		var dstDirent Dirent
   464  		var srcDirent dirent_freebsd11
   465  
   466  		// If multiple direntries are written, sometimes when we reach the final one,
   467  		// we may have cap of old less than size of dirent_freebsd11.
   468  		copy((*[unsafe.Sizeof(srcDirent)]byte)(unsafe.Pointer(&srcDirent))[:], old[srcPos:])
   469  
   470  		reclen := roundup(fixedSize+int(srcDirent.Namlen)+1, 8)
   471  		if dstPos+reclen > len(buf) {
   472  			break
   473  		}
   474  
   475  		dstDirent.Fileno = uint64(srcDirent.Fileno)
   476  		dstDirent.Off = 0
   477  		dstDirent.Reclen = uint16(reclen)
   478  		dstDirent.Type = srcDirent.Type
   479  		dstDirent.Pad0 = 0
   480  		dstDirent.Namlen = uint16(srcDirent.Namlen)
   481  		dstDirent.Pad1 = 0
   482  
   483  		copy(dstDirent.Name[:], srcDirent.Name[:srcDirent.Namlen])
   484  		copy(buf[dstPos:], (*[unsafe.Sizeof(dstDirent)]byte)(unsafe.Pointer(&dstDirent))[:])
   485  		padding := buf[dstPos+fixedSize+int(dstDirent.Namlen) : dstPos+reclen]
   486  		for i := range padding {
   487  			padding[i] = 0
   488  		}
   489  
   490  		dstPos += int(dstDirent.Reclen)
   491  		srcPos += int(srcDirent.Reclen)
   492  	}
   493  
   494  	return dstPos
   495  }
   496  
   497  func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
   498  	if raceenabled {
   499  		raceReleaseMerge(unsafe.Pointer(&ioSync))
   500  	}
   501  	return sendfile(outfd, infd, offset, count)
   502  }
   503  
   504  //sys	ptrace(request int, pid int, addr uintptr, data int) (err error)
   505  
   506  func PtraceAttach(pid int) (err error) {
   507  	return ptrace(PTRACE_ATTACH, pid, 0, 0)
   508  }
   509  
   510  func PtraceCont(pid int, signal int) (err error) {
   511  	return ptrace(PTRACE_CONT, pid, 1, signal)
   512  }
   513  
   514  func PtraceDetach(pid int) (err error) {
   515  	return ptrace(PTRACE_DETACH, pid, 1, 0)
   516  }
   517  
   518  func PtraceGetFpRegs(pid int, fpregsout *FpReg) (err error) {
   519  	return ptrace(PTRACE_GETFPREGS, pid, uintptr(unsafe.Pointer(fpregsout)), 0)
   520  }
   521  
   522  func PtraceGetRegs(pid int, regsout *Reg) (err error) {
   523  	return ptrace(PTRACE_GETREGS, pid, uintptr(unsafe.Pointer(regsout)), 0)
   524  }
   525  
   526  func PtraceLwpEvents(pid int, enable int) (err error) {
   527  	return ptrace(PTRACE_LWPEVENTS, pid, 0, enable)
   528  }
   529  
   530  func PtraceLwpInfo(pid int, info uintptr) (err error) {
   531  	return ptrace(PTRACE_LWPINFO, pid, info, int(unsafe.Sizeof(PtraceLwpInfoStruct{})))
   532  }
   533  
   534  func PtracePeekData(pid int, addr uintptr, out []byte) (count int, err error) {
   535  	return PtraceIO(PIOD_READ_D, pid, addr, out, SizeofLong)
   536  }
   537  
   538  func PtracePeekText(pid int, addr uintptr, out []byte) (count int, err error) {
   539  	return PtraceIO(PIOD_READ_I, pid, addr, out, SizeofLong)
   540  }
   541  
   542  func PtracePokeData(pid int, addr uintptr, data []byte) (count int, err error) {
   543  	return PtraceIO(PIOD_WRITE_D, pid, addr, data, SizeofLong)
   544  }
   545  
   546  func PtracePokeText(pid int, addr uintptr, data []byte) (count int, err error) {
   547  	return PtraceIO(PIOD_WRITE_I, pid, addr, data, SizeofLong)
   548  }
   549  
   550  func PtraceSetRegs(pid int, regs *Reg) (err error) {
   551  	return ptrace(PTRACE_SETREGS, pid, uintptr(unsafe.Pointer(regs)), 0)
   552  }
   553  
   554  func PtraceSingleStep(pid int) (err error) {
   555  	return ptrace(PTRACE_SINGLESTEP, pid, 1, 0)
   556  }
   557  
   558  /*
   559   * Exposed directly
   560   */
   561  //sys	Access(path string, mode uint32) (err error)
   562  //sys	Adjtime(delta *Timeval, olddelta *Timeval) (err error)
   563  //sys	CapEnter() (err error)
   564  //sys	capRightsGet(version int, fd int, rightsp *CapRights) (err error) = SYS___CAP_RIGHTS_GET
   565  //sys	capRightsLimit(fd int, rightsp *CapRights) (err error)
   566  //sys	Chdir(path string) (err error)
   567  //sys	Chflags(path string, flags int) (err error)
   568  //sys	Chmod(path string, mode uint32) (err error)
   569  //sys	Chown(path string, uid int, gid int) (err error)
   570  //sys	Chroot(path string) (err error)
   571  //sys	Close(fd int) (err error)
   572  //sys	Dup(fd int) (nfd int, err error)
   573  //sys	Dup2(from int, to int) (err error)
   574  //sys	Exit(code int)
   575  //sys	ExtattrGetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
   576  //sys	ExtattrSetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
   577  //sys	ExtattrDeleteFd(fd int, attrnamespace int, attrname string) (err error)
   578  //sys	ExtattrListFd(fd int, attrnamespace int, data uintptr, nbytes int) (ret int, err error)
   579  //sys	ExtattrGetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
   580  //sys	ExtattrSetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
   581  //sys	ExtattrDeleteFile(file string, attrnamespace int, attrname string) (err error)
   582  //sys	ExtattrListFile(file string, attrnamespace int, data uintptr, nbytes int) (ret int, err error)
   583  //sys	ExtattrGetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
   584  //sys	ExtattrSetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
   585  //sys	ExtattrDeleteLink(link string, attrnamespace int, attrname string) (err error)
   586  //sys	ExtattrListLink(link string, attrnamespace int, data uintptr, nbytes int) (ret int, err error)
   587  //sys	Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_POSIX_FADVISE
   588  //sys	Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
   589  //sys	Fchdir(fd int) (err error)
   590  //sys	Fchflags(fd int, flags int) (err error)
   591  //sys	Fchmod(fd int, mode uint32) (err error)
   592  //sys	Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
   593  //sys	Fchown(fd int, uid int, gid int) (err error)
   594  //sys	Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
   595  //sys	Flock(fd int, how int) (err error)
   596  //sys	Fpathconf(fd int, name int) (val int, err error)
   597  //sys	fstat(fd int, stat *stat_freebsd11_t) (err error)
   598  //sys	fstat_freebsd12(fd int, stat *Stat_t) (err error)
   599  //sys	fstatat(fd int, path string, stat *stat_freebsd11_t, flags int) (err error)
   600  //sys	fstatat_freebsd12(fd int, path string, stat *Stat_t, flags int) (err error)
   601  //sys	fstatfs(fd int, stat *statfs_freebsd11_t) (err error)
   602  //sys	fstatfs_freebsd12(fd int, stat *Statfs_t) (err error)
   603  //sys	Fsync(fd int) (err error)
   604  //sys	Ftruncate(fd int, length int64) (err error)
   605  //sys	getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error)
   606  //sys	getdirentries_freebsd12(fd int, buf []byte, basep *uint64) (n int, err error)
   607  //sys	Getdtablesize() (size int)
   608  //sysnb	Getegid() (egid int)
   609  //sysnb	Geteuid() (uid int)
   610  //sysnb	Getgid() (gid int)
   611  //sysnb	Getpgid(pid int) (pgid int, err error)
   612  //sysnb	Getpgrp() (pgrp int)
   613  //sysnb	Getpid() (pid int)
   614  //sysnb	Getppid() (ppid int)
   615  //sys	Getpriority(which int, who int) (prio int, err error)
   616  //sysnb	Getrlimit(which int, lim *Rlimit) (err error)
   617  //sysnb	Getrusage(who int, rusage *Rusage) (err error)
   618  //sysnb	Getsid(pid int) (sid int, err error)
   619  //sysnb	Gettimeofday(tv *Timeval) (err error)
   620  //sysnb	Getuid() (uid int)
   621  //sys	Issetugid() (tainted bool)
   622  //sys	Kill(pid int, signum syscall.Signal) (err error)
   623  //sys	Kqueue() (fd int, err error)
   624  //sys	Lchown(path string, uid int, gid int) (err error)
   625  //sys	Link(path string, link string) (err error)
   626  //sys	Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error)
   627  //sys	Listen(s int, backlog int) (err error)
   628  //sys	lstat(path string, stat *stat_freebsd11_t) (err error)
   629  //sys	Mkdir(path string, mode uint32) (err error)
   630  //sys	Mkdirat(dirfd int, path string, mode uint32) (err error)
   631  //sys	Mkfifo(path string, mode uint32) (err error)
   632  //sys	mknod(path string, mode uint32, dev int) (err error)
   633  //sys	mknodat(fd int, path string, mode uint32, dev int) (err error)
   634  //sys	mknodat_freebsd12(fd int, path string, mode uint32, dev uint64) (err error)
   635  //sys	Nanosleep(time *Timespec, leftover *Timespec) (err error)
   636  //sys	Open(path string, mode int, perm uint32) (fd int, err error)
   637  //sys	Openat(fdat int, path string, mode int, perm uint32) (fd int, err error)
   638  //sys	Pathconf(path string, name int) (val int, err error)
   639  //sys	Pread(fd int, p []byte, offset int64) (n int, err error)
   640  //sys	Pwrite(fd int, p []byte, offset int64) (n int, err error)
   641  //sys	read(fd int, p []byte) (n int, err error)
   642  //sys	Readlink(path string, buf []byte) (n int, err error)
   643  //sys	Readlinkat(dirfd int, path string, buf []byte) (n int, err error)
   644  //sys	Rename(from string, to string) (err error)
   645  //sys	Renameat(fromfd int, from string, tofd int, to string) (err error)
   646  //sys	Revoke(path string) (err error)
   647  //sys	Rmdir(path string) (err error)
   648  //sys	Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
   649  //sys	Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
   650  //sysnb	Setegid(egid int) (err error)
   651  //sysnb	Seteuid(euid int) (err error)
   652  //sysnb	Setgid(gid int) (err error)
   653  //sys	Setlogin(name string) (err error)
   654  //sysnb	Setpgid(pid int, pgid int) (err error)
   655  //sys	Setpriority(which int, who int, prio int) (err error)
   656  //sysnb	Setregid(rgid int, egid int) (err error)
   657  //sysnb	Setreuid(ruid int, euid int) (err error)
   658  //sysnb	Setresgid(rgid int, egid int, sgid int) (err error)
   659  //sysnb	Setresuid(ruid int, euid int, suid int) (err error)
   660  //sysnb	Setrlimit(which int, lim *Rlimit) (err error)
   661  //sysnb	Setsid() (pid int, err error)
   662  //sysnb	Settimeofday(tp *Timeval) (err error)
   663  //sysnb	Setuid(uid int) (err error)
   664  //sys	stat(path string, stat *stat_freebsd11_t) (err error)
   665  //sys	statfs(path string, stat *statfs_freebsd11_t) (err error)
   666  //sys	statfs_freebsd12(path string, stat *Statfs_t) (err error)
   667  //sys	Symlink(path string, link string) (err error)
   668  //sys	Symlinkat(oldpath string, newdirfd int, newpath string) (err error)
   669  //sys	Sync() (err error)
   670  //sys	Truncate(path string, length int64) (err error)
   671  //sys	Umask(newmask int) (oldmask int)
   672  //sys	Undelete(path string) (err error)
   673  //sys	Unlink(path string) (err error)
   674  //sys	Unlinkat(dirfd int, path string, flags int) (err error)
   675  //sys	Unmount(path string, flags int) (err error)
   676  //sys	write(fd int, p []byte) (n int, err error)
   677  //sys	mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
   678  //sys	munmap(addr uintptr, length uintptr) (err error)
   679  //sys	readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
   680  //sys	writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
   681  //sys	accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error)
   682  //sys	utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error)
   683  
   684  /*
   685   * Unimplemented
   686   */
   687  // Profil
   688  // Sigaction
   689  // Sigprocmask
   690  // Getlogin
   691  // Sigpending
   692  // Sigaltstack
   693  // Ioctl
   694  // Reboot
   695  // Execve
   696  // Vfork
   697  // Sbrk
   698  // Sstk
   699  // Ovadvise
   700  // Mincore
   701  // Setitimer
   702  // Swapon
   703  // Select
   704  // Sigsuspend
   705  // Readv
   706  // Writev
   707  // Nfssvc
   708  // Getfh
   709  // Quotactl
   710  // Mount
   711  // Csops
   712  // Waitid
   713  // Add_profil
   714  // Kdebug_trace
   715  // Sigreturn
   716  // Atsocket
   717  // Kqueue_from_portset_np
   718  // Kqueue_portset
   719  // Getattrlist
   720  // Setattrlist
   721  // Getdents
   722  // Getdirentriesattr
   723  // Searchfs
   724  // Delete
   725  // Copyfile
   726  // Watchevent
   727  // Waitevent
   728  // Modwatch
   729  // Fsctl
   730  // Initgroups
   731  // Posix_spawn
   732  // Nfsclnt
   733  // Fhopen
   734  // Minherit
   735  // Semsys
   736  // Msgsys
   737  // Shmsys
   738  // Semctl
   739  // Semget
   740  // Semop
   741  // Msgctl
   742  // Msgget
   743  // Msgsnd
   744  // Msgrcv
   745  // Shmat
   746  // Shmctl
   747  // Shmdt
   748  // Shmget
   749  // Shm_open
   750  // Shm_unlink
   751  // Sem_open
   752  // Sem_close
   753  // Sem_unlink
   754  // Sem_wait
   755  // Sem_trywait
   756  // Sem_post
   757  // Sem_getvalue
   758  // Sem_init
   759  // Sem_destroy
   760  // Open_extended
   761  // Umask_extended
   762  // Stat_extended
   763  // Lstat_extended
   764  // Fstat_extended
   765  // Chmod_extended
   766  // Fchmod_extended
   767  // Access_extended
   768  // Settid
   769  // Gettid
   770  // Setsgroups
   771  // Getsgroups
   772  // Setwgroups
   773  // Getwgroups
   774  // Mkfifo_extended
   775  // Mkdir_extended
   776  // Identitysvc
   777  // Shared_region_check_np
   778  // Shared_region_map_np
   779  // __pthread_mutex_destroy
   780  // __pthread_mutex_init
   781  // __pthread_mutex_lock
   782  // __pthread_mutex_trylock
   783  // __pthread_mutex_unlock
   784  // __pthread_cond_init
   785  // __pthread_cond_destroy
   786  // __pthread_cond_broadcast
   787  // __pthread_cond_signal
   788  // Setsid_with_pid
   789  // __pthread_cond_timedwait
   790  // Aio_fsync
   791  // Aio_return
   792  // Aio_suspend
   793  // Aio_cancel
   794  // Aio_error
   795  // Aio_read
   796  // Aio_write
   797  // Lio_listio
   798  // __pthread_cond_wait
   799  // Iopolicysys
   800  // __pthread_kill
   801  // __pthread_sigmask
   802  // __sigwait
   803  // __disable_threadsignal
   804  // __pthread_markcancel
   805  // __pthread_canceled
   806  // __semwait_signal
   807  // Proc_info
   808  // Stat64_extended
   809  // Lstat64_extended
   810  // Fstat64_extended
   811  // __pthread_chdir
   812  // __pthread_fchdir
   813  // Audit
   814  // Auditon
   815  // Getauid
   816  // Setauid
   817  // Getaudit
   818  // Setaudit
   819  // Getaudit_addr
   820  // Setaudit_addr
   821  // Auditctl
   822  // Bsdthread_create
   823  // Bsdthread_terminate
   824  // Stack_snapshot
   825  // Bsdthread_register
   826  // Workq_open
   827  // Workq_ops
   828  // __mac_execve
   829  // __mac_syscall
   830  // __mac_get_file
   831  // __mac_set_file
   832  // __mac_get_link
   833  // __mac_set_link
   834  // __mac_get_proc
   835  // __mac_set_proc
   836  // __mac_get_fd
   837  // __mac_set_fd
   838  // __mac_get_pid
   839  // __mac_get_lcid
   840  // __mac_get_lctx
   841  // __mac_set_lctx
   842  // Setlcid
   843  // Read_nocancel
   844  // Write_nocancel
   845  // Open_nocancel
   846  // Close_nocancel
   847  // Wait4_nocancel
   848  // Recvmsg_nocancel
   849  // Sendmsg_nocancel
   850  // Recvfrom_nocancel
   851  // Accept_nocancel
   852  // Fcntl_nocancel
   853  // Select_nocancel
   854  // Fsync_nocancel
   855  // Connect_nocancel
   856  // Sigsuspend_nocancel
   857  // Readv_nocancel
   858  // Writev_nocancel
   859  // Sendto_nocancel
   860  // Pread_nocancel
   861  // Pwrite_nocancel
   862  // Waitid_nocancel
   863  // Poll_nocancel
   864  // Msgsnd_nocancel
   865  // Msgrcv_nocancel
   866  // Sem_wait_nocancel
   867  // Aio_suspend_nocancel
   868  // __sigwait_nocancel
   869  // __semwait_signal_nocancel
   870  // __mac_mount
   871  // __mac_get_mount
   872  // __mac_getfsstat
   873  

View as plain text