syscall_freebsd.go 24 KB

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