A lightweight mechanism to provide an *instant kickstart* to a Go web server instance upon changing any Go source files under the project directory (and its subdirectories).

syscall_netbsd.go 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  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. // NetBSD 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. "syscall"
  14. "unsafe"
  15. )
  16. type SockaddrDatalink struct {
  17. Len uint8
  18. Family uint8
  19. Index uint16
  20. Type uint8
  21. Nlen uint8
  22. Alen uint8
  23. Slen uint8
  24. Data [12]int8
  25. raw RawSockaddrDatalink
  26. }
  27. func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
  28. func sysctlNodes(mib []_C_int) (nodes []Sysctlnode, err error) {
  29. var olen uintptr
  30. // Get a list of all sysctl nodes below the given MIB by performing
  31. // a sysctl for the given MIB with CTL_QUERY appended.
  32. mib = append(mib, CTL_QUERY)
  33. qnode := Sysctlnode{Flags: SYSCTL_VERS_1}
  34. qp := (*byte)(unsafe.Pointer(&qnode))
  35. sz := unsafe.Sizeof(qnode)
  36. if err = sysctl(mib, nil, &olen, qp, sz); err != nil {
  37. return nil, err
  38. }
  39. // Now that we know the size, get the actual nodes.
  40. nodes = make([]Sysctlnode, olen/sz)
  41. np := (*byte)(unsafe.Pointer(&nodes[0]))
  42. if err = sysctl(mib, np, &olen, qp, sz); err != nil {
  43. return nil, err
  44. }
  45. return nodes, nil
  46. }
  47. func nametomib(name string) (mib []_C_int, err error) {
  48. // Split name into components.
  49. var parts []string
  50. last := 0
  51. for i := 0; i < len(name); i++ {
  52. if name[i] == '.' {
  53. parts = append(parts, name[last:i])
  54. last = i + 1
  55. }
  56. }
  57. parts = append(parts, name[last:])
  58. // Discover the nodes and construct the MIB OID.
  59. for partno, part := range parts {
  60. nodes, err := sysctlNodes(mib)
  61. if err != nil {
  62. return nil, err
  63. }
  64. for _, node := range nodes {
  65. n := make([]byte, 0)
  66. for i := range node.Name {
  67. if node.Name[i] != 0 {
  68. n = append(n, byte(node.Name[i]))
  69. }
  70. }
  71. if string(n) == part {
  72. mib = append(mib, _C_int(node.Num))
  73. break
  74. }
  75. }
  76. if len(mib) != partno+1 {
  77. return nil, EINVAL
  78. }
  79. }
  80. return mib, nil
  81. }
  82. func direntIno(buf []byte) (uint64, bool) {
  83. return readInt(buf, unsafe.Offsetof(Dirent{}.Fileno), unsafe.Sizeof(Dirent{}.Fileno))
  84. }
  85. func direntReclen(buf []byte) (uint64, bool) {
  86. return readInt(buf, unsafe.Offsetof(Dirent{}.Reclen), unsafe.Sizeof(Dirent{}.Reclen))
  87. }
  88. func direntNamlen(buf []byte) (uint64, bool) {
  89. return readInt(buf, unsafe.Offsetof(Dirent{}.Namlen), unsafe.Sizeof(Dirent{}.Namlen))
  90. }
  91. //sysnb pipe() (fd1 int, fd2 int, err error)
  92. func Pipe(p []int) (err error) {
  93. if len(p) != 2 {
  94. return EINVAL
  95. }
  96. p[0], p[1], err = pipe()
  97. return
  98. }
  99. //sys getdents(fd int, buf []byte) (n int, err error)
  100. func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
  101. return getdents(fd, buf)
  102. }
  103. // TODO
  104. func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
  105. return -1, ENOSYS
  106. }
  107. /*
  108. * Exposed directly
  109. */
  110. //sys Access(path string, mode uint32) (err error)
  111. //sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
  112. //sys Chdir(path string) (err error)
  113. //sys Chflags(path string, flags int) (err error)
  114. //sys Chmod(path string, mode uint32) (err error)
  115. //sys Chown(path string, uid int, gid int) (err error)
  116. //sys Chroot(path string) (err error)
  117. //sys Close(fd int) (err error)
  118. //sys Dup(fd int) (nfd int, err error)
  119. //sys Dup2(from int, to int) (err error)
  120. //sys Exit(code int)
  121. //sys Fchdir(fd int) (err error)
  122. //sys Fchflags(fd int, flags int) (err error)
  123. //sys Fchmod(fd int, mode uint32) (err error)
  124. //sys Fchown(fd int, uid int, gid int) (err error)
  125. //sys Flock(fd int, how int) (err error)
  126. //sys Fpathconf(fd int, name int) (val int, err error)
  127. //sys Fstat(fd int, stat *Stat_t) (err error)
  128. //sys Fsync(fd int) (err error)
  129. //sys Ftruncate(fd int, length int64) (err error)
  130. //sysnb Getegid() (egid int)
  131. //sysnb Geteuid() (uid int)
  132. //sysnb Getgid() (gid int)
  133. //sysnb Getpgid(pid int) (pgid int, err error)
  134. //sysnb Getpgrp() (pgrp int)
  135. //sysnb Getpid() (pid int)
  136. //sysnb Getppid() (ppid int)
  137. //sys Getpriority(which int, who int) (prio int, err error)
  138. //sysnb Getrlimit(which int, lim *Rlimit) (err error)
  139. //sysnb Getrusage(who int, rusage *Rusage) (err error)
  140. //sysnb Getsid(pid int) (sid int, err error)
  141. //sysnb Gettimeofday(tv *Timeval) (err error)
  142. //sysnb Getuid() (uid int)
  143. //sys Issetugid() (tainted bool)
  144. //sys Kill(pid int, signum syscall.Signal) (err error)
  145. //sys Kqueue() (fd int, err error)
  146. //sys Lchown(path string, uid int, gid int) (err error)
  147. //sys Link(path string, link string) (err error)
  148. //sys Listen(s int, backlog int) (err error)
  149. //sys Lstat(path string, stat *Stat_t) (err error)
  150. //sys Mkdir(path string, mode uint32) (err error)
  151. //sys Mkfifo(path string, mode uint32) (err error)
  152. //sys Mknod(path string, mode uint32, dev int) (err error)
  153. //sys Mlock(b []byte) (err error)
  154. //sys Mlockall(flags int) (err error)
  155. //sys Mprotect(b []byte, prot int) (err error)
  156. //sys Munlock(b []byte) (err error)
  157. //sys Munlockall() (err error)
  158. //sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
  159. //sys Open(path string, mode int, perm uint32) (fd int, err error)
  160. //sys Pathconf(path string, name int) (val int, err error)
  161. //sys Pread(fd int, p []byte, offset int64) (n int, err error)
  162. //sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
  163. //sys read(fd int, p []byte) (n int, err error)
  164. //sys Readlink(path string, buf []byte) (n int, err error)
  165. //sys Rename(from string, to string) (err error)
  166. //sys Revoke(path string) (err error)
  167. //sys Rmdir(path string) (err error)
  168. //sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
  169. //sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
  170. //sysnb Setegid(egid int) (err error)
  171. //sysnb Seteuid(euid int) (err error)
  172. //sysnb Setgid(gid int) (err error)
  173. //sysnb Setpgid(pid int, pgid int) (err error)
  174. //sys Setpriority(which int, who int, prio int) (err error)
  175. //sysnb Setregid(rgid int, egid int) (err error)
  176. //sysnb Setreuid(ruid int, euid int) (err error)
  177. //sysnb Setrlimit(which int, lim *Rlimit) (err error)
  178. //sysnb Setsid() (pid int, err error)
  179. //sysnb Settimeofday(tp *Timeval) (err error)
  180. //sysnb Setuid(uid int) (err error)
  181. //sys Stat(path string, stat *Stat_t) (err error)
  182. //sys Symlink(path string, link string) (err error)
  183. //sys Sync() (err error)
  184. //sys Truncate(path string, length int64) (err error)
  185. //sys Umask(newmask int) (oldmask int)
  186. //sys Unlink(path string) (err error)
  187. //sys Unmount(path string, flags int) (err error)
  188. //sys write(fd int, p []byte) (n int, err error)
  189. //sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
  190. //sys munmap(addr uintptr, length uintptr) (err error)
  191. //sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
  192. //sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
  193. /*
  194. * Unimplemented
  195. */
  196. // ____semctl13
  197. // __clone
  198. // __fhopen40
  199. // __fhstat40
  200. // __fhstatvfs140
  201. // __fstat30
  202. // __getcwd
  203. // __getfh30
  204. // __getlogin
  205. // __lstat30
  206. // __mount50
  207. // __msgctl13
  208. // __msync13
  209. // __ntp_gettime30
  210. // __posix_chown
  211. // __posix_fadvise50
  212. // __posix_fchown
  213. // __posix_lchown
  214. // __posix_rename
  215. // __setlogin
  216. // __shmctl13
  217. // __sigaction_sigtramp
  218. // __sigaltstack14
  219. // __sigpending14
  220. // __sigprocmask14
  221. // __sigsuspend14
  222. // __sigtimedwait
  223. // __stat30
  224. // __syscall
  225. // __vfork14
  226. // _ksem_close
  227. // _ksem_destroy
  228. // _ksem_getvalue
  229. // _ksem_init
  230. // _ksem_open
  231. // _ksem_post
  232. // _ksem_trywait
  233. // _ksem_unlink
  234. // _ksem_wait
  235. // _lwp_continue
  236. // _lwp_create
  237. // _lwp_ctl
  238. // _lwp_detach
  239. // _lwp_exit
  240. // _lwp_getname
  241. // _lwp_getprivate
  242. // _lwp_kill
  243. // _lwp_park
  244. // _lwp_self
  245. // _lwp_setname
  246. // _lwp_setprivate
  247. // _lwp_suspend
  248. // _lwp_unpark
  249. // _lwp_unpark_all
  250. // _lwp_wait
  251. // _lwp_wakeup
  252. // _pset_bind
  253. // _sched_getaffinity
  254. // _sched_getparam
  255. // _sched_setaffinity
  256. // _sched_setparam
  257. // acct
  258. // aio_cancel
  259. // aio_error
  260. // aio_fsync
  261. // aio_read
  262. // aio_return
  263. // aio_suspend
  264. // aio_write
  265. // break
  266. // clock_getres
  267. // clock_gettime
  268. // clock_settime
  269. // compat_09_ogetdomainname
  270. // compat_09_osetdomainname
  271. // compat_09_ouname
  272. // compat_10_omsgsys
  273. // compat_10_osemsys
  274. // compat_10_oshmsys
  275. // compat_12_fstat12
  276. // compat_12_getdirentries
  277. // compat_12_lstat12
  278. // compat_12_msync
  279. // compat_12_oreboot
  280. // compat_12_oswapon
  281. // compat_12_stat12
  282. // compat_13_sigaction13
  283. // compat_13_sigaltstack13
  284. // compat_13_sigpending13
  285. // compat_13_sigprocmask13
  286. // compat_13_sigreturn13
  287. // compat_13_sigsuspend13
  288. // compat_14___semctl
  289. // compat_14_msgctl
  290. // compat_14_shmctl
  291. // compat_16___sigaction14
  292. // compat_16___sigreturn14
  293. // compat_20_fhstatfs
  294. // compat_20_fstatfs
  295. // compat_20_getfsstat
  296. // compat_20_statfs
  297. // compat_30___fhstat30
  298. // compat_30___fstat13
  299. // compat_30___lstat13
  300. // compat_30___stat13
  301. // compat_30_fhopen
  302. // compat_30_fhstat
  303. // compat_30_fhstatvfs1
  304. // compat_30_getdents
  305. // compat_30_getfh
  306. // compat_30_ntp_gettime
  307. // compat_30_socket
  308. // compat_40_mount
  309. // compat_43_fstat43
  310. // compat_43_lstat43
  311. // compat_43_oaccept
  312. // compat_43_ocreat
  313. // compat_43_oftruncate
  314. // compat_43_ogetdirentries
  315. // compat_43_ogetdtablesize
  316. // compat_43_ogethostid
  317. // compat_43_ogethostname
  318. // compat_43_ogetkerninfo
  319. // compat_43_ogetpagesize
  320. // compat_43_ogetpeername
  321. // compat_43_ogetrlimit
  322. // compat_43_ogetsockname
  323. // compat_43_okillpg
  324. // compat_43_olseek
  325. // compat_43_ommap
  326. // compat_43_oquota
  327. // compat_43_orecv
  328. // compat_43_orecvfrom
  329. // compat_43_orecvmsg
  330. // compat_43_osend
  331. // compat_43_osendmsg
  332. // compat_43_osethostid
  333. // compat_43_osethostname
  334. // compat_43_osetrlimit
  335. // compat_43_osigblock
  336. // compat_43_osigsetmask
  337. // compat_43_osigstack
  338. // compat_43_osigvec
  339. // compat_43_otruncate
  340. // compat_43_owait
  341. // compat_43_stat43
  342. // execve
  343. // extattr_delete_fd
  344. // extattr_delete_file
  345. // extattr_delete_link
  346. // extattr_get_fd
  347. // extattr_get_file
  348. // extattr_get_link
  349. // extattr_list_fd
  350. // extattr_list_file
  351. // extattr_list_link
  352. // extattr_set_fd
  353. // extattr_set_file
  354. // extattr_set_link
  355. // extattrctl
  356. // fchroot
  357. // fdatasync
  358. // fgetxattr
  359. // fktrace
  360. // flistxattr
  361. // fork
  362. // fremovexattr
  363. // fsetxattr
  364. // fstatvfs1
  365. // fsync_range
  366. // getcontext
  367. // getitimer
  368. // getvfsstat
  369. // getxattr
  370. // ioctl
  371. // ktrace
  372. // lchflags
  373. // lchmod
  374. // lfs_bmapv
  375. // lfs_markv
  376. // lfs_segclean
  377. // lfs_segwait
  378. // lgetxattr
  379. // lio_listio
  380. // listxattr
  381. // llistxattr
  382. // lremovexattr
  383. // lseek
  384. // lsetxattr
  385. // lutimes
  386. // madvise
  387. // mincore
  388. // minherit
  389. // modctl
  390. // mq_close
  391. // mq_getattr
  392. // mq_notify
  393. // mq_open
  394. // mq_receive
  395. // mq_send
  396. // mq_setattr
  397. // mq_timedreceive
  398. // mq_timedsend
  399. // mq_unlink
  400. // mremap
  401. // msgget
  402. // msgrcv
  403. // msgsnd
  404. // nfssvc
  405. // ntp_adjtime
  406. // pmc_control
  407. // pmc_get_info
  408. // poll
  409. // pollts
  410. // preadv
  411. // profil
  412. // pselect
  413. // pset_assign
  414. // pset_create
  415. // pset_destroy
  416. // ptrace
  417. // pwritev
  418. // quotactl
  419. // rasctl
  420. // readv
  421. // reboot
  422. // removexattr
  423. // sa_enable
  424. // sa_preempt
  425. // sa_register
  426. // sa_setconcurrency
  427. // sa_stacks
  428. // sa_yield
  429. // sbrk
  430. // sched_yield
  431. // semconfig
  432. // semget
  433. // semop
  434. // setcontext
  435. // setitimer
  436. // setxattr
  437. // shmat
  438. // shmdt
  439. // shmget
  440. // sstk
  441. // statvfs1
  442. // swapctl
  443. // sysarch
  444. // syscall
  445. // timer_create
  446. // timer_delete
  447. // timer_getoverrun
  448. // timer_gettime
  449. // timer_settime
  450. // undelete
  451. // utrace
  452. // uuidgen
  453. // vadvise
  454. // vfork
  455. // writev