]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blob - vendor/golang.org/x/sys/unix/syscall_netbsd.go
Merge branch 'fix_read_test' of github.com:alexandreFre/terraform-provider-statuscake
[github/fretlink/terraform-provider-statuscake.git] / vendor / golang.org / x / sys / unix / syscall_netbsd.go
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
5 // NetBSD system calls.
6 // This file is compiled as ordinary Go code,
7 // but it is also input to mksyscall,
8 // which parses the //sys lines and generates system call stubs.
9 // Note that sometimes we use a lowercase //sys name and wrap
10 // it in our own nicer implementation, either here or in
11 // syscall_bsd.go or syscall_unix.go.
12
13 package unix
14
15 import (
16 "runtime"
17 "syscall"
18 "unsafe"
19 )
20
21 // SockaddrDatalink implements the Sockaddr interface for AF_LINK type sockets.
22 type SockaddrDatalink struct {
23 Len uint8
24 Family uint8
25 Index uint16
26 Type uint8
27 Nlen uint8
28 Alen uint8
29 Slen uint8
30 Data [12]int8
31 raw RawSockaddrDatalink
32 }
33
34 func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
35
36 func sysctlNodes(mib []_C_int) (nodes []Sysctlnode, err error) {
37 var olen uintptr
38
39 // Get a list of all sysctl nodes below the given MIB by performing
40 // a sysctl for the given MIB with CTL_QUERY appended.
41 mib = append(mib, CTL_QUERY)
42 qnode := Sysctlnode{Flags: SYSCTL_VERS_1}
43 qp := (*byte)(unsafe.Pointer(&qnode))
44 sz := unsafe.Sizeof(qnode)
45 if err = sysctl(mib, nil, &olen, qp, sz); err != nil {
46 return nil, err
47 }
48
49 // Now that we know the size, get the actual nodes.
50 nodes = make([]Sysctlnode, olen/sz)
51 np := (*byte)(unsafe.Pointer(&nodes[0]))
52 if err = sysctl(mib, np, &olen, qp, sz); err != nil {
53 return nil, err
54 }
55
56 return nodes, nil
57 }
58
59 func nametomib(name string) (mib []_C_int, err error) {
60 // Split name into components.
61 var parts []string
62 last := 0
63 for i := 0; i < len(name); i++ {
64 if name[i] == '.' {
65 parts = append(parts, name[last:i])
66 last = i + 1
67 }
68 }
69 parts = append(parts, name[last:])
70
71 // Discover the nodes and construct the MIB OID.
72 for partno, part := range parts {
73 nodes, err := sysctlNodes(mib)
74 if err != nil {
75 return nil, err
76 }
77 for _, node := range nodes {
78 n := make([]byte, 0)
79 for i := range node.Name {
80 if node.Name[i] != 0 {
81 n = append(n, byte(node.Name[i]))
82 }
83 }
84 if string(n) == part {
85 mib = append(mib, _C_int(node.Num))
86 break
87 }
88 }
89 if len(mib) != partno+1 {
90 return nil, EINVAL
91 }
92 }
93
94 return mib, nil
95 }
96
97 func SysctlClockinfo(name string) (*Clockinfo, error) {
98 mib, err := sysctlmib(name)
99 if err != nil {
100 return nil, err
101 }
102
103 n := uintptr(SizeofClockinfo)
104 var ci Clockinfo
105 if err := sysctl(mib, (*byte)(unsafe.Pointer(&ci)), &n, nil, 0); err != nil {
106 return nil, err
107 }
108 if n != SizeofClockinfo {
109 return nil, EIO
110 }
111 return &ci, nil
112 }
113
114 //sysnb pipe() (fd1 int, fd2 int, err error)
115 func Pipe(p []int) (err error) {
116 if len(p) != 2 {
117 return EINVAL
118 }
119 p[0], p[1], err = pipe()
120 return
121 }
122
123 //sys getdents(fd int, buf []byte) (n int, err error)
124 func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
125 return getdents(fd, buf)
126 }
127
128 const ImplementsGetwd = true
129
130 //sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD
131
132 func Getwd() (string, error) {
133 var buf [PathMax]byte
134 _, err := Getcwd(buf[0:])
135 if err != nil {
136 return "", err
137 }
138 n := clen(buf[:])
139 if n < 1 {
140 return "", EINVAL
141 }
142 return string(buf[:n]), nil
143 }
144
145 // TODO
146 func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
147 return -1, ENOSYS
148 }
149
150 func setattrlistTimes(path string, times []Timespec, flags int) error {
151 // used on Darwin for UtimesNano
152 return ENOSYS
153 }
154
155 //sys ioctl(fd int, req uint, arg uintptr) (err error)
156
157 // ioctl itself should not be exposed directly, but additional get/set
158 // functions for specific types are permissible.
159
160 // IoctlSetInt performs an ioctl operation which sets an integer value
161 // on fd, using the specified request number.
162 func IoctlSetInt(fd int, req uint, value int) error {
163 return ioctl(fd, req, uintptr(value))
164 }
165
166 func ioctlSetWinsize(fd int, req uint, value *Winsize) error {
167 return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
168 }
169
170 func ioctlSetTermios(fd int, req uint, value *Termios) error {
171 return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
172 }
173
174 // IoctlGetInt performs an ioctl operation which gets an integer value
175 // from fd, using the specified request number.
176 func IoctlGetInt(fd int, req uint) (int, error) {
177 var value int
178 err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
179 return value, err
180 }
181
182 func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
183 var value Winsize
184 err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
185 return &value, err
186 }
187
188 func IoctlGetTermios(fd int, req uint) (*Termios, error) {
189 var value Termios
190 err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
191 return &value, err
192 }
193
194 func IoctlGetPtmget(fd int, req uint) (*Ptmget, error) {
195 var value Ptmget
196 err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
197 runtime.KeepAlive(value)
198 return &value, err
199 }
200
201 func Uname(uname *Utsname) error {
202 mib := []_C_int{CTL_KERN, KERN_OSTYPE}
203 n := unsafe.Sizeof(uname.Sysname)
204 if err := sysctl(mib, &uname.Sysname[0], &n, nil, 0); err != nil {
205 return err
206 }
207
208 mib = []_C_int{CTL_KERN, KERN_HOSTNAME}
209 n = unsafe.Sizeof(uname.Nodename)
210 if err := sysctl(mib, &uname.Nodename[0], &n, nil, 0); err != nil {
211 return err
212 }
213
214 mib = []_C_int{CTL_KERN, KERN_OSRELEASE}
215 n = unsafe.Sizeof(uname.Release)
216 if err := sysctl(mib, &uname.Release[0], &n, nil, 0); err != nil {
217 return err
218 }
219
220 mib = []_C_int{CTL_KERN, KERN_VERSION}
221 n = unsafe.Sizeof(uname.Version)
222 if err := sysctl(mib, &uname.Version[0], &n, nil, 0); err != nil {
223 return err
224 }
225
226 // The version might have newlines or tabs in it, convert them to
227 // spaces.
228 for i, b := range uname.Version {
229 if b == '\n' || b == '\t' {
230 if i == len(uname.Version)-1 {
231 uname.Version[i] = 0
232 } else {
233 uname.Version[i] = ' '
234 }
235 }
236 }
237
238 mib = []_C_int{CTL_HW, HW_MACHINE}
239 n = unsafe.Sizeof(uname.Machine)
240 if err := sysctl(mib, &uname.Machine[0], &n, nil, 0); err != nil {
241 return err
242 }
243
244 return nil
245 }
246
247 func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
248 if raceenabled {
249 raceReleaseMerge(unsafe.Pointer(&ioSync))
250 }
251 return sendfile(outfd, infd, offset, count)
252 }
253
254 /*
255 * Exposed directly
256 */
257 //sys Access(path string, mode uint32) (err error)
258 //sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
259 //sys Chdir(path string) (err error)
260 //sys Chflags(path string, flags int) (err error)
261 //sys Chmod(path string, mode uint32) (err error)
262 //sys Chown(path string, uid int, gid int) (err error)
263 //sys Chroot(path string) (err error)
264 //sys Close(fd int) (err error)
265 //sys Dup(fd int) (nfd int, err error)
266 //sys Dup2(from int, to int) (err error)
267 //sys Exit(code int)
268 //sys ExtattrGetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
269 //sys ExtattrSetFd(fd int, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
270 //sys ExtattrDeleteFd(fd int, attrnamespace int, attrname string) (err error)
271 //sys ExtattrListFd(fd int, attrnamespace int, data uintptr, nbytes int) (ret int, err error)
272 //sys ExtattrGetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
273 //sys ExtattrSetFile(file string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
274 //sys ExtattrDeleteFile(file string, attrnamespace int, attrname string) (err error)
275 //sys ExtattrListFile(file string, attrnamespace int, data uintptr, nbytes int) (ret int, err error)
276 //sys ExtattrGetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
277 //sys ExtattrSetLink(link string, attrnamespace int, attrname string, data uintptr, nbytes int) (ret int, err error)
278 //sys ExtattrDeleteLink(link string, attrnamespace int, attrname string) (err error)
279 //sys ExtattrListLink(link string, attrnamespace int, data uintptr, nbytes int) (ret int, err error)
280 //sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
281 //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = SYS_POSIX_FADVISE
282 //sys Fchdir(fd int) (err error)
283 //sys Fchflags(fd int, flags int) (err error)
284 //sys Fchmod(fd int, mode uint32) (err error)
285 //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
286 //sys Fchown(fd int, uid int, gid int) (err error)
287 //sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
288 //sys Flock(fd int, how int) (err error)
289 //sys Fpathconf(fd int, name int) (val int, err error)
290 //sys Fstat(fd int, stat *Stat_t) (err error)
291 //sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
292 //sys Fsync(fd int) (err error)
293 //sys Ftruncate(fd int, length int64) (err error)
294 //sysnb Getegid() (egid int)
295 //sysnb Geteuid() (uid int)
296 //sysnb Getgid() (gid int)
297 //sysnb Getpgid(pid int) (pgid int, err error)
298 //sysnb Getpgrp() (pgrp int)
299 //sysnb Getpid() (pid int)
300 //sysnb Getppid() (ppid int)
301 //sys Getpriority(which int, who int) (prio int, err error)
302 //sysnb Getrlimit(which int, lim *Rlimit) (err error)
303 //sysnb Getrusage(who int, rusage *Rusage) (err error)
304 //sysnb Getsid(pid int) (sid int, err error)
305 //sysnb Gettimeofday(tv *Timeval) (err error)
306 //sysnb Getuid() (uid int)
307 //sys Issetugid() (tainted bool)
308 //sys Kill(pid int, signum syscall.Signal) (err error)
309 //sys Kqueue() (fd int, err error)
310 //sys Lchown(path string, uid int, gid int) (err error)
311 //sys Link(path string, link string) (err error)
312 //sys Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error)
313 //sys Listen(s int, backlog int) (err error)
314 //sys Lstat(path string, stat *Stat_t) (err error)
315 //sys Mkdir(path string, mode uint32) (err error)
316 //sys Mkdirat(dirfd int, path string, mode uint32) (err error)
317 //sys Mkfifo(path string, mode uint32) (err error)
318 //sys Mkfifoat(dirfd int, path string, mode uint32) (err error)
319 //sys Mknod(path string, mode uint32, dev int) (err error)
320 //sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error)
321 //sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
322 //sys Open(path string, mode int, perm uint32) (fd int, err error)
323 //sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error)
324 //sys Pathconf(path string, name int) (val int, err error)
325 //sys Pread(fd int, p []byte, offset int64) (n int, err error)
326 //sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
327 //sys read(fd int, p []byte) (n int, err error)
328 //sys Readlink(path string, buf []byte) (n int, err error)
329 //sys Readlinkat(dirfd int, path string, buf []byte) (n int, err error)
330 //sys Rename(from string, to string) (err error)
331 //sys Renameat(fromfd int, from string, tofd int, to string) (err error)
332 //sys Revoke(path string) (err error)
333 //sys Rmdir(path string) (err error)
334 //sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
335 //sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
336 //sysnb Setegid(egid int) (err error)
337 //sysnb Seteuid(euid int) (err error)
338 //sysnb Setgid(gid int) (err error)
339 //sysnb Setpgid(pid int, pgid int) (err error)
340 //sys Setpriority(which int, who int, prio int) (err error)
341 //sysnb Setregid(rgid int, egid int) (err error)
342 //sysnb Setreuid(ruid int, euid int) (err error)
343 //sysnb Setrlimit(which int, lim *Rlimit) (err error)
344 //sysnb Setsid() (pid int, err error)
345 //sysnb Settimeofday(tp *Timeval) (err error)
346 //sysnb Setuid(uid int) (err error)
347 //sys Stat(path string, stat *Stat_t) (err error)
348 //sys Symlink(path string, link string) (err error)
349 //sys Symlinkat(oldpath string, newdirfd int, newpath string) (err error)
350 //sys Sync() (err error)
351 //sys Truncate(path string, length int64) (err error)
352 //sys Umask(newmask int) (oldmask int)
353 //sys Unlink(path string) (err error)
354 //sys Unlinkat(dirfd int, path string, flags int) (err error)
355 //sys Unmount(path string, flags int) (err error)
356 //sys write(fd int, p []byte) (n int, err error)
357 //sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
358 //sys munmap(addr uintptr, length uintptr) (err error)
359 //sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
360 //sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
361 //sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error)
362
363 /*
364 * Unimplemented
365 */
366 // ____semctl13
367 // __clone
368 // __fhopen40
369 // __fhstat40
370 // __fhstatvfs140
371 // __fstat30
372 // __getcwd
373 // __getfh30
374 // __getlogin
375 // __lstat30
376 // __mount50
377 // __msgctl13
378 // __msync13
379 // __ntp_gettime30
380 // __posix_chown
381 // __posix_fchown
382 // __posix_lchown
383 // __posix_rename
384 // __setlogin
385 // __shmctl13
386 // __sigaction_sigtramp
387 // __sigaltstack14
388 // __sigpending14
389 // __sigprocmask14
390 // __sigsuspend14
391 // __sigtimedwait
392 // __stat30
393 // __syscall
394 // __vfork14
395 // _ksem_close
396 // _ksem_destroy
397 // _ksem_getvalue
398 // _ksem_init
399 // _ksem_open
400 // _ksem_post
401 // _ksem_trywait
402 // _ksem_unlink
403 // _ksem_wait
404 // _lwp_continue
405 // _lwp_create
406 // _lwp_ctl
407 // _lwp_detach
408 // _lwp_exit
409 // _lwp_getname
410 // _lwp_getprivate
411 // _lwp_kill
412 // _lwp_park
413 // _lwp_self
414 // _lwp_setname
415 // _lwp_setprivate
416 // _lwp_suspend
417 // _lwp_unpark
418 // _lwp_unpark_all
419 // _lwp_wait
420 // _lwp_wakeup
421 // _pset_bind
422 // _sched_getaffinity
423 // _sched_getparam
424 // _sched_setaffinity
425 // _sched_setparam
426 // acct
427 // aio_cancel
428 // aio_error
429 // aio_fsync
430 // aio_read
431 // aio_return
432 // aio_suspend
433 // aio_write
434 // break
435 // clock_getres
436 // clock_gettime
437 // clock_settime
438 // compat_09_ogetdomainname
439 // compat_09_osetdomainname
440 // compat_09_ouname
441 // compat_10_omsgsys
442 // compat_10_osemsys
443 // compat_10_oshmsys
444 // compat_12_fstat12
445 // compat_12_getdirentries
446 // compat_12_lstat12
447 // compat_12_msync
448 // compat_12_oreboot
449 // compat_12_oswapon
450 // compat_12_stat12
451 // compat_13_sigaction13
452 // compat_13_sigaltstack13
453 // compat_13_sigpending13
454 // compat_13_sigprocmask13
455 // compat_13_sigreturn13
456 // compat_13_sigsuspend13
457 // compat_14___semctl
458 // compat_14_msgctl
459 // compat_14_shmctl
460 // compat_16___sigaction14
461 // compat_16___sigreturn14
462 // compat_20_fhstatfs
463 // compat_20_fstatfs
464 // compat_20_getfsstat
465 // compat_20_statfs
466 // compat_30___fhstat30
467 // compat_30___fstat13
468 // compat_30___lstat13
469 // compat_30___stat13
470 // compat_30_fhopen
471 // compat_30_fhstat
472 // compat_30_fhstatvfs1
473 // compat_30_getdents
474 // compat_30_getfh
475 // compat_30_ntp_gettime
476 // compat_30_socket
477 // compat_40_mount
478 // compat_43_fstat43
479 // compat_43_lstat43
480 // compat_43_oaccept
481 // compat_43_ocreat
482 // compat_43_oftruncate
483 // compat_43_ogetdirentries
484 // compat_43_ogetdtablesize
485 // compat_43_ogethostid
486 // compat_43_ogethostname
487 // compat_43_ogetkerninfo
488 // compat_43_ogetpagesize
489 // compat_43_ogetpeername
490 // compat_43_ogetrlimit
491 // compat_43_ogetsockname
492 // compat_43_okillpg
493 // compat_43_olseek
494 // compat_43_ommap
495 // compat_43_oquota
496 // compat_43_orecv
497 // compat_43_orecvfrom
498 // compat_43_orecvmsg
499 // compat_43_osend
500 // compat_43_osendmsg
501 // compat_43_osethostid
502 // compat_43_osethostname
503 // compat_43_osetrlimit
504 // compat_43_osigblock
505 // compat_43_osigsetmask
506 // compat_43_osigstack
507 // compat_43_osigvec
508 // compat_43_otruncate
509 // compat_43_owait
510 // compat_43_stat43
511 // execve
512 // extattr_delete_fd
513 // extattr_delete_file
514 // extattr_delete_link
515 // extattr_get_fd
516 // extattr_get_file
517 // extattr_get_link
518 // extattr_list_fd
519 // extattr_list_file
520 // extattr_list_link
521 // extattr_set_fd
522 // extattr_set_file
523 // extattr_set_link
524 // extattrctl
525 // fchroot
526 // fdatasync
527 // fgetxattr
528 // fktrace
529 // flistxattr
530 // fork
531 // fremovexattr
532 // fsetxattr
533 // fstatvfs1
534 // fsync_range
535 // getcontext
536 // getitimer
537 // getvfsstat
538 // getxattr
539 // ktrace
540 // lchflags
541 // lchmod
542 // lfs_bmapv
543 // lfs_markv
544 // lfs_segclean
545 // lfs_segwait
546 // lgetxattr
547 // lio_listio
548 // listxattr
549 // llistxattr
550 // lremovexattr
551 // lseek
552 // lsetxattr
553 // lutimes
554 // madvise
555 // mincore
556 // minherit
557 // modctl
558 // mq_close
559 // mq_getattr
560 // mq_notify
561 // mq_open
562 // mq_receive
563 // mq_send
564 // mq_setattr
565 // mq_timedreceive
566 // mq_timedsend
567 // mq_unlink
568 // mremap
569 // msgget
570 // msgrcv
571 // msgsnd
572 // nfssvc
573 // ntp_adjtime
574 // pmc_control
575 // pmc_get_info
576 // pollts
577 // preadv
578 // profil
579 // pselect
580 // pset_assign
581 // pset_create
582 // pset_destroy
583 // ptrace
584 // pwritev
585 // quotactl
586 // rasctl
587 // readv
588 // reboot
589 // removexattr
590 // sa_enable
591 // sa_preempt
592 // sa_register
593 // sa_setconcurrency
594 // sa_stacks
595 // sa_yield
596 // sbrk
597 // sched_yield
598 // semconfig
599 // semget
600 // semop
601 // setcontext
602 // setitimer
603 // setxattr
604 // shmat
605 // shmdt
606 // shmget
607 // sstk
608 // statvfs1
609 // swapctl
610 // sysarch
611 // syscall
612 // timer_create
613 // timer_delete
614 // timer_getoverrun
615 // timer_gettime
616 // timer_settime
617 // undelete
618 // utrace
619 // uuidgen
620 // vadvise
621 // vfork
622 // writev