syscall_freebsd.go 22 KB

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