syscall_freebsd.go 24 KB

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