syscall_darwin.go 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753
  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. "runtime"
  15. "syscall"
  16. "unsafe"
  17. )
  18. // SockaddrDatalink implements the Sockaddr interface for AF_LINK type sockets.
  19. type SockaddrDatalink struct {
  20. Len uint8
  21. Family uint8
  22. Index uint16
  23. Type uint8
  24. Nlen uint8
  25. Alen uint8
  26. Slen uint8
  27. Data [12]int8
  28. raw RawSockaddrDatalink
  29. }
  30. // SockaddrCtl implements the Sockaddr interface for AF_SYSTEM type sockets.
  31. type SockaddrCtl struct {
  32. ID uint32
  33. Unit uint32
  34. raw RawSockaddrCtl
  35. }
  36. func (sa *SockaddrCtl) sockaddr() (unsafe.Pointer, _Socklen, error) {
  37. sa.raw.Sc_len = SizeofSockaddrCtl
  38. sa.raw.Sc_family = AF_SYSTEM
  39. sa.raw.Ss_sysaddr = AF_SYS_CONTROL
  40. sa.raw.Sc_id = sa.ID
  41. sa.raw.Sc_unit = sa.Unit
  42. return unsafe.Pointer(&sa.raw), SizeofSockaddrCtl, nil
  43. }
  44. // SockaddrVM implements the Sockaddr interface for AF_VSOCK type sockets.
  45. // SockaddrVM provides access to Darwin VM sockets: a mechanism that enables
  46. // bidirectional communication between a hypervisor and its guest virtual
  47. // machines.
  48. type SockaddrVM struct {
  49. // CID and Port specify a context ID and port address for a VM socket.
  50. // Guests have a unique CID, and hosts may have a well-known CID of:
  51. // - VMADDR_CID_HYPERVISOR: refers to the hypervisor process.
  52. // - VMADDR_CID_LOCAL: refers to local communication (loopback).
  53. // - VMADDR_CID_HOST: refers to other processes on the host.
  54. CID uint32
  55. Port uint32
  56. raw RawSockaddrVM
  57. }
  58. func (sa *SockaddrVM) sockaddr() (unsafe.Pointer, _Socklen, error) {
  59. sa.raw.Len = SizeofSockaddrVM
  60. sa.raw.Family = AF_VSOCK
  61. sa.raw.Port = sa.Port
  62. sa.raw.Cid = sa.CID
  63. return unsafe.Pointer(&sa.raw), SizeofSockaddrVM, nil
  64. }
  65. func anyToSockaddrGOOS(fd int, rsa *RawSockaddrAny) (Sockaddr, error) {
  66. switch rsa.Addr.Family {
  67. case AF_SYSTEM:
  68. pp := (*RawSockaddrCtl)(unsafe.Pointer(rsa))
  69. if pp.Ss_sysaddr == AF_SYS_CONTROL {
  70. sa := new(SockaddrCtl)
  71. sa.ID = pp.Sc_id
  72. sa.Unit = pp.Sc_unit
  73. return sa, nil
  74. }
  75. case AF_VSOCK:
  76. pp := (*RawSockaddrVM)(unsafe.Pointer(rsa))
  77. sa := &SockaddrVM{
  78. CID: pp.Cid,
  79. Port: pp.Port,
  80. }
  81. return sa, nil
  82. }
  83. return nil, EAFNOSUPPORT
  84. }
  85. // Some external packages rely on SYS___SYSCTL being defined to implement their
  86. // own sysctl wrappers. Provide it here, even though direct syscalls are no
  87. // longer supported on darwin.
  88. const SYS___SYSCTL = SYS_SYSCTL
  89. // Translate "kern.hostname" to []_C_int{0,1,2,3}.
  90. func nametomib(name string) (mib []_C_int, err error) {
  91. const siz = unsafe.Sizeof(mib[0])
  92. // NOTE(rsc): It seems strange to set the buffer to have
  93. // size CTL_MAXNAME+2 but use only CTL_MAXNAME
  94. // as the size. I don't know why the +2 is here, but the
  95. // kernel uses +2 for its own implementation of this function.
  96. // I am scared that if we don't include the +2 here, the kernel
  97. // will silently write 2 words farther than we specify
  98. // and we'll get memory corruption.
  99. var buf [CTL_MAXNAME + 2]_C_int
  100. n := uintptr(CTL_MAXNAME) * siz
  101. p := (*byte)(unsafe.Pointer(&buf[0]))
  102. bytes, err := ByteSliceFromString(name)
  103. if err != nil {
  104. return nil, err
  105. }
  106. // Magic sysctl: "setting" 0.3 to a string name
  107. // lets you read back the array of integers form.
  108. if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil {
  109. return nil, err
  110. }
  111. return buf[0 : n/siz], nil
  112. }
  113. func direntIno(buf []byte) (uint64, bool) {
  114. return readInt(buf, unsafe.Offsetof(Dirent{}.Ino), unsafe.Sizeof(Dirent{}.Ino))
  115. }
  116. func direntReclen(buf []byte) (uint64, bool) {
  117. return readInt(buf, unsafe.Offsetof(Dirent{}.Reclen), unsafe.Sizeof(Dirent{}.Reclen))
  118. }
  119. func direntNamlen(buf []byte) (uint64, bool) {
  120. return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
  121. }
  122. func PtraceAttach(pid int) (err error) { return ptrace(PT_ATTACH, pid, 0, 0) }
  123. func PtraceDetach(pid int) (err error) { return ptrace(PT_DETACH, pid, 0, 0) }
  124. type attrList struct {
  125. bitmapCount uint16
  126. _ uint16
  127. CommonAttr uint32
  128. VolAttr uint32
  129. DirAttr uint32
  130. FileAttr uint32
  131. Forkattr uint32
  132. }
  133. //sysnb pipe(p *[2]int32) (err error)
  134. func Pipe(p []int) (err error) {
  135. if len(p) != 2 {
  136. return EINVAL
  137. }
  138. var x [2]int32
  139. err = pipe(&x)
  140. p[0] = int(x[0])
  141. p[1] = int(x[1])
  142. return
  143. }
  144. func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
  145. var _p0 unsafe.Pointer
  146. var bufsize uintptr
  147. if len(buf) > 0 {
  148. _p0 = unsafe.Pointer(&buf[0])
  149. bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
  150. }
  151. return getfsstat(_p0, bufsize, flags)
  152. }
  153. func xattrPointer(dest []byte) *byte {
  154. // It's only when dest is set to NULL that the OS X implementations of
  155. // getxattr() and listxattr() return the current sizes of the named attributes.
  156. // An empty byte array is not sufficient. To maintain the same behaviour as the
  157. // linux implementation, we wrap around the system calls and pass in NULL when
  158. // dest is empty.
  159. var destp *byte
  160. if len(dest) > 0 {
  161. destp = &dest[0]
  162. }
  163. return destp
  164. }
  165. //sys getxattr(path string, attr string, dest *byte, size int, position uint32, options int) (sz int, err error)
  166. func Getxattr(path string, attr string, dest []byte) (sz int, err error) {
  167. return getxattr(path, attr, xattrPointer(dest), len(dest), 0, 0)
  168. }
  169. func Lgetxattr(link string, attr string, dest []byte) (sz int, err error) {
  170. return getxattr(link, attr, xattrPointer(dest), len(dest), 0, XATTR_NOFOLLOW)
  171. }
  172. //sys fgetxattr(fd int, attr string, dest *byte, size int, position uint32, options int) (sz int, err error)
  173. func Fgetxattr(fd int, attr string, dest []byte) (sz int, err error) {
  174. return fgetxattr(fd, attr, xattrPointer(dest), len(dest), 0, 0)
  175. }
  176. //sys setxattr(path string, attr string, data *byte, size int, position uint32, options int) (err error)
  177. func Setxattr(path string, attr string, data []byte, flags int) (err error) {
  178. // The parameters for the OS X implementation vary slightly compared to the
  179. // linux system call, specifically the position parameter:
  180. //
  181. // linux:
  182. // int setxattr(
  183. // const char *path,
  184. // const char *name,
  185. // const void *value,
  186. // size_t size,
  187. // int flags
  188. // );
  189. //
  190. // darwin:
  191. // int setxattr(
  192. // const char *path,
  193. // const char *name,
  194. // void *value,
  195. // size_t size,
  196. // u_int32_t position,
  197. // int options
  198. // );
  199. //
  200. // position specifies the offset within the extended attribute. In the
  201. // current implementation, only the resource fork extended attribute makes
  202. // use of this argument. For all others, position is reserved. We simply
  203. // default to setting it to zero.
  204. return setxattr(path, attr, xattrPointer(data), len(data), 0, flags)
  205. }
  206. func Lsetxattr(link string, attr string, data []byte, flags int) (err error) {
  207. return setxattr(link, attr, xattrPointer(data), len(data), 0, flags|XATTR_NOFOLLOW)
  208. }
  209. //sys fsetxattr(fd int, attr string, data *byte, size int, position uint32, options int) (err error)
  210. func Fsetxattr(fd int, attr string, data []byte, flags int) (err error) {
  211. return fsetxattr(fd, attr, xattrPointer(data), len(data), 0, 0)
  212. }
  213. //sys removexattr(path string, attr string, options int) (err error)
  214. func Removexattr(path string, attr string) (err error) {
  215. // We wrap around and explicitly zero out the options provided to the OS X
  216. // implementation of removexattr, we do so for interoperability with the
  217. // linux variant.
  218. return removexattr(path, attr, 0)
  219. }
  220. func Lremovexattr(link string, attr string) (err error) {
  221. return removexattr(link, attr, XATTR_NOFOLLOW)
  222. }
  223. //sys fremovexattr(fd int, attr string, options int) (err error)
  224. func Fremovexattr(fd int, attr string) (err error) {
  225. return fremovexattr(fd, attr, 0)
  226. }
  227. //sys listxattr(path string, dest *byte, size int, options int) (sz int, err error)
  228. func Listxattr(path string, dest []byte) (sz int, err error) {
  229. return listxattr(path, xattrPointer(dest), len(dest), 0)
  230. }
  231. func Llistxattr(link string, dest []byte) (sz int, err error) {
  232. return listxattr(link, xattrPointer(dest), len(dest), XATTR_NOFOLLOW)
  233. }
  234. //sys flistxattr(fd int, dest *byte, size int, options int) (sz int, err error)
  235. func Flistxattr(fd int, dest []byte) (sz int, err error) {
  236. return flistxattr(fd, xattrPointer(dest), len(dest), 0)
  237. }
  238. func setattrlistTimes(path string, times []Timespec, flags int) error {
  239. _p0, err := BytePtrFromString(path)
  240. if err != nil {
  241. return err
  242. }
  243. var attrList attrList
  244. attrList.bitmapCount = ATTR_BIT_MAP_COUNT
  245. attrList.CommonAttr = ATTR_CMN_MODTIME | ATTR_CMN_ACCTIME
  246. // order is mtime, atime: the opposite of Chtimes
  247. attributes := [2]Timespec{times[1], times[0]}
  248. options := 0
  249. if flags&AT_SYMLINK_NOFOLLOW != 0 {
  250. options |= FSOPT_NOFOLLOW
  251. }
  252. return setattrlist(
  253. _p0,
  254. unsafe.Pointer(&attrList),
  255. unsafe.Pointer(&attributes),
  256. unsafe.Sizeof(attributes),
  257. options)
  258. }
  259. //sys setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error)
  260. func utimensat(dirfd int, path string, times *[2]Timespec, flags int) error {
  261. // Darwin doesn't support SYS_UTIMENSAT
  262. return ENOSYS
  263. }
  264. /*
  265. * Wrapped
  266. */
  267. //sys fcntl(fd int, cmd int, arg int) (val int, err error)
  268. //sys kill(pid int, signum int, posix int) (err error)
  269. func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(signum), 1) }
  270. //sys ioctl(fd int, req uint, arg uintptr) (err error)
  271. func IoctlCtlInfo(fd int, ctlInfo *CtlInfo) error {
  272. err := ioctl(fd, CTLIOCGINFO, uintptr(unsafe.Pointer(ctlInfo)))
  273. runtime.KeepAlive(ctlInfo)
  274. return err
  275. }
  276. // IfreqMTU is struct ifreq used to get or set a network device's MTU.
  277. type IfreqMTU struct {
  278. Name [IFNAMSIZ]byte
  279. MTU int32
  280. }
  281. // IoctlGetIfreqMTU performs the SIOCGIFMTU ioctl operation on fd to get the MTU
  282. // of the network device specified by ifname.
  283. func IoctlGetIfreqMTU(fd int, ifname string) (*IfreqMTU, error) {
  284. var ifreq IfreqMTU
  285. copy(ifreq.Name[:], ifname)
  286. err := ioctl(fd, SIOCGIFMTU, uintptr(unsafe.Pointer(&ifreq)))
  287. return &ifreq, err
  288. }
  289. // IoctlSetIfreqMTU performs the SIOCSIFMTU ioctl operation on fd to set the MTU
  290. // of the network device specified by ifreq.Name.
  291. func IoctlSetIfreqMTU(fd int, ifreq *IfreqMTU) error {
  292. err := ioctl(fd, SIOCSIFMTU, uintptr(unsafe.Pointer(ifreq)))
  293. runtime.KeepAlive(ifreq)
  294. return err
  295. }
  296. //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL
  297. func Uname(uname *Utsname) error {
  298. mib := []_C_int{CTL_KERN, KERN_OSTYPE}
  299. n := unsafe.Sizeof(uname.Sysname)
  300. if err := sysctl(mib, &uname.Sysname[0], &n, nil, 0); err != nil {
  301. return err
  302. }
  303. mib = []_C_int{CTL_KERN, KERN_HOSTNAME}
  304. n = unsafe.Sizeof(uname.Nodename)
  305. if err := sysctl(mib, &uname.Nodename[0], &n, nil, 0); err != nil {
  306. return err
  307. }
  308. mib = []_C_int{CTL_KERN, KERN_OSRELEASE}
  309. n = unsafe.Sizeof(uname.Release)
  310. if err := sysctl(mib, &uname.Release[0], &n, nil, 0); err != nil {
  311. return err
  312. }
  313. mib = []_C_int{CTL_KERN, KERN_VERSION}
  314. n = unsafe.Sizeof(uname.Version)
  315. if err := sysctl(mib, &uname.Version[0], &n, nil, 0); err != nil {
  316. return err
  317. }
  318. // The version might have newlines or tabs in it, convert them to
  319. // spaces.
  320. for i, b := range uname.Version {
  321. if b == '\n' || b == '\t' {
  322. if i == len(uname.Version)-1 {
  323. uname.Version[i] = 0
  324. } else {
  325. uname.Version[i] = ' '
  326. }
  327. }
  328. }
  329. mib = []_C_int{CTL_HW, HW_MACHINE}
  330. n = unsafe.Sizeof(uname.Machine)
  331. if err := sysctl(mib, &uname.Machine[0], &n, nil, 0); err != nil {
  332. return err
  333. }
  334. return nil
  335. }
  336. func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
  337. if raceenabled {
  338. raceReleaseMerge(unsafe.Pointer(&ioSync))
  339. }
  340. var length = int64(count)
  341. err = sendfile(infd, outfd, *offset, &length, nil, 0)
  342. written = int(length)
  343. return
  344. }
  345. func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) {
  346. var value IPMreqn
  347. vallen := _Socklen(SizeofIPMreqn)
  348. errno := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
  349. return &value, errno
  350. }
  351. func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) {
  352. return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq))
  353. }
  354. // GetsockoptXucred is a getsockopt wrapper that returns an Xucred struct.
  355. // The usual level and opt are SOL_LOCAL and LOCAL_PEERCRED, respectively.
  356. func GetsockoptXucred(fd, level, opt int) (*Xucred, error) {
  357. x := new(Xucred)
  358. vallen := _Socklen(SizeofXucred)
  359. err := getsockopt(fd, level, opt, unsafe.Pointer(x), &vallen)
  360. return x, err
  361. }
  362. func SysctlKinfoProcSlice(name string) ([]KinfoProc, error) {
  363. mib, err := sysctlmib(name)
  364. if err != nil {
  365. return nil, err
  366. }
  367. // Find size.
  368. n := uintptr(0)
  369. if err := sysctl(mib, nil, &n, nil, 0); err != nil {
  370. return nil, err
  371. }
  372. if n == 0 {
  373. return nil, nil
  374. }
  375. if n%SizeofKinfoProc != 0 {
  376. return nil, fmt.Errorf("sysctl() returned a size of %d, which is not a multiple of %d", n, SizeofKinfoProc)
  377. }
  378. // Read into buffer of that size.
  379. buf := make([]KinfoProc, n/SizeofKinfoProc)
  380. if err := sysctl(mib, (*byte)(unsafe.Pointer(&buf[0])), &n, nil, 0); err != nil {
  381. return nil, err
  382. }
  383. if n%SizeofKinfoProc != 0 {
  384. return nil, fmt.Errorf("sysctl() returned a size of %d, which is not a multiple of %d", n, SizeofKinfoProc)
  385. }
  386. // The actual call may return less than the original reported required
  387. // size so ensure we deal with that.
  388. return buf[:n/SizeofKinfoProc], nil
  389. }
  390. //sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error)
  391. //sys shmat(id int, addr uintptr, flag int) (ret uintptr, err error)
  392. //sys shmctl(id int, cmd int, buf *SysvShmDesc) (result int, err error)
  393. //sys shmdt(addr uintptr) (err error)
  394. //sys shmget(key int, size int, flag int) (id int, err error)
  395. /*
  396. * Exposed directly
  397. */
  398. //sys Access(path string, mode uint32) (err error)
  399. //sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
  400. //sys Chdir(path string) (err error)
  401. //sys Chflags(path string, flags int) (err error)
  402. //sys Chmod(path string, mode uint32) (err error)
  403. //sys Chown(path string, uid int, gid int) (err error)
  404. //sys Chroot(path string) (err error)
  405. //sys ClockGettime(clockid int32, time *Timespec) (err error)
  406. //sys Close(fd int) (err error)
  407. //sys Clonefile(src string, dst string, flags int) (err error)
  408. //sys Clonefileat(srcDirfd int, src string, dstDirfd int, dst string, flags int) (err error)
  409. //sys Dup(fd int) (nfd int, err error)
  410. //sys Dup2(from int, to int) (err error)
  411. //sys Exchangedata(path1 string, path2 string, options int) (err error)
  412. //sys Exit(code int)
  413. //sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
  414. //sys Fchdir(fd int) (err error)
  415. //sys Fchflags(fd int, flags int) (err error)
  416. //sys Fchmod(fd int, mode uint32) (err error)
  417. //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
  418. //sys Fchown(fd int, uid int, gid int) (err error)
  419. //sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
  420. //sys Fclonefileat(srcDirfd int, dstDirfd int, dst string, flags int) (err error)
  421. //sys Flock(fd int, how int) (err error)
  422. //sys Fpathconf(fd int, name int) (val int, err error)
  423. //sys Fsync(fd int) (err error)
  424. //sys Ftruncate(fd int, length int64) (err error)
  425. //sys Getcwd(buf []byte) (n int, err error)
  426. //sys Getdtablesize() (size int)
  427. //sysnb Getegid() (egid int)
  428. //sysnb Geteuid() (uid int)
  429. //sysnb Getgid() (gid int)
  430. //sysnb Getpgid(pid int) (pgid int, err error)
  431. //sysnb Getpgrp() (pgrp int)
  432. //sysnb Getpid() (pid int)
  433. //sysnb Getppid() (ppid int)
  434. //sys Getpriority(which int, who int) (prio int, err error)
  435. //sysnb Getrlimit(which int, lim *Rlimit) (err error)
  436. //sysnb Getrusage(who int, rusage *Rusage) (err error)
  437. //sysnb Getsid(pid int) (sid int, err error)
  438. //sysnb Gettimeofday(tp *Timeval) (err error)
  439. //sysnb Getuid() (uid int)
  440. //sysnb Issetugid() (tainted bool)
  441. //sys Kqueue() (fd int, err error)
  442. //sys Lchown(path string, uid int, gid int) (err error)
  443. //sys Link(path string, link string) (err error)
  444. //sys Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error)
  445. //sys Listen(s int, backlog int) (err error)
  446. //sys Mkdir(path string, mode uint32) (err error)
  447. //sys Mkdirat(dirfd int, path string, mode uint32) (err error)
  448. //sys Mkfifo(path string, mode uint32) (err error)
  449. //sys Mknod(path string, mode uint32, dev int) (err error)
  450. //sys Open(path string, mode int, perm uint32) (fd int, err error)
  451. //sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error)
  452. //sys Pathconf(path string, name int) (val int, err error)
  453. //sys Pread(fd int, p []byte, offset int64) (n int, err error)
  454. //sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
  455. //sys read(fd int, p []byte) (n int, err error)
  456. //sys Readlink(path string, buf []byte) (n int, err error)
  457. //sys Readlinkat(dirfd int, path string, buf []byte) (n int, err error)
  458. //sys Rename(from string, to string) (err error)
  459. //sys Renameat(fromfd int, from string, tofd int, to string) (err error)
  460. //sys Revoke(path string) (err error)
  461. //sys Rmdir(path string) (err error)
  462. //sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
  463. //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
  464. //sys Setegid(egid int) (err error)
  465. //sysnb Seteuid(euid int) (err error)
  466. //sysnb Setgid(gid int) (err error)
  467. //sys Setlogin(name string) (err error)
  468. //sysnb Setpgid(pid int, pgid int) (err error)
  469. //sys Setpriority(which int, who int, prio int) (err error)
  470. //sys Setprivexec(flag int) (err error)
  471. //sysnb Setregid(rgid int, egid int) (err error)
  472. //sysnb Setreuid(ruid int, euid int) (err error)
  473. //sysnb Setrlimit(which int, lim *Rlimit) (err error)
  474. //sysnb Setsid() (pid int, err error)
  475. //sysnb Settimeofday(tp *Timeval) (err error)
  476. //sysnb Setuid(uid int) (err error)
  477. //sys Symlink(path string, link string) (err error)
  478. //sys Symlinkat(oldpath string, newdirfd int, newpath string) (err error)
  479. //sys Sync() (err error)
  480. //sys Truncate(path string, length int64) (err error)
  481. //sys Umask(newmask int) (oldmask int)
  482. //sys Undelete(path string) (err error)
  483. //sys Unlink(path string) (err error)
  484. //sys Unlinkat(dirfd int, path string, flags int) (err error)
  485. //sys Unmount(path string, flags int) (err error)
  486. //sys write(fd int, p []byte) (n int, err error)
  487. //sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
  488. //sys munmap(addr uintptr, length uintptr) (err error)
  489. //sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
  490. //sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
  491. /*
  492. * Unimplemented
  493. */
  494. // Profil
  495. // Sigaction
  496. // Sigprocmask
  497. // Getlogin
  498. // Sigpending
  499. // Sigaltstack
  500. // Ioctl
  501. // Reboot
  502. // Execve
  503. // Vfork
  504. // Sbrk
  505. // Sstk
  506. // Ovadvise
  507. // Mincore
  508. // Setitimer
  509. // Swapon
  510. // Select
  511. // Sigsuspend
  512. // Readv
  513. // Writev
  514. // Nfssvc
  515. // Getfh
  516. // Quotactl
  517. // Mount
  518. // Csops
  519. // Waitid
  520. // Add_profil
  521. // Kdebug_trace
  522. // Sigreturn
  523. // Atsocket
  524. // Kqueue_from_portset_np
  525. // Kqueue_portset
  526. // Getattrlist
  527. // Setattrlist
  528. // Getdirentriesattr
  529. // Searchfs
  530. // Delete
  531. // Copyfile
  532. // Watchevent
  533. // Waitevent
  534. // Modwatch
  535. // Fsctl
  536. // Initgroups
  537. // Posix_spawn
  538. // Nfsclnt
  539. // Fhopen
  540. // Minherit
  541. // Semsys
  542. // Msgsys
  543. // Shmsys
  544. // Semctl
  545. // Semget
  546. // Semop
  547. // Msgctl
  548. // Msgget
  549. // Msgsnd
  550. // Msgrcv
  551. // Shm_open
  552. // Shm_unlink
  553. // Sem_open
  554. // Sem_close
  555. // Sem_unlink
  556. // Sem_wait
  557. // Sem_trywait
  558. // Sem_post
  559. // Sem_getvalue
  560. // Sem_init
  561. // Sem_destroy
  562. // Open_extended
  563. // Umask_extended
  564. // Stat_extended
  565. // Lstat_extended
  566. // Fstat_extended
  567. // Chmod_extended
  568. // Fchmod_extended
  569. // Access_extended
  570. // Settid
  571. // Gettid
  572. // Setsgroups
  573. // Getsgroups
  574. // Setwgroups
  575. // Getwgroups
  576. // Mkfifo_extended
  577. // Mkdir_extended
  578. // Identitysvc
  579. // Shared_region_check_np
  580. // Shared_region_map_np
  581. // __pthread_mutex_destroy
  582. // __pthread_mutex_init
  583. // __pthread_mutex_lock
  584. // __pthread_mutex_trylock
  585. // __pthread_mutex_unlock
  586. // __pthread_cond_init
  587. // __pthread_cond_destroy
  588. // __pthread_cond_broadcast
  589. // __pthread_cond_signal
  590. // Setsid_with_pid
  591. // __pthread_cond_timedwait
  592. // Aio_fsync
  593. // Aio_return
  594. // Aio_suspend
  595. // Aio_cancel
  596. // Aio_error
  597. // Aio_read
  598. // Aio_write
  599. // Lio_listio
  600. // __pthread_cond_wait
  601. // Iopolicysys
  602. // __pthread_kill
  603. // __pthread_sigmask
  604. // __sigwait
  605. // __disable_threadsignal
  606. // __pthread_markcancel
  607. // __pthread_canceled
  608. // __semwait_signal
  609. // Proc_info
  610. // sendfile
  611. // Stat64_extended
  612. // Lstat64_extended
  613. // Fstat64_extended
  614. // __pthread_chdir
  615. // __pthread_fchdir
  616. // Audit
  617. // Auditon
  618. // Getauid
  619. // Setauid
  620. // Getaudit
  621. // Setaudit
  622. // Getaudit_addr
  623. // Setaudit_addr
  624. // Auditctl
  625. // Bsdthread_create
  626. // Bsdthread_terminate
  627. // Stack_snapshot
  628. // Bsdthread_register
  629. // Workq_open
  630. // Workq_ops
  631. // __mac_execve
  632. // __mac_syscall
  633. // __mac_get_file
  634. // __mac_set_file
  635. // __mac_get_link
  636. // __mac_set_link
  637. // __mac_get_proc
  638. // __mac_set_proc
  639. // __mac_get_fd
  640. // __mac_set_fd
  641. // __mac_get_pid
  642. // __mac_get_lcid
  643. // __mac_get_lctx
  644. // __mac_set_lctx
  645. // Setlcid
  646. // Read_nocancel
  647. // Write_nocancel
  648. // Open_nocancel
  649. // Close_nocancel
  650. // Wait4_nocancel
  651. // Recvmsg_nocancel
  652. // Sendmsg_nocancel
  653. // Recvfrom_nocancel
  654. // Accept_nocancel
  655. // Fcntl_nocancel
  656. // Select_nocancel
  657. // Fsync_nocancel
  658. // Connect_nocancel
  659. // Sigsuspend_nocancel
  660. // Readv_nocancel
  661. // Writev_nocancel
  662. // Sendto_nocancel
  663. // Pread_nocancel
  664. // Pwrite_nocancel
  665. // Waitid_nocancel
  666. // Poll_nocancel
  667. // Msgsnd_nocancel
  668. // Msgrcv_nocancel
  669. // Sem_wait_nocancel
  670. // Aio_suspend_nocancel
  671. // __sigwait_nocancel
  672. // __semwait_signal_nocancel
  673. // __mac_mount
  674. // __mac_get_mount
  675. // __mac_getfsstat