syscall_bsd.go 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624
  1. // Copyright 2009 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. // +build darwin dragonfly freebsd netbsd openbsd
  5. // BSD system call wrappers shared by *BSD based systems
  6. // including OS X (Darwin) and FreeBSD. Like the other
  7. // syscall_*.go files it is compiled as Go code but also
  8. // used as input to mksyscall which parses the //sys
  9. // lines and generates system call stubs.
  10. package unix
  11. import (
  12. "runtime"
  13. "syscall"
  14. "unsafe"
  15. )
  16. /*
  17. * Wrapped
  18. */
  19. //sysnb getgroups(ngid int, gid *_Gid_t) (n int, err error)
  20. //sysnb setgroups(ngid int, gid *_Gid_t) (err error)
  21. func Getgroups() (gids []int, err error) {
  22. n, err := getgroups(0, nil)
  23. if err != nil {
  24. return nil, err
  25. }
  26. if n == 0 {
  27. return nil, nil
  28. }
  29. // Sanity check group count. Max is 16 on BSD.
  30. if n < 0 || n > 1000 {
  31. return nil, EINVAL
  32. }
  33. a := make([]_Gid_t, n)
  34. n, err = getgroups(n, &a[0])
  35. if err != nil {
  36. return nil, err
  37. }
  38. gids = make([]int, n)
  39. for i, v := range a[0:n] {
  40. gids[i] = int(v)
  41. }
  42. return
  43. }
  44. func Setgroups(gids []int) (err error) {
  45. if len(gids) == 0 {
  46. return setgroups(0, nil)
  47. }
  48. a := make([]_Gid_t, len(gids))
  49. for i, v := range gids {
  50. a[i] = _Gid_t(v)
  51. }
  52. return setgroups(len(a), &a[0])
  53. }
  54. func ReadDirent(fd int, buf []byte) (n int, err error) {
  55. // Final argument is (basep *uintptr) and the syscall doesn't take nil.
  56. // 64 bits should be enough. (32 bits isn't even on 386). Since the
  57. // actual system call is getdirentries64, 64 is a good guess.
  58. // TODO(rsc): Can we use a single global basep for all calls?
  59. var base = (*uintptr)(unsafe.Pointer(new(uint64)))
  60. return Getdirentries(fd, buf, base)
  61. }
  62. // Wait status is 7 bits at bottom, either 0 (exited),
  63. // 0x7F (stopped), or a signal number that caused an exit.
  64. // The 0x80 bit is whether there was a core dump.
  65. // An extra number (exit code, signal causing a stop)
  66. // is in the high bits.
  67. type WaitStatus uint32
  68. const (
  69. mask = 0x7F
  70. core = 0x80
  71. shift = 8
  72. exited = 0
  73. stopped = 0x7F
  74. )
  75. func (w WaitStatus) Exited() bool { return w&mask == exited }
  76. func (w WaitStatus) ExitStatus() int {
  77. if w&mask != exited {
  78. return -1
  79. }
  80. return int(w >> shift)
  81. }
  82. func (w WaitStatus) Signaled() bool { return w&mask != stopped && w&mask != 0 }
  83. func (w WaitStatus) Signal() syscall.Signal {
  84. sig := syscall.Signal(w & mask)
  85. if sig == stopped || sig == 0 {
  86. return -1
  87. }
  88. return sig
  89. }
  90. func (w WaitStatus) CoreDump() bool { return w.Signaled() && w&core != 0 }
  91. func (w WaitStatus) Stopped() bool { return w&mask == stopped && syscall.Signal(w>>shift) != SIGSTOP }
  92. func (w WaitStatus) Continued() bool { return w&mask == stopped && syscall.Signal(w>>shift) == SIGSTOP }
  93. func (w WaitStatus) StopSignal() syscall.Signal {
  94. if !w.Stopped() {
  95. return -1
  96. }
  97. return syscall.Signal(w>>shift) & 0xFF
  98. }
  99. func (w WaitStatus) TrapCause() int { return -1 }
  100. //sys wait4(pid int, wstatus *_C_int, options int, rusage *Rusage) (wpid int, err error)
  101. func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) {
  102. var status _C_int
  103. wpid, err = wait4(pid, &status, options, rusage)
  104. if wstatus != nil {
  105. *wstatus = WaitStatus(status)
  106. }
  107. return
  108. }
  109. //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error)
  110. //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
  111. //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error)
  112. //sysnb socket(domain int, typ int, proto int) (fd int, err error)
  113. //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error)
  114. //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error)
  115. //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
  116. //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error)
  117. //sys Shutdown(s int, how int) (err error)
  118. func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) {
  119. if sa.Port < 0 || sa.Port > 0xFFFF {
  120. return nil, 0, EINVAL
  121. }
  122. sa.raw.Len = SizeofSockaddrInet4
  123. sa.raw.Family = AF_INET
  124. p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
  125. p[0] = byte(sa.Port >> 8)
  126. p[1] = byte(sa.Port)
  127. for i := 0; i < len(sa.Addr); i++ {
  128. sa.raw.Addr[i] = sa.Addr[i]
  129. }
  130. return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
  131. }
  132. func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) {
  133. if sa.Port < 0 || sa.Port > 0xFFFF {
  134. return nil, 0, EINVAL
  135. }
  136. sa.raw.Len = SizeofSockaddrInet6
  137. sa.raw.Family = AF_INET6
  138. p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port))
  139. p[0] = byte(sa.Port >> 8)
  140. p[1] = byte(sa.Port)
  141. sa.raw.Scope_id = sa.ZoneId
  142. for i := 0; i < len(sa.Addr); i++ {
  143. sa.raw.Addr[i] = sa.Addr[i]
  144. }
  145. return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
  146. }
  147. func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) {
  148. name := sa.Name
  149. n := len(name)
  150. if n >= len(sa.raw.Path) || n == 0 {
  151. return nil, 0, EINVAL
  152. }
  153. sa.raw.Len = byte(3 + n) // 2 for Family, Len; 1 for NUL
  154. sa.raw.Family = AF_UNIX
  155. for i := 0; i < n; i++ {
  156. sa.raw.Path[i] = int8(name[i])
  157. }
  158. return unsafe.Pointer(&sa.raw), _Socklen(sa.raw.Len), nil
  159. }
  160. func (sa *SockaddrDatalink) sockaddr() (unsafe.Pointer, _Socklen, error) {
  161. if sa.Index == 0 {
  162. return nil, 0, EINVAL
  163. }
  164. sa.raw.Len = sa.Len
  165. sa.raw.Family = AF_LINK
  166. sa.raw.Index = sa.Index
  167. sa.raw.Type = sa.Type
  168. sa.raw.Nlen = sa.Nlen
  169. sa.raw.Alen = sa.Alen
  170. sa.raw.Slen = sa.Slen
  171. for i := 0; i < len(sa.raw.Data); i++ {
  172. sa.raw.Data[i] = sa.Data[i]
  173. }
  174. return unsafe.Pointer(&sa.raw), SizeofSockaddrDatalink, nil
  175. }
  176. func anyToSockaddr(rsa *RawSockaddrAny) (Sockaddr, error) {
  177. switch rsa.Addr.Family {
  178. case AF_LINK:
  179. pp := (*RawSockaddrDatalink)(unsafe.Pointer(rsa))
  180. sa := new(SockaddrDatalink)
  181. sa.Len = pp.Len
  182. sa.Family = pp.Family
  183. sa.Index = pp.Index
  184. sa.Type = pp.Type
  185. sa.Nlen = pp.Nlen
  186. sa.Alen = pp.Alen
  187. sa.Slen = pp.Slen
  188. for i := 0; i < len(sa.Data); i++ {
  189. sa.Data[i] = pp.Data[i]
  190. }
  191. return sa, nil
  192. case AF_UNIX:
  193. pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa))
  194. if pp.Len < 2 || pp.Len > SizeofSockaddrUnix {
  195. return nil, EINVAL
  196. }
  197. sa := new(SockaddrUnix)
  198. // Some BSDs include the trailing NUL in the length, whereas
  199. // others do not. Work around this by subtracting the leading
  200. // family and len. The path is then scanned to see if a NUL
  201. // terminator still exists within the length.
  202. n := int(pp.Len) - 2 // subtract leading Family, Len
  203. for i := 0; i < n; i++ {
  204. if pp.Path[i] == 0 {
  205. // found early NUL; assume Len included the NUL
  206. // or was overestimating.
  207. n = i
  208. break
  209. }
  210. }
  211. bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n]
  212. sa.Name = string(bytes)
  213. return sa, nil
  214. case AF_INET:
  215. pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa))
  216. sa := new(SockaddrInet4)
  217. p := (*[2]byte)(unsafe.Pointer(&pp.Port))
  218. sa.Port = int(p[0])<<8 + int(p[1])
  219. for i := 0; i < len(sa.Addr); i++ {
  220. sa.Addr[i] = pp.Addr[i]
  221. }
  222. return sa, nil
  223. case AF_INET6:
  224. pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa))
  225. sa := new(SockaddrInet6)
  226. p := (*[2]byte)(unsafe.Pointer(&pp.Port))
  227. sa.Port = int(p[0])<<8 + int(p[1])
  228. sa.ZoneId = pp.Scope_id
  229. for i := 0; i < len(sa.Addr); i++ {
  230. sa.Addr[i] = pp.Addr[i]
  231. }
  232. return sa, nil
  233. }
  234. return nil, EAFNOSUPPORT
  235. }
  236. func Accept(fd int) (nfd int, sa Sockaddr, err error) {
  237. var rsa RawSockaddrAny
  238. var len _Socklen = SizeofSockaddrAny
  239. nfd, err = accept(fd, &rsa, &len)
  240. if err != nil {
  241. return
  242. }
  243. if runtime.GOOS == "darwin" && len == 0 {
  244. // Accepted socket has no address.
  245. // This is likely due to a bug in xnu kernels,
  246. // where instead of ECONNABORTED error socket
  247. // is accepted, but has no address.
  248. Close(nfd)
  249. return 0, nil, ECONNABORTED
  250. }
  251. sa, err = anyToSockaddr(&rsa)
  252. if err != nil {
  253. Close(nfd)
  254. nfd = 0
  255. }
  256. return
  257. }
  258. func Getsockname(fd int) (sa Sockaddr, err error) {
  259. var rsa RawSockaddrAny
  260. var len _Socklen = SizeofSockaddrAny
  261. if err = getsockname(fd, &rsa, &len); err != nil {
  262. return
  263. }
  264. // TODO(jsing): DragonFly has a "bug" (see issue 3349), which should be
  265. // reported upstream.
  266. if runtime.GOOS == "dragonfly" && rsa.Addr.Family == AF_UNSPEC && rsa.Addr.Len == 0 {
  267. rsa.Addr.Family = AF_UNIX
  268. rsa.Addr.Len = SizeofSockaddrUnix
  269. }
  270. return anyToSockaddr(&rsa)
  271. }
  272. //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error)
  273. // GetsockoptString returns the string value of the socket option opt for the
  274. // socket associated with fd at the given socket level.
  275. func GetsockoptString(fd, level, opt int) (string, error) {
  276. buf := make([]byte, 256)
  277. vallen := _Socklen(len(buf))
  278. err := getsockopt(fd, level, opt, unsafe.Pointer(&buf[0]), &vallen)
  279. if err != nil {
  280. return "", err
  281. }
  282. return string(buf[:vallen-1]), nil
  283. }
  284. //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error)
  285. //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error)
  286. //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error)
  287. func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) {
  288. var msg Msghdr
  289. var rsa RawSockaddrAny
  290. msg.Name = (*byte)(unsafe.Pointer(&rsa))
  291. msg.Namelen = uint32(SizeofSockaddrAny)
  292. var iov Iovec
  293. if len(p) > 0 {
  294. iov.Base = (*byte)(unsafe.Pointer(&p[0]))
  295. iov.SetLen(len(p))
  296. }
  297. var dummy byte
  298. if len(oob) > 0 {
  299. // receive at least one normal byte
  300. if len(p) == 0 {
  301. iov.Base = &dummy
  302. iov.SetLen(1)
  303. }
  304. msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
  305. msg.SetControllen(len(oob))
  306. }
  307. msg.Iov = &iov
  308. msg.Iovlen = 1
  309. if n, err = recvmsg(fd, &msg, flags); err != nil {
  310. return
  311. }
  312. oobn = int(msg.Controllen)
  313. recvflags = int(msg.Flags)
  314. // source address is only specified if the socket is unconnected
  315. if rsa.Addr.Family != AF_UNSPEC {
  316. from, err = anyToSockaddr(&rsa)
  317. }
  318. return
  319. }
  320. //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error)
  321. func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) {
  322. _, err = SendmsgN(fd, p, oob, to, flags)
  323. return
  324. }
  325. func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) {
  326. var ptr unsafe.Pointer
  327. var salen _Socklen
  328. if to != nil {
  329. ptr, salen, err = to.sockaddr()
  330. if err != nil {
  331. return 0, err
  332. }
  333. }
  334. var msg Msghdr
  335. msg.Name = (*byte)(unsafe.Pointer(ptr))
  336. msg.Namelen = uint32(salen)
  337. var iov Iovec
  338. if len(p) > 0 {
  339. iov.Base = (*byte)(unsafe.Pointer(&p[0]))
  340. iov.SetLen(len(p))
  341. }
  342. var dummy byte
  343. if len(oob) > 0 {
  344. // send at least one normal byte
  345. if len(p) == 0 {
  346. iov.Base = &dummy
  347. iov.SetLen(1)
  348. }
  349. msg.Control = (*byte)(unsafe.Pointer(&oob[0]))
  350. msg.SetControllen(len(oob))
  351. }
  352. msg.Iov = &iov
  353. msg.Iovlen = 1
  354. if n, err = sendmsg(fd, &msg, flags); err != nil {
  355. return 0, err
  356. }
  357. if len(oob) > 0 && len(p) == 0 {
  358. n = 0
  359. }
  360. return n, nil
  361. }
  362. //sys kevent(kq int, change unsafe.Pointer, nchange int, event unsafe.Pointer, nevent int, timeout *Timespec) (n int, err error)
  363. func Kevent(kq int, changes, events []Kevent_t, timeout *Timespec) (n int, err error) {
  364. var change, event unsafe.Pointer
  365. if len(changes) > 0 {
  366. change = unsafe.Pointer(&changes[0])
  367. }
  368. if len(events) > 0 {
  369. event = unsafe.Pointer(&events[0])
  370. }
  371. return kevent(kq, change, len(changes), event, len(events), timeout)
  372. }
  373. //sys sysctl(mib []_C_int, old *byte, oldlen *uintptr, new *byte, newlen uintptr) (err error) = SYS___SYSCTL
  374. // sysctlmib translates name to mib number and appends any additional args.
  375. func sysctlmib(name string, args ...int) ([]_C_int, error) {
  376. // Translate name to mib number.
  377. mib, err := nametomib(name)
  378. if err != nil {
  379. return nil, err
  380. }
  381. for _, a := range args {
  382. mib = append(mib, _C_int(a))
  383. }
  384. return mib, nil
  385. }
  386. func Sysctl(name string) (string, error) {
  387. return SysctlArgs(name)
  388. }
  389. func SysctlArgs(name string, args ...int) (string, error) {
  390. buf, err := SysctlRaw(name, args...)
  391. if err != nil {
  392. return "", err
  393. }
  394. n := len(buf)
  395. // Throw away terminating NUL.
  396. if n > 0 && buf[n-1] == '\x00' {
  397. n--
  398. }
  399. return string(buf[0:n]), nil
  400. }
  401. func SysctlUint32(name string) (uint32, error) {
  402. return SysctlUint32Args(name)
  403. }
  404. func SysctlUint32Args(name string, args ...int) (uint32, error) {
  405. mib, err := sysctlmib(name, args...)
  406. if err != nil {
  407. return 0, err
  408. }
  409. n := uintptr(4)
  410. buf := make([]byte, 4)
  411. if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
  412. return 0, err
  413. }
  414. if n != 4 {
  415. return 0, EIO
  416. }
  417. return *(*uint32)(unsafe.Pointer(&buf[0])), nil
  418. }
  419. func SysctlUint64(name string, args ...int) (uint64, error) {
  420. mib, err := sysctlmib(name, args...)
  421. if err != nil {
  422. return 0, err
  423. }
  424. n := uintptr(8)
  425. buf := make([]byte, 8)
  426. if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
  427. return 0, err
  428. }
  429. if n != 8 {
  430. return 0, EIO
  431. }
  432. return *(*uint64)(unsafe.Pointer(&buf[0])), nil
  433. }
  434. func SysctlRaw(name string, args ...int) ([]byte, error) {
  435. mib, err := sysctlmib(name, args...)
  436. if err != nil {
  437. return nil, err
  438. }
  439. // Find size.
  440. n := uintptr(0)
  441. if err := sysctl(mib, nil, &n, nil, 0); err != nil {
  442. return nil, err
  443. }
  444. if n == 0 {
  445. return nil, nil
  446. }
  447. // Read into buffer of that size.
  448. buf := make([]byte, n)
  449. if err := sysctl(mib, &buf[0], &n, nil, 0); err != nil {
  450. return nil, err
  451. }
  452. // The actual call may return less than the original reported required
  453. // size so ensure we deal with that.
  454. return buf[:n], nil
  455. }
  456. //sys utimes(path string, timeval *[2]Timeval) (err error)
  457. func Utimes(path string, tv []Timeval) error {
  458. if tv == nil {
  459. return utimes(path, nil)
  460. }
  461. if len(tv) != 2 {
  462. return EINVAL
  463. }
  464. return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
  465. }
  466. func UtimesNano(path string, ts []Timespec) error {
  467. if ts == nil {
  468. err := utimensat(AT_FDCWD, path, nil, 0)
  469. if err != ENOSYS {
  470. return err
  471. }
  472. return utimes(path, nil)
  473. }
  474. if len(ts) != 2 {
  475. return EINVAL
  476. }
  477. // Darwin setattrlist can set nanosecond timestamps
  478. err := setattrlistTimes(path, ts, 0)
  479. if err != ENOSYS {
  480. return err
  481. }
  482. err = utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0)
  483. if err != ENOSYS {
  484. return err
  485. }
  486. // Not as efficient as it could be because Timespec and
  487. // Timeval have different types in the different OSes
  488. tv := [2]Timeval{
  489. NsecToTimeval(TimespecToNsec(ts[0])),
  490. NsecToTimeval(TimespecToNsec(ts[1])),
  491. }
  492. return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
  493. }
  494. func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error {
  495. if ts == nil {
  496. return utimensat(dirfd, path, nil, flags)
  497. }
  498. if len(ts) != 2 {
  499. return EINVAL
  500. }
  501. err := setattrlistTimes(path, ts, flags)
  502. if err != ENOSYS {
  503. return err
  504. }
  505. return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags)
  506. }
  507. //sys futimes(fd int, timeval *[2]Timeval) (err error)
  508. func Futimes(fd int, tv []Timeval) error {
  509. if tv == nil {
  510. return futimes(fd, nil)
  511. }
  512. if len(tv) != 2 {
  513. return EINVAL
  514. }
  515. return futimes(fd, (*[2]Timeval)(unsafe.Pointer(&tv[0])))
  516. }
  517. //sys fcntl(fd int, cmd int, arg int) (val int, err error)
  518. //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error)
  519. func Poll(fds []PollFd, timeout int) (n int, err error) {
  520. if len(fds) == 0 {
  521. return poll(nil, 0, timeout)
  522. }
  523. return poll(&fds[0], len(fds), timeout)
  524. }
  525. // TODO: wrap
  526. // Acct(name nil-string) (err error)
  527. // Gethostuuid(uuid *byte, timeout *Timespec) (err error)
  528. // Ptrace(req int, pid int, addr uintptr, data int) (ret uintptr, err error)
  529. var mapper = &mmapper{
  530. active: make(map[*byte][]byte),
  531. mmap: mmap,
  532. munmap: munmap,
  533. }
  534. func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) {
  535. return mapper.Mmap(fd, offset, length, prot, flags)
  536. }
  537. func Munmap(b []byte) (err error) {
  538. return mapper.Munmap(b)
  539. }
  540. //sys Madvise(b []byte, behav int) (err error)
  541. //sys Mlock(b []byte) (err error)
  542. //sys Mlockall(flags int) (err error)
  543. //sys Mprotect(b []byte, prot int) (err error)
  544. //sys Msync(b []byte, flags int) (err error)
  545. //sys Munlock(b []byte) (err error)
  546. //sys Munlockall() (err error)