本站源代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

880 lines
24KB

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