github.com/Andyfoo/golang/x/sys@v0.0.0-20190901054642-57c1bf301704/unix/syscall_freebsd.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 // 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 // Translate "kern.hostname" to []_C_int{0,1,2,3}. 58 func nametomib(name string) (mib []_C_int, err error) { 59 const siz = unsafe.Sizeof(mib[0]) 60 61 // NOTE(rsc): It seems strange to set the buffer to have 62 // size CTL_MAXNAME+2 but use only CTL_MAXNAME 63 // as the size. I don't know why the +2 is here, but the 64 // kernel uses +2 for its own implementation of this function. 65 // I am scared that if we don't include the +2 here, the kernel 66 // will silently write 2 words farther than we specify 67 // and we'll get memory corruption. 68 var buf [CTL_MAXNAME + 2]_C_int 69 n := uintptr(CTL_MAXNAME) * siz 70 71 p := (*byte)(unsafe.Pointer(&buf[0])) 72 bytes, err := ByteSliceFromString(name) 73 if err != nil { 74 return nil, err 75 } 76 77 // Magic sysctl: "setting" 0.3 to a string name 78 // lets you read back the array of integers form. 79 if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil { 80 return nil, err 81 } 82 return buf[0 : n/siz], nil 83 } 84 85 func direntIno(buf []byte) (uint64, bool) { 86 return readInt(buf, unsafe.Offsetof(Dirent{}.Fileno), unsafe.Sizeof(Dirent{}.Fileno)) 87 } 88 89 func direntReclen(buf []byte) (uint64, bool) { 90 return readInt(buf, unsafe.Offsetof(Dirent{}.Reclen), unsafe.Sizeof(Dirent{}.Reclen)) 91 } 92 93 func direntNamlen(buf []byte) (uint64, bool) { 94 return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen)) 95 } 96 97 func Pipe(p []int) (err error) { 98 return Pipe2(p, 0) 99 } 100 101 //sysnb pipe2(p *[2]_C_int, flags int) (err error) 102 103 func Pipe2(p []int, flags int) error { 104 if len(p) != 2 { 105 return EINVAL 106 } 107 var pp [2]_C_int 108 err := pipe2(&pp, flags) 109 p[0] = int(pp[0]) 110 p[1] = int(pp[1]) 111 return err 112 } 113 114 func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) { 115 var value IPMreqn 116 vallen := _Socklen(SizeofIPMreqn) 117 errno := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen) 118 return &value, errno 119 } 120 121 func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) { 122 return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq)) 123 } 124 125 func Accept4(fd, flags int) (nfd int, sa Sockaddr, err error) { 126 var rsa RawSockaddrAny 127 var len _Socklen = SizeofSockaddrAny 128 nfd, err = accept4(fd, &rsa, &len, flags) 129 if err != nil { 130 return 131 } 132 if len > SizeofSockaddrAny { 133 panic("RawSockaddrAny too small") 134 } 135 sa, err = anyToSockaddr(fd, &rsa) 136 if err != nil { 137 Close(nfd) 138 nfd = 0 139 } 140 return 141 } 142 143 const ImplementsGetwd = true 144 145 //sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD 146 147 func Getwd() (string, error) { 148 var buf [PathMax]byte 149 _, err := Getcwd(buf[0:]) 150 if err != nil { 151 return "", err 152 } 153 n := clen(buf[:]) 154 if n < 1 { 155 return "", EINVAL 156 } 157 return string(buf[:n]), nil 158 } 159 160 func Getfsstat(buf []Statfs_t, flags int) (n int, err error) { 161 var ( 162 _p0 unsafe.Pointer 163 bufsize uintptr 164 oldBuf []statfs_freebsd11_t 165 needsConvert bool 166 ) 167 168 if len(buf) > 0 { 169 if supportsABI(_ino64First) { 170 _p0 = unsafe.Pointer(&buf[0]) 171 bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf)) 172 } else { 173 n := len(buf) 174 oldBuf = make([]statfs_freebsd11_t, n) 175 _p0 = unsafe.Pointer(&oldBuf[0]) 176 bufsize = unsafe.Sizeof(statfs_freebsd11_t{}) * uintptr(n) 177 needsConvert = true 178 } 179 } 180 var sysno uintptr = SYS_GETFSSTAT 181 if supportsABI(_ino64First) { 182 sysno = SYS_GETFSSTAT_FREEBSD12 183 } 184 r0, _, e1 := Syscall(sysno, uintptr(_p0), bufsize, uintptr(flags)) 185 n = int(r0) 186 if e1 != 0 { 187 err = e1 188 } 189 if e1 == 0 && needsConvert { 190 for i := range oldBuf { 191 buf[i].convertFrom(&oldBuf[i]) 192 } 193 } 194 return 195 } 196 197 func setattrlistTimes(path string, times []Timespec, flags int) error { 198 // used on Darwin for UtimesNano 199 return ENOSYS 200 } 201 202 //sys ioctl(fd int, req uint, arg uintptr) (err error) 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 dstDirent := (*Dirent)(unsafe.Pointer(&buf[dstPos])) 464 srcDirent := (*dirent_freebsd11)(unsafe.Pointer(&old[srcPos])) 465 466 reclen := roundup(fixedSize+int(srcDirent.Namlen)+1, 8) 467 if dstPos+reclen > len(buf) { 468 break 469 } 470 471 dstDirent.Fileno = uint64(srcDirent.Fileno) 472 dstDirent.Off = 0 473 dstDirent.Reclen = uint16(reclen) 474 dstDirent.Type = srcDirent.Type 475 dstDirent.Pad0 = 0 476 dstDirent.Namlen = uint16(srcDirent.Namlen) 477 dstDirent.Pad1 = 0 478 479 copy(dstDirent.Name[:], srcDirent.Name[:srcDirent.Namlen]) 480 padding := buf[dstPos+fixedSize+int(dstDirent.Namlen) : dstPos+reclen] 481 for i := range padding { 482 padding[i] = 0 483 } 484 485 dstPos += int(dstDirent.Reclen) 486 srcPos += int(srcDirent.Reclen) 487 } 488 489 return dstPos 490 } 491 492 func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { 493 if raceenabled { 494 raceReleaseMerge(unsafe.Pointer(&ioSync)) 495 } 496 return sendfile(outfd, infd, offset, count) 497 } 498 499 //sys ptrace(request int, pid int, addr uintptr, data int) (err error) 500 501 func PtraceAttach(pid int) (err error) { 502 return ptrace(PTRACE_ATTACH, pid, 0, 0) 503 } 504 505 func PtraceCont(pid int, signal int) (err error) { 506 return ptrace(PTRACE_CONT, pid, 1, signal) 507 } 508 509 func PtraceDetach(pid int) (err error) { 510 return ptrace(PTRACE_DETACH, pid, 1, 0) 511 } 512 513 func PtraceGetFpRegs(pid int, fpregsout *FpReg) (err error) { 514 return ptrace(PTRACE_GETFPREGS, pid, uintptr(unsafe.Pointer(fpregsout)), 0) 515 } 516 517 func PtraceGetFsBase(pid int, fsbase *int64) (err error) { 518 return ptrace(PTRACE_GETFSBASE, pid, uintptr(unsafe.Pointer(fsbase)), 0) 519 } 520 521 func PtraceGetRegs(pid int, regsout *Reg) (err error) { 522 return ptrace(PTRACE_GETREGS, pid, uintptr(unsafe.Pointer(regsout)), 0) 523 } 524 525 func PtraceIO(req int, pid int, addr uintptr, out []byte, countin int) (count int, err error) { 526 ioDesc := PtraceIoDesc{Op: int32(req), Offs: (*byte)(unsafe.Pointer(addr)), Addr: (*byte)(unsafe.Pointer(&out[0])), Len: uint(countin)} 527 err = ptrace(PTRACE_IO, pid, uintptr(unsafe.Pointer(&ioDesc)), 0) 528 return int(ioDesc.Len), err 529 } 530 531 func PtraceLwpEvents(pid int, enable int) (err error) { 532 return ptrace(PTRACE_LWPEVENTS, pid, 0, enable) 533 } 534 535 func PtraceLwpInfo(pid int, info uintptr) (err error) { 536 return ptrace(PTRACE_LWPINFO, pid, info, int(unsafe.Sizeof(PtraceLwpInfoStruct{}))) 537 } 538 539 func PtracePeekData(pid int, addr uintptr, out []byte) (count int, err error) { 540 return PtraceIO(PIOD_READ_D, pid, addr, out, SizeofLong) 541 } 542 543 func PtracePeekText(pid int, addr uintptr, out []byte) (count int, err error) { 544 return PtraceIO(PIOD_READ_I, pid, addr, out, SizeofLong) 545 } 546 547 func PtracePokeData(pid int, addr uintptr, data []byte) (count int, err error) { 548 return PtraceIO(PIOD_WRITE_D, pid, addr, data, SizeofLong) 549 } 550 551 func PtracePokeText(pid int, addr uintptr, data []byte) (count int, err error) { 552 return PtraceIO(PIOD_WRITE_I, pid, addr, data, SizeofLong) 553 } 554 555 func PtraceSetRegs(pid int, regs *Reg) (err error) { 556 return ptrace(PTRACE_SETREGS, pid, uintptr(unsafe.Pointer(regs)), 0) 557 } 558 559 func PtraceSingleStep(pid int) (err error) { 560 return ptrace(PTRACE_SINGLESTEP, pid, 1, 0) 561 } 562 563 /* 564 * Exposed directly 565 */ 566 //sys Access(path string, mode uint32) (err error) 567 //sys Adjtime(delta *Timeval, olddelta *Timeval) (err error) 568 //sys CapEnter() (err error) 569 //sys capRightsGet(version int, fd int, rightsp *CapRights) (err error) = SYS___CAP_RIGHTS_GET 570 //sys capRightsLimit(fd int, rightsp *CapRights) (err error) 571 //sys Chdir(path string) (err error) 572 //sys Chflags(path string, flags int) (err error) 573 //sys Chmod(path string, mode uint32) (err error) 574 //sys Chown(path string, uid int, gid int) (err error) 575 //sys Chroot(path string) (err error) 576 //sys Close(fd int) (err error) 577 //sys Dup(fd int) (nfd int, err error) 578 //sys Dup2(from int, to int) (err error) 579 //sys Exit(code int) 580 //sys ExtattrGetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) 581 //sys ExtattrSetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) 582 //sys ExtattrDeleteFd(fd int, attrnamespace int, attrname string) (err error) 583 //sys ExtattrListFd(fd int, attrnamespace int, data uintptr, nbytes int) (ret int, err error) 584 //sys ExtattrGetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) 585 //sys ExtattrSetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) 586 //sys ExtattrDeleteFile(file string, attrnamespace int, attrname string) (err error) 587 //sys ExtattrListFile(file string, attrnamespace int, data uintptr, nbytes int) (ret int, err error) 588 //sys ExtattrGetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) 589 //sys ExtattrSetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error) 590 //sys ExtattrDeleteLink(link string, attrnamespace int, attrname string) (err error) 591 //sys ExtattrListLink(link string, attrnamespace int, data uintptr, nbytes int) (ret int, err error) 592 //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_POSIX_FADVISE 593 //sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error) 594 //sys Fchdir(fd int) (err error) 595 //sys Fchflags(fd int, flags int) (err error) 596 //sys Fchmod(fd int, mode uint32) (err error) 597 //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) 598 //sys Fchown(fd int, uid int, gid int) (err error) 599 //sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) 600 //sys Flock(fd int, how int) (err error) 601 //sys Fpathconf(fd int, name int) (val int, err error) 602 //sys fstat(fd int, stat *stat_freebsd11_t) (err error) 603 //sys fstat_freebsd12(fd int, stat *Stat_t) (err error) 604 //sys fstatat(fd int, path string, stat *stat_freebsd11_t, flags int) (err error) 605 //sys fstatat_freebsd12(fd int, path string, stat *Stat_t, flags int) (err error) 606 //sys fstatfs(fd int, stat *statfs_freebsd11_t) (err error) 607 //sys fstatfs_freebsd12(fd int, stat *Statfs_t) (err error) 608 //sys Fsync(fd int) (err error) 609 //sys Ftruncate(fd int, length int64) (err error) 610 //sys getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) 611 //sys getdirentries_freebsd12(fd int, buf []byte, basep *uint64) (n int, err error) 612 //sys Getdtablesize() (size int) 613 //sysnb Getegid() (egid int) 614 //sysnb Geteuid() (uid int) 615 //sysnb Getgid() (gid int) 616 //sysnb Getpgid(pid int) (pgid int, err error) 617 //sysnb Getpgrp() (pgrp int) 618 //sysnb Getpid() (pid int) 619 //sysnb Getppid() (ppid int) 620 //sys Getpriority(which int, who int) (prio int, err error) 621 //sysnb Getrlimit(which int, lim *Rlimit) (err error) 622 //sysnb Getrusage(who int, rusage *Rusage) (err error) 623 //sysnb Getsid(pid int) (sid int, err error) 624 //sysnb Gettimeofday(tv *Timeval) (err error) 625 //sysnb Getuid() (uid int) 626 //sys Issetugid() (tainted bool) 627 //sys Kill(pid int, signum syscall.Signal) (err error) 628 //sys Kqueue() (fd int, err error) 629 //sys Lchown(path string, uid int, gid int) (err error) 630 //sys Link(path string, link string) (err error) 631 //sys Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error) 632 //sys Listen(s int, backlog int) (err error) 633 //sys lstat(path string, stat *stat_freebsd11_t) (err error) 634 //sys Mkdir(path string, mode uint32) (err error) 635 //sys Mkdirat(dirfd int, path string, mode uint32) (err error) 636 //sys Mkfifo(path string, mode uint32) (err error) 637 //sys mknod(path string, mode uint32, dev int) (err error) 638 //sys mknodat(fd int, path string, mode uint32, dev int) (err error) 639 //sys mknodat_freebsd12(fd int, path string, mode uint32, dev uint64) (err error) 640 //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) 641 //sys Open(path string, mode int, perm uint32) (fd int, err error) 642 //sys Openat(fdat int, path string, mode int, perm uint32) (fd int, err error) 643 //sys Pathconf(path string, name int) (val int, err error) 644 //sys Pread(fd int, p []byte, offset int64) (n int, err error) 645 //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) 646 //sys read(fd int, p []byte) (n int, err error) 647 //sys Readlink(path string, buf []byte) (n int, err error) 648 //sys Readlinkat(dirfd int, path string, buf []byte) (n int, err error) 649 //sys Rename(from string, to string) (err error) 650 //sys Renameat(fromfd int, from string, tofd int, to string) (err error) 651 //sys Revoke(path string) (err error) 652 //sys Rmdir(path string) (err error) 653 //sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK 654 //sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error) 655 //sysnb Setegid(egid int) (err error) 656 //sysnb Seteuid(euid int) (err error) 657 //sysnb Setgid(gid int) (err error) 658 //sys Setlogin(name string) (err error) 659 //sysnb Setpgid(pid int, pgid int) (err error) 660 //sys Setpriority(which int, who int, prio int) (err error) 661 //sysnb Setregid(rgid int, egid int) (err error) 662 //sysnb Setreuid(ruid int, euid int) (err error) 663 //sysnb Setresgid(rgid int, egid int, sgid int) (err error) 664 //sysnb Setresuid(ruid int, euid int, suid int) (err error) 665 //sysnb Setrlimit(which int, lim *Rlimit) (err error) 666 //sysnb Setsid() (pid int, err error) 667 //sysnb Settimeofday(tp *Timeval) (err error) 668 //sysnb Setuid(uid int) (err error) 669 //sys stat(path string, stat *stat_freebsd11_t) (err error) 670 //sys statfs(path string, stat *statfs_freebsd11_t) (err error) 671 //sys statfs_freebsd12(path string, stat *Statfs_t) (err error) 672 //sys Symlink(path string, link string) (err error) 673 //sys Symlinkat(oldpath string, newdirfd int, newpath string) (err error) 674 //sys Sync() (err error) 675 //sys Truncate(path string, length int64) (err error) 676 //sys Umask(newmask int) (oldmask int) 677 //sys Undelete(path string) (err error) 678 //sys Unlink(path string) (err error) 679 //sys Unlinkat(dirfd int, path string, flags int) (err error) 680 //sys Unmount(path string, flags int) (err error) 681 //sys write(fd int, p []byte) (n int, err error) 682 //sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error) 683 //sys munmap(addr uintptr, length uintptr) (err error) 684 //sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ 685 //sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE 686 //sys accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error) 687 //sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error) 688 689 /* 690 * Unimplemented 691 */ 692 // Profil 693 // Sigaction 694 // Sigprocmask 695 // Getlogin 696 // Sigpending 697 // Sigaltstack 698 // Ioctl 699 // Reboot 700 // Execve 701 // Vfork 702 // Sbrk 703 // Sstk 704 // Ovadvise 705 // Mincore 706 // Setitimer 707 // Swapon 708 // Select 709 // Sigsuspend 710 // Readv 711 // Writev 712 // Nfssvc 713 // Getfh 714 // Quotactl 715 // Mount 716 // Csops 717 // Waitid 718 // Add_profil 719 // Kdebug_trace 720 // Sigreturn 721 // Atsocket 722 // Kqueue_from_portset_np 723 // Kqueue_portset 724 // Getattrlist 725 // Setattrlist 726 // Getdents 727 // Getdirentriesattr 728 // Searchfs 729 // Delete 730 // Copyfile 731 // Watchevent 732 // Waitevent 733 // Modwatch 734 // Fsctl 735 // Initgroups 736 // Posix_spawn 737 // Nfsclnt 738 // Fhopen 739 // Minherit 740 // Semsys 741 // Msgsys 742 // Shmsys 743 // Semctl 744 // Semget 745 // Semop 746 // Msgctl 747 // Msgget 748 // Msgsnd 749 // Msgrcv 750 // Shmat 751 // Shmctl 752 // Shmdt 753 // Shmget 754 // Shm_open 755 // Shm_unlink 756 // Sem_open 757 // Sem_close 758 // Sem_unlink 759 // Sem_wait 760 // Sem_trywait 761 // Sem_post 762 // Sem_getvalue 763 // Sem_init 764 // Sem_destroy 765 // Open_extended 766 // Umask_extended 767 // Stat_extended 768 // Lstat_extended 769 // Fstat_extended 770 // Chmod_extended 771 // Fchmod_extended 772 // Access_extended 773 // Settid 774 // Gettid 775 // Setsgroups 776 // Getsgroups 777 // Setwgroups 778 // Getwgroups 779 // Mkfifo_extended 780 // Mkdir_extended 781 // Identitysvc 782 // Shared_region_check_np 783 // Shared_region_map_np 784 // __pthread_mutex_destroy 785 // __pthread_mutex_init 786 // __pthread_mutex_lock 787 // __pthread_mutex_trylock 788 // __pthread_mutex_unlock 789 // __pthread_cond_init 790 // __pthread_cond_destroy 791 // __pthread_cond_broadcast 792 // __pthread_cond_signal 793 // Setsid_with_pid 794 // __pthread_cond_timedwait 795 // Aio_fsync 796 // Aio_return 797 // Aio_suspend 798 // Aio_cancel 799 // Aio_error 800 // Aio_read 801 // Aio_write 802 // Lio_listio 803 // __pthread_cond_wait 804 // Iopolicysys 805 // __pthread_kill 806 // __pthread_sigmask 807 // __sigwait 808 // __disable_threadsignal 809 // __pthread_markcancel 810 // __pthread_canceled 811 // __semwait_signal 812 // Proc_info 813 // Stat64_extended 814 // Lstat64_extended 815 // Fstat64_extended 816 // __pthread_chdir 817 // __pthread_fchdir 818 // Audit 819 // Auditon 820 // Getauid 821 // Setauid 822 // Getaudit 823 // Setaudit 824 // Getaudit_addr 825 // Setaudit_addr 826 // Auditctl 827 // Bsdthread_create 828 // Bsdthread_terminate 829 // Stack_snapshot 830 // Bsdthread_register 831 // Workq_open 832 // Workq_ops 833 // __mac_execve 834 // __mac_syscall 835 // __mac_get_file 836 // __mac_set_file 837 // __mac_get_link 838 // __mac_set_link 839 // __mac_get_proc 840 // __mac_set_proc 841 // __mac_get_fd 842 // __mac_set_fd 843 // __mac_get_pid 844 // __mac_get_lcid 845 // __mac_get_lctx 846 // __mac_set_lctx 847 // Setlcid 848 // Read_nocancel 849 // Write_nocancel 850 // Open_nocancel 851 // Close_nocancel 852 // Wait4_nocancel 853 // Recvmsg_nocancel 854 // Sendmsg_nocancel 855 // Recvfrom_nocancel 856 // Accept_nocancel 857 // Fcntl_nocancel 858 // Select_nocancel 859 // Fsync_nocancel 860 // Connect_nocancel 861 // Sigsuspend_nocancel 862 // Readv_nocancel 863 // Writev_nocancel 864 // Sendto_nocancel 865 // Pread_nocancel 866 // Pwrite_nocancel 867 // Waitid_nocancel 868 // Poll_nocancel 869 // Msgsnd_nocancel 870 // Msgrcv_nocancel 871 // Sem_wait_nocancel 872 // Aio_suspend_nocancel 873 // __sigwait_nocancel 874 // __semwait_signal_nocancel 875 // __mac_mount 876 // __mac_get_mount 877 // __mac_getfsstat