syscall_darwin.go 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772
  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. if err == nil {
  141. p[0] = int(x[0])
  142. p[1] = int(x[1])
  143. }
  144. return
  145. }
  146. func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
  147. var _p0 unsafe.Pointer
  148. var bufsize uintptr
  149. if len(buf) > 0 {
  150. _p0 = unsafe.Pointer(&buf[0])
  151. bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
  152. }
  153. return getfsstat(_p0, bufsize, flags)
  154. }
  155. func xattrPointer(dest []byte) *byte {
  156. // It's only when dest is set to NULL that the OS X implementations of
  157. // getxattr() and listxattr() return the current sizes of the named attributes.
  158. // An empty byte array is not sufficient. To maintain the same behaviour as the
  159. // linux implementation, we wrap around the system calls and pass in NULL when
  160. // dest is empty.
  161. var destp *byte
  162. if len(dest) > 0 {
  163. destp = &dest[0]
  164. }
  165. return destp
  166. }
  167. //sys getxattr(path string, attr string, dest *byte, size int, position uint32, options int) (sz int, err error)
  168. func Getxattr(path string, attr string, dest []byte) (sz int, err error) {
  169. return getxattr(path, attr, xattrPointer(dest), len(dest), 0, 0)
  170. }
  171. func Lgetxattr(link string, attr string, dest []byte) (sz int, err error) {
  172. return getxattr(link, attr, xattrPointer(dest), len(dest), 0, XATTR_NOFOLLOW)
  173. }
  174. //sys fgetxattr(fd int, attr string, dest *byte, size int, position uint32, options int) (sz int, err error)
  175. func Fgetxattr(fd int, attr string, dest []byte) (sz int, err error) {
  176. return fgetxattr(fd, attr, xattrPointer(dest), len(dest), 0, 0)
  177. }
  178. //sys setxattr(path string, attr string, data *byte, size int, position uint32, options int) (err error)
  179. func Setxattr(path string, attr string, data []byte, flags int) (err error) {
  180. // The parameters for the OS X implementation vary slightly compared to the
  181. // linux system call, specifically the position parameter:
  182. //
  183. // linux:
  184. // int setxattr(
  185. // const char *path,
  186. // const char *name,
  187. // const void *value,
  188. // size_t size,
  189. // int flags
  190. // );
  191. //
  192. // darwin:
  193. // int setxattr(
  194. // const char *path,
  195. // const char *name,
  196. // void *value,
  197. // size_t size,
  198. // u_int32_t position,
  199. // int options
  200. // );
  201. //
  202. // position specifies the offset within the extended attribute. In the
  203. // current implementation, only the resource fork extended attribute makes
  204. // use of this argument. For all others, position is reserved. We simply
  205. // default to setting it to zero.
  206. return setxattr(path, attr, xattrPointer(data), len(data), 0, flags)
  207. }
  208. func Lsetxattr(link string, attr string, data []byte, flags int) (err error) {
  209. return setxattr(link, attr, xattrPointer(data), len(data), 0, flags|XATTR_NOFOLLOW)
  210. }
  211. //sys fsetxattr(fd int, attr string, data *byte, size int, position uint32, options int) (err error)
  212. func Fsetxattr(fd int, attr string, data []byte, flags int) (err error) {
  213. return fsetxattr(fd, attr, xattrPointer(data), len(data), 0, 0)
  214. }
  215. //sys removexattr(path string, attr string, options int) (err error)
  216. func Removexattr(path string, attr string) (err error) {
  217. // We wrap around and explicitly zero out the options provided to the OS X
  218. // implementation of removexattr, we do so for interoperability with the
  219. // linux variant.
  220. return removexattr(path, attr, 0)
  221. }
  222. func Lremovexattr(link string, attr string) (err error) {
  223. return removexattr(link, attr, XATTR_NOFOLLOW)
  224. }
  225. //sys fremovexattr(fd int, attr string, options int) (err error)
  226. func Fremovexattr(fd int, attr string) (err error) {
  227. return fremovexattr(fd, attr, 0)
  228. }
  229. //sys listxattr(path string, dest *byte, size int, options int) (sz int, err error)
  230. func Listxattr(path string, dest []byte) (sz int, err error) {
  231. return listxattr(path, xattrPointer(dest), len(dest), 0)
  232. }
  233. func Llistxattr(link string, dest []byte) (sz int, err error) {
  234. return listxattr(link, xattrPointer(dest), len(dest), XATTR_NOFOLLOW)
  235. }
  236. //sys flistxattr(fd int, dest *byte, size int, options int) (sz int, err error)
  237. func Flistxattr(fd int, dest []byte) (sz int, err error) {
  238. return flistxattr(fd, xattrPointer(dest), len(dest), 0)
  239. }
  240. func setattrlistTimes(path string, times []Timespec, flags int) error {
  241. _p0, err := BytePtrFromString(path)
  242. if err != nil {
  243. return err
  244. }
  245. var attrList attrList
  246. attrList.bitmapCount = ATTR_BIT_MAP_COUNT
  247. attrList.CommonAttr = ATTR_CMN_MODTIME | ATTR_CMN_ACCTIME
  248. // order is mtime, atime: the opposite of Chtimes
  249. attributes := [2]Timespec{times[1], times[0]}
  250. options := 0
  251. if flags&AT_SYMLINK_NOFOLLOW != 0 {
  252. options |= FSOPT_NOFOLLOW
  253. }
  254. return setattrlist(
  255. _p0,
  256. unsafe.Pointer(&attrList),
  257. unsafe.Pointer(&attributes),
  258. unsafe.Sizeof(attributes),
  259. options)
  260. }
  261. //sys setattrlist(path *byte, list unsafe.Pointer, buf unsafe.Pointer, size uintptr, options int) (err error)
  262. func utimensat(dirfd int, path string, times *[2]Timespec, flags int) error {
  263. // Darwin doesn't support SYS_UTIMENSAT
  264. return ENOSYS
  265. }
  266. /*
  267. * Wrapped
  268. */
  269. //sys fcntl(fd int, cmd int, arg int) (val int, err error)
  270. //sys kill(pid int, signum int, posix int) (err error)
  271. func Kill(pid int, signum syscall.Signal) (err error) { return kill(pid, int(signum), 1) }
  272. //sys ioctl(fd int, req uint, arg uintptr) (err error)
  273. func IoctlCtlInfo(fd int, ctlInfo *CtlInfo) error {
  274. err := ioctl(fd, CTLIOCGINFO, uintptr(unsafe.Pointer(ctlInfo)))
  275. runtime.KeepAlive(ctlInfo)
  276. return err
  277. }
  278. // IfreqMTU is struct ifreq used to get or set a network device's MTU.
  279. type IfreqMTU struct {
  280. Name [IFNAMSIZ]byte
  281. MTU int32
  282. }
  283. // IoctlGetIfreqMTU performs the SIOCGIFMTU ioctl operation on fd to get the MTU
  284. // of the network device specified by ifname.
  285. func IoctlGetIfreqMTU(fd int, ifname string) (*IfreqMTU, error) {
  286. var ifreq IfreqMTU
  287. copy(ifreq.Name[:], ifname)
  288. err := ioctl(fd, SIOCGIFMTU, uintptr(unsafe.Pointer(&ifreq)))
  289. return &ifreq, err
  290. }
  291. // IoctlSetIfreqMTU performs the SIOCSIFMTU ioctl operation on fd to set the MTU
  292. // of the network device specified by ifreq.Name.
  293. func IoctlSetIfreqMTU(fd int, ifreq *IfreqMTU) error {
  294. err := ioctl(fd, SIOCSIFMTU, uintptr(unsafe.Pointer(ifreq)))
  295. runtime.KeepAlive(ifreq)
  296. return err
  297. }
  298. //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS_SYSCTL
  299. func Uname(uname *Utsname) error {
  300. mib := []_C_int{CTL_KERN, KERN_OSTYPE}
  301. n := unsafe.Sizeof(uname.Sysname)
  302. if err := sysctl(mib, &uname.Sysname[0], &n, nil, 0); err != nil {
  303. return err
  304. }
  305. mib = []_C_int{CTL_KERN, KERN_HOSTNAME}
  306. n = unsafe.Sizeof(uname.Nodename)
  307. if err := sysctl(mib, &uname.Nodename[0], &n, nil, 0); err != nil {
  308. return err
  309. }
  310. mib = []_C_int{CTL_KERN, KERN_OSRELEASE}
  311. n = unsafe.Sizeof(uname.Release)
  312. if err := sysctl(mib, &uname.Release[0], &n, nil, 0); err != nil {
  313. return err
  314. }
  315. mib = []_C_int{CTL_KERN, KERN_VERSION}
  316. n = unsafe.Sizeof(uname.Version)
  317. if err := sysctl(mib, &uname.Version[0], &n, nil, 0); err != nil {
  318. return err
  319. }
  320. // The version might have newlines or tabs in it, convert them to
  321. // spaces.
  322. for i, b := range uname.Version {
  323. if b == '\n' || b == '\t' {
  324. if i == len(uname.Version)-1 {
  325. uname.Version[i] = 0
  326. } else {
  327. uname.Version[i] = ' '
  328. }
  329. }
  330. }
  331. mib = []_C_int{CTL_HW, HW_MACHINE}
  332. n = unsafe.Sizeof(uname.Machine)
  333. if err := sysctl(mib, &uname.Machine[0], &n, nil, 0); err != nil {
  334. return err
  335. }
  336. return nil
  337. }
  338. func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
  339. if raceenabled {
  340. raceReleaseMerge(unsafe.Pointer(&ioSync))
  341. }
  342. var length = int64(count)
  343. err = sendfile(infd, outfd, *offset, &length, nil, 0)
  344. written = int(length)
  345. return
  346. }
  347. func GetsockoptIPMreqn(fd, level, opt int) (*IPMreqn, error) {
  348. var value IPMreqn
  349. vallen := _Socklen(SizeofIPMreqn)
  350. errno := getsockopt(fd, level, opt, unsafe.Pointer(&value), &vallen)
  351. return &value, errno
  352. }
  353. func SetsockoptIPMreqn(fd, level, opt int, mreq *IPMreqn) (err error) {
  354. return setsockopt(fd, level, opt, unsafe.Pointer(mreq), unsafe.Sizeof(*mreq))
  355. }
  356. // GetsockoptXucred is a getsockopt wrapper that returns an Xucred struct.
  357. // The usual level and opt are SOL_LOCAL and LOCAL_PEERCRED, respectively.
  358. func GetsockoptXucred(fd, level, opt int) (*Xucred, error) {
  359. x := new(Xucred)
  360. vallen := _Socklen(SizeofXucred)
  361. err := getsockopt(fd, level, opt, unsafe.Pointer(x), &vallen)
  362. return x, err
  363. }
  364. func SysctlKinfoProc(name string, args ...int) (*KinfoProc, error) {
  365. mib, err := sysctlmib(name, args...)
  366. if err != nil {
  367. return nil, err
  368. }
  369. var kinfo KinfoProc
  370. n := uintptr(SizeofKinfoProc)
  371. if err := sysctl(mib, (*byte)(unsafe.Pointer(&kinfo)), &n, nil, 0); err != nil {
  372. return nil, err
  373. }
  374. if n != SizeofKinfoProc {
  375. return nil, EIO
  376. }
  377. return &kinfo, nil
  378. }
  379. func SysctlKinfoProcSlice(name string, args ...int) ([]KinfoProc, error) {
  380. mib, err := sysctlmib(name, args...)
  381. if err != nil {
  382. return nil, err
  383. }
  384. // Find size.
  385. n := uintptr(0)
  386. if err := sysctl(mib, nil, &n, nil, 0); err != nil {
  387. return nil, err
  388. }
  389. if n == 0 {
  390. return nil, nil
  391. }
  392. if n%SizeofKinfoProc != 0 {
  393. return nil, fmt.Errorf("sysctl() returned a size of %d, which is not a multiple of %d", n, SizeofKinfoProc)
  394. }
  395. // Read into buffer of that size.
  396. buf := make([]KinfoProc, n/SizeofKinfoProc)
  397. if err := sysctl(mib, (*byte)(unsafe.Pointer(&buf[0])), &n, nil, 0); err != nil {
  398. return nil, err
  399. }
  400. if n%SizeofKinfoProc != 0 {
  401. return nil, fmt.Errorf("sysctl() returned a size of %d, which is not a multiple of %d", n, SizeofKinfoProc)
  402. }
  403. // The actual call may return less than the original reported required
  404. // size so ensure we deal with that.
  405. return buf[:n/SizeofKinfoProc], nil
  406. }
  407. //sys sendfile(infd int, outfd int, offset int64, len *int64, hdtr unsafe.Pointer, flags int) (err error)
  408. //sys shmat(id int, addr uintptr, flag int) (ret uintptr, err error)
  409. //sys shmctl(id int, cmd int, buf *SysvShmDesc) (result int, err error)
  410. //sys shmdt(addr uintptr) (err error)
  411. //sys shmget(key int, size int, flag int) (id int, err error)
  412. /*
  413. * Exposed directly
  414. */
  415. //sys Access(path string, mode uint32) (err error)
  416. //sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
  417. //sys Chdir(path string) (err error)
  418. //sys Chflags(path string, flags int) (err error)
  419. //sys Chmod(path string, mode uint32) (err error)
  420. //sys Chown(path string, uid int, gid int) (err error)
  421. //sys Chroot(path string) (err error)
  422. //sys ClockGettime(clockid int32, time *Timespec) (err error)
  423. //sys Close(fd int) (err error)
  424. //sys Clonefile(src string, dst string, flags int) (err error)
  425. //sys Clonefileat(srcDirfd int, src string, dstDirfd int, dst string, flags int) (err error)
  426. //sys Dup(fd int) (nfd int, err error)
  427. //sys Dup2(from int, to int) (err error)
  428. //sys Exchangedata(path1 string, path2 string, options int) (err error)
  429. //sys Exit(code int)
  430. //sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
  431. //sys Fchdir(fd int) (err error)
  432. //sys Fchflags(fd int, flags int) (err error)
  433. //sys Fchmod(fd int, mode uint32) (err error)
  434. //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
  435. //sys Fchown(fd int, uid int, gid int) (err error)
  436. //sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
  437. //sys Fclonefileat(srcDirfd int, dstDirfd int, dst string, flags int) (err error)
  438. //sys Flock(fd int, how int) (err error)
  439. //sys Fpathconf(fd int, name int) (val int, err error)
  440. //sys Fsync(fd int) (err error)
  441. //sys Ftruncate(fd int, length int64) (err error)
  442. //sys Getcwd(buf []byte) (n int, err error)
  443. //sys Getdtablesize() (size int)
  444. //sysnb Getegid() (egid int)
  445. //sysnb Geteuid() (uid int)
  446. //sysnb Getgid() (gid int)
  447. //sysnb Getpgid(pid int) (pgid int, err error)
  448. //sysnb Getpgrp() (pgrp int)
  449. //sysnb Getpid() (pid int)
  450. //sysnb Getppid() (ppid int)
  451. //sys Getpriority(which int, who int) (prio int, err error)
  452. //sysnb Getrlimit(which int, lim *Rlimit) (err error)
  453. //sysnb Getrusage(who int, rusage *Rusage) (err error)
  454. //sysnb Getsid(pid int) (sid int, err error)
  455. //sysnb Gettimeofday(tp *Timeval) (err error)
  456. //sysnb Getuid() (uid int)
  457. //sysnb Issetugid() (tainted bool)
  458. //sys Kqueue() (fd int, err error)
  459. //sys Lchown(path string, uid int, gid int) (err error)
  460. //sys Link(path string, link string) (err error)
  461. //sys Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error)
  462. //sys Listen(s int, backlog int) (err error)
  463. //sys Mkdir(path string, mode uint32) (err error)
  464. //sys Mkdirat(dirfd int, path string, mode uint32) (err error)
  465. //sys Mkfifo(path string, mode uint32) (err error)
  466. //sys Mknod(path string, mode uint32, dev int) (err error)
  467. //sys Open(path string, mode int, perm uint32) (fd int, err error)
  468. //sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error)
  469. //sys Pathconf(path string, name int) (val int, err error)
  470. //sys Pread(fd int, p []byte, offset int64) (n int, err error)
  471. //sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
  472. //sys read(fd int, p []byte) (n int, err error)
  473. //sys Readlink(path string, buf []byte) (n int, err error)
  474. //sys Readlinkat(dirfd int, path string, buf []byte) (n int, err error)
  475. //sys Rename(from string, to string) (err error)
  476. //sys Renameat(fromfd int, from string, tofd int, to string) (err error)
  477. //sys Revoke(path string) (err error)
  478. //sys Rmdir(path string) (err error)
  479. //sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
  480. //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error)
  481. //sys Setegid(egid int) (err error)
  482. //sysnb Seteuid(euid int) (err error)
  483. //sysnb Setgid(gid int) (err error)
  484. //sys Setlogin(name string) (err error)
  485. //sysnb Setpgid(pid int, pgid int) (err error)
  486. //sys Setpriority(which int, who int, prio int) (err error)
  487. //sys Setprivexec(flag int) (err error)
  488. //sysnb Setregid(rgid int, egid int) (err error)
  489. //sysnb Setreuid(ruid int, euid int) (err error)
  490. //sysnb Setrlimit(which int, lim *Rlimit) (err error)
  491. //sysnb Setsid() (pid int, err error)
  492. //sysnb Settimeofday(tp *Timeval) (err error)
  493. //sysnb Setuid(uid int) (err error)
  494. //sys Symlink(path string, link string) (err error)
  495. //sys Symlinkat(oldpath string, newdirfd int, newpath string) (err error)
  496. //sys Sync() (err error)
  497. //sys Truncate(path string, length int64) (err error)
  498. //sys Umask(newmask int) (oldmask int)
  499. //sys Undelete(path string) (err error)
  500. //sys Unlink(path string) (err error)
  501. //sys Unlinkat(dirfd int, path string, flags int) (err error)
  502. //sys Unmount(path string, flags int) (err error)
  503. //sys write(fd int, p []byte) (n int, err error)
  504. //sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
  505. //sys munmap(addr uintptr, length uintptr) (err error)
  506. //sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
  507. //sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
  508. /*
  509. * Unimplemented
  510. */
  511. // Profil
  512. // Sigaction
  513. // Sigprocmask
  514. // Getlogin
  515. // Sigpending
  516. // Sigaltstack
  517. // Ioctl
  518. // Reboot
  519. // Execve
  520. // Vfork
  521. // Sbrk
  522. // Sstk
  523. // Ovadvise
  524. // Mincore
  525. // Setitimer
  526. // Swapon
  527. // Select
  528. // Sigsuspend
  529. // Readv
  530. // Writev
  531. // Nfssvc
  532. // Getfh
  533. // Quotactl
  534. // Mount
  535. // Csops
  536. // Waitid
  537. // Add_profil
  538. // Kdebug_trace
  539. // Sigreturn
  540. // Atsocket
  541. // Kqueue_from_portset_np
  542. // Kqueue_portset
  543. // Getattrlist
  544. // Setattrlist
  545. // Getdirentriesattr
  546. // Searchfs
  547. // Delete
  548. // Copyfile
  549. // Watchevent
  550. // Waitevent
  551. // Modwatch
  552. // Fsctl
  553. // Initgroups
  554. // Posix_spawn
  555. // Nfsclnt
  556. // Fhopen
  557. // Minherit
  558. // Semsys
  559. // Msgsys
  560. // Shmsys
  561. // Semctl
  562. // Semget
  563. // Semop
  564. // Msgctl
  565. // Msgget
  566. // Msgsnd
  567. // Msgrcv
  568. // Shm_open
  569. // Shm_unlink
  570. // Sem_open
  571. // Sem_close
  572. // Sem_unlink
  573. // Sem_wait
  574. // Sem_trywait
  575. // Sem_post
  576. // Sem_getvalue
  577. // Sem_init
  578. // Sem_destroy
  579. // Open_extended
  580. // Umask_extended
  581. // Stat_extended
  582. // Lstat_extended
  583. // Fstat_extended
  584. // Chmod_extended
  585. // Fchmod_extended
  586. // Access_extended
  587. // Settid
  588. // Gettid
  589. // Setsgroups
  590. // Getsgroups
  591. // Setwgroups
  592. // Getwgroups
  593. // Mkfifo_extended
  594. // Mkdir_extended
  595. // Identitysvc
  596. // Shared_region_check_np
  597. // Shared_region_map_np
  598. // __pthread_mutex_destroy
  599. // __pthread_mutex_init
  600. // __pthread_mutex_lock
  601. // __pthread_mutex_trylock
  602. // __pthread_mutex_unlock
  603. // __pthread_cond_init
  604. // __pthread_cond_destroy
  605. // __pthread_cond_broadcast
  606. // __pthread_cond_signal
  607. // Setsid_with_pid
  608. // __pthread_cond_timedwait
  609. // Aio_fsync
  610. // Aio_return
  611. // Aio_suspend
  612. // Aio_cancel
  613. // Aio_error
  614. // Aio_read
  615. // Aio_write
  616. // Lio_listio
  617. // __pthread_cond_wait
  618. // Iopolicysys
  619. // __pthread_kill
  620. // __pthread_sigmask
  621. // __sigwait
  622. // __disable_threadsignal
  623. // __pthread_markcancel
  624. // __pthread_canceled
  625. // __semwait_signal
  626. // Proc_info
  627. // sendfile
  628. // Stat64_extended
  629. // Lstat64_extended
  630. // Fstat64_extended
  631. // __pthread_chdir
  632. // __pthread_fchdir
  633. // Audit
  634. // Auditon
  635. // Getauid
  636. // Setauid
  637. // Getaudit
  638. // Setaudit
  639. // Getaudit_addr
  640. // Setaudit_addr
  641. // Auditctl
  642. // Bsdthread_create
  643. // Bsdthread_terminate
  644. // Stack_snapshot
  645. // Bsdthread_register
  646. // Workq_open
  647. // Workq_ops
  648. // __mac_execve
  649. // __mac_syscall
  650. // __mac_get_file
  651. // __mac_set_file
  652. // __mac_get_link
  653. // __mac_set_link
  654. // __mac_get_proc
  655. // __mac_set_proc
  656. // __mac_get_fd
  657. // __mac_set_fd
  658. // __mac_get_pid
  659. // __mac_get_lcid
  660. // __mac_get_lctx
  661. // __mac_set_lctx
  662. // Setlcid
  663. // Read_nocancel
  664. // Write_nocancel
  665. // Open_nocancel
  666. // Close_nocancel
  667. // Wait4_nocancel
  668. // Recvmsg_nocancel
  669. // Sendmsg_nocancel
  670. // Recvfrom_nocancel
  671. // Accept_nocancel
  672. // Fcntl_nocancel
  673. // Select_nocancel
  674. // Fsync_nocancel
  675. // Connect_nocancel
  676. // Sigsuspend_nocancel
  677. // Readv_nocancel
  678. // Writev_nocancel
  679. // Sendto_nocancel
  680. // Pread_nocancel
  681. // Pwrite_nocancel
  682. // Waitid_nocancel
  683. // Poll_nocancel
  684. // Msgsnd_nocancel
  685. // Msgrcv_nocancel
  686. // Sem_wait_nocancel
  687. // Aio_suspend_nocancel
  688. // __sigwait_nocancel
  689. // __semwait_signal_nocancel
  690. // __mac_mount
  691. // __mac_get_mount
  692. // __mac_getfsstat