syscall_darwin.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  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. // Darwin 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. "fmt"
  14. "syscall"
  15. "unsafe"
  16. )
  17. //sys closedir(dir uintptr) (err error)
  18. //sys readdir_r(dir uintptr, entry *Dirent, result **Dirent) (res Errno)
  19. func fdopendir(fd int) (dir uintptr, err error) {
  20. r0, _, e1 := syscall_syscallPtr(libc_fdopendir_trampoline_addr, uintptr(fd), 0, 0)
  21. dir = uintptr(r0)
  22. if e1 != 0 {
  23. err = errnoErr(e1)
  24. }
  25. return
  26. }
  27. var libc_fdopendir_trampoline_addr uintptr
  28. //go:cgo_import_dynamic libc_fdopendir fdopendir "/usr/lib/libSystem.B.dylib"
  29. func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
  30. // Simulate Getdirentries using fdopendir/readdir_r/closedir.
  31. // We store the number of entries to skip in the seek
  32. // offset of fd. See issue #31368.
  33. // It's not the full required semantics, but should handle the case
  34. // of calling Getdirentries or ReadDirent repeatedly.
  35. // It won't handle assigning the results of lseek to *basep, or handle
  36. // the directory being edited underfoot.
  37. skip, err := Seek(fd, 0, 1 /* SEEK_CUR */)
  38. if err != nil {
  39. return 0, err
  40. }
  41. // We need to duplicate the incoming file descriptor
  42. // because the caller expects to retain control of it, but
  43. // fdopendir expects to take control of its argument.
  44. // Just Dup'ing the file descriptor is not enough, as the
  45. // result shares underlying state. Use Openat to make a really
  46. // new file descriptor referring to the same directory.
  47. fd2, err := Openat(fd, ".", O_RDONLY, 0)
  48. if err != nil {
  49. return 0, err
  50. }
  51. d, err := fdopendir(fd2)
  52. if err != nil {
  53. Close(fd2)
  54. return 0, err
  55. }
  56. defer closedir(d)
  57. var cnt int64
  58. for {
  59. var entry Dirent
  60. var entryp *Dirent
  61. e := readdir_r(d, &entry, &entryp)
  62. if e != 0 {
  63. return n, errnoErr(e)
  64. }
  65. if entryp == nil {
  66. break
  67. }
  68. if skip > 0 {
  69. skip--
  70. cnt++
  71. continue
  72. }
  73. reclen := int(entry.Reclen)
  74. if reclen > len(buf) {
  75. // Not enough room. Return for now.
  76. // The counter will let us know where we should start up again.
  77. // Note: this strategy for suspending in the middle and
  78. // restarting is O(n^2) in the length of the directory. Oh well.
  79. break
  80. }
  81. // Copy entry into return buffer.
  82. s := unsafe.Slice((*byte)(unsafe.Pointer(&entry)), reclen)
  83. copy(buf, s)
  84. buf = buf[reclen:]
  85. n += reclen
  86. cnt++
  87. }
  88. // Set the seek offset of the input fd to record
  89. // how many files we've already returned.
  90. _, err = Seek(fd, cnt, 0 /* SEEK_SET */)
  91. if err != nil {
  92. return n, err
  93. }
  94. return n, nil
  95. }
  96. // SockaddrDatalink implements the Sockaddr interface for AF_LINK type sockets.
  97. type SockaddrDatalink struct {
  98. Len uint8
  99. Family uint8
  100. Index uint16
  101. Type uint8
  102. Nlen uint8
  103. Alen uint8
  104. Slen uint8
  105. Data [12]int8
  106. raw RawSockaddrDatalink
  107. }
  108. // SockaddrCtl implements the Sockaddr interface for AF_SYSTEM type sockets.
  109. type SockaddrCtl struct {
  110. ID uint32
  111. Unit uint32
  112. raw RawSockaddrCtl
  113. }
  114. func (sa *SockaddrCtl) sockaddr() (unsafe.Pointer, _Socklen, error) {
  115. sa.raw.Sc_len = SizeofSockaddrCtl
  116. sa.raw.Sc_family = AF_SYSTEM
  117. sa.raw.Ss_sysaddr = AF_SYS_CONTROL
  118. sa.raw.Sc_id = sa.ID
  119. sa.raw.Sc_unit = sa.Unit
  120. return unsafe.Pointer(&sa.raw), SizeofSockaddrCtl, nil
  121. }
  122. // SockaddrVM implements the Sockaddr interface for AF_VSOCK type sockets.
  123. // SockaddrVM provides access to Darwin VM sockets: a mechanism that enables
  124. // bidirectional communication between a hypervisor and its guest virtual
  125. // machines.
  126. type SockaddrVM struct {
  127. // CID and Port specify a context ID and port address for a VM socket.
  128. // Guests have a unique CID, and hosts may have a well-known CID of:
  129. // - VMADDR_CID_HYPERVISOR: refers to the hypervisor process.
  130. // - VMADDR_CID_LOCAL: refers to local communication (loopback).
  131. // - VMADDR_CID_HOST: refers to other processes on the host.
  132. CID uint32
  133. Port uint32
  134. raw RawSockaddrVM
  135. }
  136. func (sa *SockaddrVM) sockaddr() (unsafe.Pointer, _Socklen, error) {
  137. sa.raw.Len = SizeofSockaddrVM
  138. sa.raw.Family = AF_VSOCK
  139. sa.raw.Port = sa.Port
  140. sa.raw.Cid = sa.CID
  141. return unsafe.Pointer(&sa.raw), SizeofSockaddrVM, nil
  142. }
  143. func anyToSockaddrGOOS(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
  144. switch rsa.Addr.Family {
  145. case AF_SYSTEM:
  146. pp := (*RawSockaddrCtl)(unsafe.Pointer(rsa))
  147. if pp.Ss_sysaddr == AF_SYS_CONTROL {
  148. sa := new(SockaddrCtl)
  149. sa.ID = pp.Sc_id
  150. sa.Unit = pp.Sc_unit
  151. return sa, nil
  152. }
  153. case AF_VSOCK:
  154. pp := (*RawSockaddrVM)(unsafe.Pointer(rsa))
  155. sa := &SockaddrVM{
  156. CID: pp.Cid,
  157. Port: pp.Port,
  158. }
  159. return sa, nil
  160. }
  161. return nil, EAFNOSUPPORT
  162. }
  163. // Some external packages rely on SYS___SYSCTL being defined to implement their
  164. // own sysctl wrappers. Provide it here, even though direct syscalls are no
  165. // longer supported on darwin.
  166. const SYS___SYSCTL = SYS_SYSCTL
  167. // Translate "kern.hostname" to []_C_int{0,1,2,3}.
  168. func nametomib(name string) (mib []_C_int, err error) {
  169. const siz = unsafe.Sizeof(mib[0])
  170. // NOTE(rsc): It seems strange to set the buffer to have
  171. // size CTL_MAXNAME+2 but use only CTL_MAXNAME
  172. // as the size. I don't know why the +2 is here, but the
  173. // kernel uses +2 for its own implementation of this function.
  174. // I am scared that if we don't include the +2 here, the kernel
  175. // will silently write 2 words farther than we specify
  176. // and we'll get memory corruption.
  177. var buf [CTL_MAXNAME + 2]_C_int
  178. n := uintptr(CTL_MAXNAME) * siz
  179. p := (*byte)(unsafe.Pointer(&buf[0]))
  180. bytes, err := ByteSliceFromString(name)
  181. if err != nil {
  182. return nil, err
  183. }
  184. // Magic sysctl: "setting" 0.3 to a string name
  185. // lets you read back the array of integers form.
  186. if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil {
  187. return nil, err
  188. }
  189. return buf[0 : n/siz], nil
  190. }
  191. func direntIno(buf []byte) (uint64, bool) {
  192. return readInt(buf, unsafe.Offsetof(Dirent{}.Ino), unsafe.Sizeof(Dirent{}.Ino))
  193. }
  194. func direntReclen(buf []byte) (uint64, bool) {
  195. return readInt(buf, unsafe.Offsetof(Dirent{}.Reclen), unsafe.Sizeof(Dirent{}.Reclen))
  196. }
  197. func direntNamlen(buf []byte) (uint64, bool) {
  198. return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
  199. }
  200. func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) }
  201. func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) }
  202. func PtraceDenyAttach() (err error) { return ptrace(PT_DENY_ATTACH, 0, 0, 0) }
  203. //sysnb pipe(p *[2]int32) (err error)
  204. func Pipe(p []int) (err error) {
  205. if len(p) != 2 {
  206. return EINVAL
  207. }
  208. var x [2]int32
  209. err = pipe(&x)
  210. if err == nil {
  211. p[0] = int(x[0])
  212. p[1] = int(x[1])
  213. }
  214. return
  215. }
  216. func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
  217. var _p0 unsafe.Pointer
  218. var bufsize uintptr
  219. if len(buf) > 0 {
  220. _p0 = unsafe.Pointer(&buf[0])
  221. bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
  222. }
  223. return getfsstat(_p0, bufsize, flags)
  224. }
  225. func xattrPointer(dest []byte) *byte {
  226. // It's only when dest is set to NULL that the OS X implementations of
  227. // getxattr() and listxattr() return the current sizes of the named attributes.
  228. // An empty byte array is not sufficient. To maintain the same behaviour as the
  229. // linux implementation, we wrap around the system calls and pass in NULL when
  230. // dest is empty.
  231. var destp *byte
  232. if len(dest) > 0 {
  233. destp = &dest[0]
  234. }
  235. return destp
  236. }
  237. //sys getxattr(path string, attr string, dest *byte, size int, position uint32, options int) (sz int, err error)
  238. func Getxattr(path string, attr string, dest []byte) (sz int, err error) {
  239. return getxattr(path, attr, xattrPointer(dest), len(dest), 0, 0)
  240. }
  241. func Lgetxattr(link string, attr string, dest []byte) (sz int, err error) {
  242. return getxattr(link, attr, xattrPointer(dest), len(dest), 0, XATTR_NOFOLLOW)
  243. }
  244. //sys fgetxattr(fd int, attr string, dest *byte, size int, position uint32, options int) (sz int, err error)
  245. func Fgetxattr(fd int, attr string, dest []byte) (sz int, err error) {
  246. return fgetxattr(fd, attr, xattrPointer(dest), len(dest), 0, 0)
  247. }
  248. //sys setxattr(path string, attr string, data *byte, size int, position uint32, options int) (err error)
  249. func Setxattr(path string, attr string, data []byte, flags int) (err error) {
  250. // The parameters for the OS X implementation vary slightly compared to the
  251. // linux system call, specifically the position parameter:
  252. //
  253. // linux:
  254. // int setxattr(
  255. // const char *path,
  256. // const char *name,
  257. // const void *value,
  258. // size_t size,
  259. // int flags
  260. // );
  261. //
  262. // darwin:
  263. // int setxattr(
  264. // const char *path,
  265. // const char *name,
  266. // void *value,
  267. // size_t size,
  268. // u_int32_t position,
  269. // int options
  270. // );
  271. //
  272. // position specifies the offset within the extended attribute. In the
  273. // current implementation, only the resource fork extended attribute makes
  274. // use of this argument. For all others, position is reserved. We simply
  275. // default to setting it to zero.
  276. return setxattr(path, attr, xattrPointer(data), len(data), 0, flags)
  277. }
  278. func Lsetxattr(link string, attr string, data []byte, flags int) (err error) {
  279. return setxattr(link, attr, xattrPointer(data), len(data), 0, flags|XATTR_NOFOLLOW)
  280. }
  281. //sys fsetxattr(fd int, attr string, data *byte, size int, position uint32, options int) (err error)
  282. func Fsetxattr(fd int, attr string, data []byte, flags int) (err error) {
  283. return fsetxattr(fd, attr, xattrPointer(data), len(data), 0, 0)
  284. }
  285. //sys removexattr(path string, attr string, options int) (err error)
  286. func Removexattr(path string, attr string) (err error) {
  287. // We wrap around and explicitly zero out the options provided to the OS X
  288. // implementation of removexattr, we do so for interoperability with the
  289. // linux variant.
  290. return removexattr(path, attr, 0)
  291. }
  292. func Lremovexattr(link string, attr string) (err error) {
  293. return removexattr(link, attr, XATTR_NOFOLLOW)
  294. }
  295. //sys fremovexattr(fd int, attr string, options int) (err error)
  296. func Fremovexattr(fd int, attr string) (err error) {
  297. return fremovexattr(fd, attr, 0)
  298. }
  299. //sys listxattr(path string, dest *byte, size int, options int) (sz int, err error)
  300. func Listxattr(path string, dest []byte) (sz int, err error) {
  301. return listxattr(path, xattrPointer(dest), len(dest), 0)
  302. }
  303. func Llistxattr(link string, dest []byte) (sz int, err error) {
  304. return listxattr(link, xattrPointer(dest), len(dest), XATTR_NOFOLLOW)
  305. }
  306. //sys flistxattr(fd int, dest *byte, size int, options int) (sz int, err error)
  307. func Flistxattr(fd int, dest []byte) (sz int, err error) {
  308. return flistxattr(fd, xattrPointer(dest), len(dest), 0)
  309. }
  310. //sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error)
  311. /*
  312. * Wrapped
  313. */
  314. //sys fcntl(fd int, cmd int, arg int) (val int, err error)
  315. //sys kill(pid int, signum int, posix int) (err error)
  316. func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(signum), 1) }
  317. //sys ioctl(fd int, req uint, arg uintptr) (err error)
  318. //sys ioctlPtr(fd int, req uint, arg unsafe.Pointer) (err error) = SYS_IOCTL
  319. func IoctlCtlInfo(fd int, ctlInfo *CtlInfo) error {
  320. return ioctlPtr(fd, CTLIOCGINFO, unsafe.Pointer(ctlInfo))
  321. }
  322. // IfreqMTU is struct ifreq used to get or set a network device's MTU.
  323. type IfreqMTU struct {
  324. Name [IFNAMSIZ]byte
  325. MTU int32
  326. }
  327. // IoctlGetIfreqMTU performs the SIOCGIFMTU ioctl operation on fd to get the MTU
  328. // of the network device specified by ifname.
  329. func IoctlGetIfreqMTU(fd int, ifname string) (*IfreqMTU, error) {
  330. var ifreq IfreqMTU
  331. copy(ifreq.Name[:], ifname)
  332. err := ioctlPtr(fd, SIOCGIFMTU, unsafe.Pointer(&ifreq))
  333. return &ifreq, err
  334. }
  335. // IoctlSetIfreqMTU performs the SIOCSIFMTU ioctl operation on fd to set the MTU
  336. // of the network device specified by ifreq.Name.
  337. func IoctlSetIfreqMTU(fd int, ifreq *IfreqMTU) error {
  338. return ioctlPtr(fd, SIOCSIFMTU, unsafe.Pointer(ifreq))
  339. }
  340. //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL
  341. func Uname(uname *Utsname) error {
  342. mib := []_C_int{CTL_KERN, KERN_OSTYPE}
  343. n := unsafe.Sizeof(uname.Sysname)
  344. if err := sysctl(mib, &uname.Sysname[0], &n, nil, 0); err != nil {
  345. return err
  346. }
  347. mib = []_C_int{CTL_KERN, KERN_HOSTNAME}
  348. n = unsafe.Sizeof(uname.Nodename)
  349. if err := sysctl(mib, &uname.Nodename[0], &n, nil, 0); err != nil {
  350. return err
  351. }
  352. mib = []_C_int{CTL_KERN, KERN_OSRELEASE}
  353. n = unsafe.Sizeof(uname.Release)
  354. if err := sysctl(mib, &uname.Release[0], &n, nil, 0); err != nil {
  355. return err
  356. }
  357. mib = []_C_int{CTL_KERN, KERN_VERSION}
  358. n = unsafe.Sizeof(uname.Version)
  359. if err := sysctl(mib, &uname.Version[0], &n, nil, 0); err != nil {
  360. return err
  361. }
  362. // The version might have newlines or tabs in it, convert them to
  363. // spaces.
  364. for i, b := range uname.Version {
  365. if b == '\n' || b == '\t' {
  366. if i == len(uname.Version)-1 {
  367. uname.Version[i] = 0
  368. } else {
  369. uname.Version[i] = ' '
  370. }
  371. }
  372. }
  373. mib = []_C_int{CTL_HW, HW_MACHINE}
  374. n = unsafe.Sizeof(uname.Machine)
  375. if err := sysctl(mib, &uname.Machine[0], &n, nil, 0); err != nil {
  376. return err
  377. }
  378. return nil
  379. }
  380. func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
  381. if raceenabled {
  382. raceReleaseMerge(unsafe.Pointer(&ioSync))
  383. }
  384. var length = int64(count)
  385. err = sendfile(infd, outfd, *offset, &length, nil, 0)
  386. written = int(length)
  387. return
  388. }
  389. func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) {
  390. var value IPMreqn
  391. vallen := _Socklen(SizeofIPMreqn)
  392. errno := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
  393. return &value, errno
  394. }
  395. func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) {
  396. return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq))
  397. }
  398. // GetsockoptXucred is a getsockopt wrapper that returns an Xucred struct.
  399. // The usual level and opt are SOL_LOCAL and LOCAL_PEERCRED, respectively.
  400. func GetsockoptXucred(fd, level, opt int) (*Xucred, error) {
  401. x := new(Xucred)
  402. vallen := _Socklen(SizeofXucred)
  403. err := getsockopt(fd, level, opt, unsafe.Pointer(x), &vallen)
  404. return x, err
  405. }
  406. func GetsockoptTCPConnectionInfo(fd, level, opt int) (*TCPConnectionInfo, error) {
  407. var value TCPConnectionInfo
  408. vallen := _Socklen(SizeofTCPConnectionInfo)
  409. err := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
  410. return &value, err
  411. }
  412. func SysctlKinfoProc(name string, args ...int) (*KinfoProc, error) {
  413. mib, err := sysctlmib(name, args...)
  414. if err != nil {
  415. return nil, err
  416. }
  417. var kinfo KinfoProc
  418. n := uintptr(SizeofKinfoProc)
  419. if err := sysctl(mib, (*byte)(unsafe.Pointer(&kinfo)), &n, nil, 0); err != nil {
  420. return nil, err
  421. }
  422. if n != SizeofKinfoProc {
  423. return nil, EIO
  424. }
  425. return &kinfo, nil
  426. }
  427. func SysctlKinfoProcSlice(name string, args ...int) ([]KinfoProc, error) {
  428. mib, err := sysctlmib(name, args...)
  429. if err != nil {
  430. return nil, err
  431. }
  432. for {
  433. // Find size.
  434. n := uintptr(0)
  435. if err := sysctl(mib, nil, &n, nil, 0); err != nil {
  436. return nil, err
  437. }
  438. if n == 0 {
  439. return nil, nil
  440. }
  441. if n%SizeofKinfoProc != 0 {
  442. return nil, fmt.Errorf("sysctl() returned a size of %d, which is not a multiple of %d", n, SizeofKinfoProc)
  443. }
  444. // Read into buffer of that size.
  445. buf := make([]KinfoProc, n/SizeofKinfoProc)
  446. if err := sysctl(mib, (*byte)(unsafe.Pointer(&buf[0])), &n, nil, 0); err != nil {
  447. if err == ENOMEM {
  448. // Process table grew. Try again.
  449. continue
  450. }
  451. return nil, err
  452. }
  453. if n%SizeofKinfoProc != 0 {
  454. return nil, fmt.Errorf("sysctl() returned a size of %d, which is not a multiple of %d", n, SizeofKinfoProc)
  455. }
  456. // The actual call may return less than the original reported required
  457. // size so ensure we deal with that.
  458. return buf[:n/SizeofKinfoProc], nil
  459. }
  460. }
  461. //sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error)
  462. //sys shmat(id int, addr uintptr, flag int) (ret uintptr, err error)
  463. //sys shmctl(id int, cmd int, buf *SysvShmDesc) (result int, err error)
  464. //sys shmdt(addr uintptr) (err error)
  465. //sys shmget(key int, size int, flag int) (id int, err error)
  466. /*
  467. * Exposed directly
  468. */
  469. //sys Access(path string, mode uint32) (err error)
  470. //sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
  471. //sys Chdir(path string) (err error)
  472. //sys Chflags(path string, flags int) (err error)
  473. //sys Chmod(path string, mode uint32) (err error)
  474. //sys Chown(path string, uid int, gid int) (err error)
  475. //sys Chroot(path string) (err error)
  476. //sys ClockGettime(clockid int32, time *Timespec) (err error)
  477. //sys Close(fd int) (err error)
  478. //sys Clonefile(src string, dst string, flags int) (err error)
  479. //sys Clonefileat(srcDirfd int, src string, dstDirfd int, dst string, flags int) (err error)
  480. //sys Dup(fd int) (nfd int, err error)
  481. //sys Dup2(from int, to int) (err error)
  482. //sys Exchangedata(path1 string, path2 string, options int) (err error)
  483. //sys Exit(code int)
  484. //sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
  485. //sys Fchdir(fd int) (err error)
  486. //sys Fchflags(fd int, flags int) (err error)
  487. //sys Fchmod(fd int, mode uint32) (err error)
  488. //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
  489. //sys Fchown(fd int, uid int, gid int) (err error)
  490. //sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
  491. //sys Fclonefileat(srcDirfd int, dstDirfd int, dst string, flags int) (err error)
  492. //sys Flock(fd int, how int) (err error)
  493. //sys Fpathconf(fd int, name int) (val int, err error)
  494. //sys Fsync(fd int) (err error)
  495. //sys Ftruncate(fd int, length int64) (err error)
  496. //sys Getcwd(buf []byte) (n int, err error)
  497. //sys Getdtablesize() (size int)
  498. //sysnb Getegid() (egid int)
  499. //sysnb Geteuid() (uid int)
  500. //sysnb Getgid() (gid int)
  501. //sysnb Getpgid(pid int) (pgid int, err error)
  502. //sysnb Getpgrp() (pgrp int)
  503. //sysnb Getpid() (pid int)
  504. //sysnb Getppid() (ppid int)
  505. //sys Getpriority(which int, who int) (prio int, err error)
  506. //sysnb Getrlimit(which int, lim *Rlimit) (err error)
  507. //sysnb Getrusage(who int, rusage *Rusage) (err error)
  508. //sysnb Getsid(pid int) (sid int, err error)
  509. //sysnb Gettimeofday(tp *Timeval) (err error)
  510. //sysnb Getuid() (uid int)
  511. //sysnb Issetugid() (tainted bool)
  512. //sys Kqueue() (fd int, err error)
  513. //sys Lchown(path string, uid int, gid int) (err error)
  514. //sys Link(path string, link string) (err error)
  515. //sys Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error)
  516. //sys Listen(s int, backlog int) (err error)
  517. //sys Mkdir(path string, mode uint32) (err error)
  518. //sys Mkdirat(dirfd int, path string, mode uint32) (err error)
  519. //sys Mkfifo(path string, mode uint32) (err error)
  520. //sys Mknod(path string, mode uint32, dev int) (err error)
  521. //sys Mount(fsType string, dir string, flags int, data unsafe.Pointer) (err error)
  522. //sys Open(path string, mode int, perm uint32) (fd int, err error)
  523. //sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error)
  524. //sys Pathconf(path string, name int) (val int, err error)
  525. //sys pread(fd int, p []byte, offset int64) (n int, err error)
  526. //sys pwrite(fd int, p []byte, offset int64) (n int, err error)
  527. //sys read(fd int, p []byte) (n int, err error)
  528. //sys Readlink(path string, buf []byte) (n int, err error)
  529. //sys Readlinkat(dirfd int, path string, buf []byte) (n int, err error)
  530. //sys Rename(from string, to string) (err error)
  531. //sys Renameat(fromfd int, from string, tofd int, to string) (err error)
  532. //sys Revoke(path string) (err error)
  533. //sys Rmdir(path string) (err error)
  534. //sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
  535. //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
  536. //sys Setattrlist(path string, attrlist *Attrlist, attrBuf []byte, options int) (err error)
  537. //sys Setegid(egid int) (err error)
  538. //sysnb Seteuid(euid int) (err error)
  539. //sysnb Setgid(gid int) (err error)
  540. //sys Setlogin(name string) (err error)
  541. //sysnb Setpgid(pid int, pgid int) (err error)
  542. //sys Setpriority(which int, who int, prio int) (err error)
  543. //sys Setprivexec(flag int) (err error)
  544. //sysnb Setregid(rgid int, egid int) (err error)
  545. //sysnb Setreuid(ruid int, euid int) (err error)
  546. //sysnb Setsid() (pid int, err error)
  547. //sysnb Settimeofday(tp *Timeval) (err error)
  548. //sysnb Setuid(uid int) (err error)
  549. //sys Symlink(path string, link string) (err error)
  550. //sys Symlinkat(oldpath string, newdirfd int, newpath string) (err error)
  551. //sys Sync() (err error)
  552. //sys Truncate(path string, length int64) (err error)
  553. //sys Umask(newmask int) (oldmask int)
  554. //sys Undelete(path string) (err error)
  555. //sys Unlink(path string) (err error)
  556. //sys Unlinkat(dirfd int, path string, flags int) (err error)
  557. //sys Unmount(path string, flags int) (err error)
  558. //sys write(fd int, p []byte) (n int, err error)
  559. //sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
  560. //sys munmap(addr uintptr, length uintptr) (err error)