]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blame - vendor/golang.org/x/sys/unix/syscall_openbsd.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_openbsd.go
CommitLineData
15c0b25d
AP
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// OpenBSD 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
13package unix
14
15import (
16 "sort"
17 "syscall"
18 "unsafe"
19)
20
21// SockaddrDatalink implements the Sockaddr interface for AF_LINK type sockets.
22type 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 [24]int8
31 raw RawSockaddrDatalink
32}
33
34func Syscall9(trap, a1, a2, a3, a4, a5, a6, a7, a8, a9 uintptr) (r1, r2 uintptr, err syscall.Errno)
35
36func nametomib(name string) (mib []_C_int, err error) {
37 i := sort.Search(len(sysctlMib), func(i int) bool {
38 return sysctlMib[i].ctlname >= name
39 })
40 if i < len(sysctlMib) && sysctlMib[i].ctlname == name {
41 return sysctlMib[i].ctloid, nil
42 }
43 return nil, EINVAL
44}
45
107c1cdb
ND
46func SysctlClockinfo(name string) (*Clockinfo, error) {
47 mib, err := sysctlmib(name)
48 if err != nil {
49 return nil, err
50 }
51
52 n := uintptr(SizeofClockinfo)
53 var ci Clockinfo
54 if err := sysctl(mib, (*byte)(unsafe.Pointer(&ci)), &n, nil, 0); err != nil {
55 return nil, err
56 }
57 if n != SizeofClockinfo {
58 return nil, EIO
59 }
60 return &ci, nil
61}
62
15c0b25d
AP
63func SysctlUvmexp(name string) (*Uvmexp, error) {
64 mib, err := sysctlmib(name)
65 if err != nil {
66 return nil, err
67 }
68
69 n := uintptr(SizeofUvmexp)
70 var u Uvmexp
71 if err := sysctl(mib, (*byte)(unsafe.Pointer(&u)), &n, nil, 0); err != nil {
72 return nil, err
73 }
74 if n != SizeofUvmexp {
75 return nil, EIO
76 }
77 return &u, nil
78}
79
80//sysnb pipe(p *[2]_C_int) (err error)
81func Pipe(p []int) (err error) {
82 if len(p) != 2 {
83 return EINVAL
84 }
85 var pp [2]_C_int
86 err = pipe(&pp)
87 p[0] = int(pp[0])
88 p[1] = int(pp[1])
89 return
90}
91
92//sys getdents(fd int, buf []byte) (n int, err error)
93func Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error) {
94 return getdents(fd, buf)
95}
96
97const ImplementsGetwd = true
98
99//sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD
100
101func Getwd() (string, error) {
102 var buf [PathMax]byte
103 _, err := Getcwd(buf[0:])
104 if err != nil {
105 return "", err
106 }
107 n := clen(buf[:])
108 if n < 1 {
109 return "", EINVAL
110 }
111 return string(buf[:n]), nil
112}
113
107c1cdb
ND
114func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
115 if raceenabled {
116 raceReleaseMerge(unsafe.Pointer(&ioSync))
117 }
118 return sendfile(outfd, infd, offset, count)
119}
120
15c0b25d
AP
121// TODO
122func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
123 return -1, ENOSYS
124}
125
126func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
127 var _p0 unsafe.Pointer
128 var bufsize uintptr
129 if len(buf) > 0 {
130 _p0 = unsafe.Pointer(&buf[0])
131 bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
132 }
133 r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags))
134 n = int(r0)
135 if e1 != 0 {
136 err = e1
137 }
138 return
139}
140
141func setattrlistTimes(path string, times []Timespec, flags int) error {
142 // used on Darwin for UtimesNano
143 return ENOSYS
144}
145
146//sys ioctl(fd int, req uint, arg uintptr) (err error)
147
148// ioctl itself should not be exposed directly, but additional get/set
149// functions for specific types are permissible.
150
151// IoctlSetInt performs an ioctl operation which sets an integer value
152// on fd, using the specified request number.
153func IoctlSetInt(fd int, req uint, value int) error {
154 return ioctl(fd, req, uintptr(value))
155}
156
157func ioctlSetWinsize(fd int, req uint, value *Winsize) error {
158 return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
159}
160
161func ioctlSetTermios(fd int, req uint, value *Termios) error {
162 return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
163}
164
165// IoctlGetInt performs an ioctl operation which gets an integer value
166// from fd, using the specified request number.
167func IoctlGetInt(fd int, req uint) (int, error) {
168 var value int
169 err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
170 return value, err
171}
172
173func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
174 var value Winsize
175 err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
176 return &value, err
177}
178
179func IoctlGetTermios(fd int, req uint) (*Termios, error) {
180 var value Termios
181 err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
182 return &value, err
183}
184
185//sys ppoll(fds *PollFd, nfds int, timeout *Timespec, sigmask *Sigset_t) (n int, err error)
186
187func Ppoll(fds []PollFd, timeout *Timespec, sigmask *Sigset_t) (n int, err error) {
188 if len(fds) == 0 {
189 return ppoll(nil, 0, timeout, sigmask)
190 }
191 return ppoll(&fds[0], len(fds), timeout, sigmask)
192}
193
194func Uname(uname *Utsname) error {
195 mib := []_C_int{CTL_KERN, KERN_OSTYPE}
196 n := unsafe.Sizeof(uname.Sysname)
197 if err := sysctl(mib, &uname.Sysname[0], &n, nil, 0); err != nil {
198 return err
199 }
200
201 mib = []_C_int{CTL_KERN, KERN_HOSTNAME}
202 n = unsafe.Sizeof(uname.Nodename)
203 if err := sysctl(mib, &uname.Nodename[0], &n, nil, 0); err != nil {
204 return err
205 }
206
207 mib = []_C_int{CTL_KERN, KERN_OSRELEASE}
208 n = unsafe.Sizeof(uname.Release)
209 if err := sysctl(mib, &uname.Release[0], &n, nil, 0); err != nil {
210 return err
211 }
212
213 mib = []_C_int{CTL_KERN, KERN_VERSION}
214 n = unsafe.Sizeof(uname.Version)
215 if err := sysctl(mib, &uname.Version[0], &n, nil, 0); err != nil {
216 return err
217 }
218
219 // The version might have newlines or tabs in it, convert them to
220 // spaces.
221 for i, b := range uname.Version {
222 if b == '\n' || b == '\t' {
223 if i == len(uname.Version)-1 {
224 uname.Version[i] = 0
225 } else {
226 uname.Version[i] = ' '
227 }
228 }
229 }
230
231 mib = []_C_int{CTL_HW, HW_MACHINE}
232 n = unsafe.Sizeof(uname.Machine)
233 if err := sysctl(mib, &uname.Machine[0], &n, nil, 0); err != nil {
234 return err
235 }
236
237 return nil
238}
239
240/*
241 * Exposed directly
242 */
243//sys Access(path string, mode uint32) (err error)
244//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
245//sys Chdir(path string) (err error)
246//sys Chflags(path string, flags int) (err error)
247//sys Chmod(path string, mode uint32) (err error)
248//sys Chown(path string, uid int, gid int) (err error)
249//sys Chroot(path string) (err error)
250//sys Close(fd int) (err error)
251//sys Dup(fd int) (nfd int, err error)
252//sys Dup2(from int, to int) (err error)
253//sys Exit(code int)
254//sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
255//sys Fchdir(fd int) (err error)
256//sys Fchflags(fd int, flags int) (err error)
257//sys Fchmod(fd int, mode uint32) (err error)
258//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
259//sys Fchown(fd int, uid int, gid int) (err error)
107c1cdb 260//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
15c0b25d
AP
261//sys Flock(fd int, how int) (err error)
262//sys Fpathconf(fd int, name int) (val int, err error)
263//sys Fstat(fd int, stat *Stat_t) (err error)
264//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
265//sys Fstatfs(fd int, stat *Statfs_t) (err error)
266//sys Fsync(fd int) (err error)
267//sys Ftruncate(fd int, length int64) (err error)
268//sysnb Getegid() (egid int)
269//sysnb Geteuid() (uid int)
270//sysnb Getgid() (gid int)
271//sysnb Getpgid(pid int) (pgid int, err error)
272//sysnb Getpgrp() (pgrp int)
273//sysnb Getpid() (pid int)
274//sysnb Getppid() (ppid int)
275//sys Getpriority(which int, who int) (prio int, err error)
276//sysnb Getrlimit(which int, lim *Rlimit) (err error)
277//sysnb Getrtable() (rtable int, err error)
278//sysnb Getrusage(who int, rusage *Rusage) (err error)
279//sysnb Getsid(pid int) (sid int, err error)
280//sysnb Gettimeofday(tv *Timeval) (err error)
281//sysnb Getuid() (uid int)
282//sys Issetugid() (tainted bool)
283//sys Kill(pid int, signum syscall.Signal) (err error)
284//sys Kqueue() (fd int, err error)
285//sys Lchown(path string, uid int, gid int) (err error)
286//sys Link(path string, link string) (err error)
107c1cdb 287//sys Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error)
15c0b25d
AP
288//sys Listen(s int, backlog int) (err error)
289//sys Lstat(path string, stat *Stat_t) (err error)
290//sys Mkdir(path string, mode uint32) (err error)
107c1cdb 291//sys Mkdirat(dirfd int, path string, mode uint32) (err error)
15c0b25d 292//sys Mkfifo(path string, mode uint32) (err error)
107c1cdb 293//sys Mkfifoat(dirfd int, path string, mode uint32) (err error)
15c0b25d 294//sys Mknod(path string, mode uint32, dev int) (err error)
107c1cdb 295//sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error)
15c0b25d
AP
296//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
297//sys Open(path string, mode int, perm uint32) (fd int, err error)
298//sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error)
299//sys Pathconf(path string, name int) (val int, err error)
300//sys Pread(fd int, p []byte, offset int64) (n int, err error)
301//sys Pwrite(fd int, p []byte, offset int64) (n int, err error)
302//sys read(fd int, p []byte) (n int, err error)
303//sys Readlink(path string, buf []byte) (n int, err error)
107c1cdb 304//sys Readlinkat(dirfd int, path string, buf []byte) (n int, err error)
15c0b25d 305//sys Rename(from string, to string) (err error)
107c1cdb 306//sys Renameat(fromfd int, from string, tofd int, to string) (err error)
15c0b25d
AP
307//sys Revoke(path string) (err error)
308//sys Rmdir(path string) (err error)
309//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
310//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
311//sysnb Setegid(egid int) (err error)
312//sysnb Seteuid(euid int) (err error)
313//sysnb Setgid(gid int) (err error)
314//sys Setlogin(name string) (err error)
315//sysnb Setpgid(pid int, pgid int) (err error)
316//sys Setpriority(which int, who int, prio int) (err error)
317//sysnb Setregid(rgid int, egid int) (err error)
318//sysnb Setreuid(ruid int, euid int) (err error)
319//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
320//sysnb Setresuid(ruid int, euid int, suid int) (err error)
321//sysnb Setrlimit(which int, lim *Rlimit) (err error)
322//sysnb Setrtable(rtable int) (err error)
323//sysnb Setsid() (pid int, err error)
324//sysnb Settimeofday(tp *Timeval) (err error)
325//sysnb Setuid(uid int) (err error)
326//sys Stat(path string, stat *Stat_t) (err error)
327//sys Statfs(path string, stat *Statfs_t) (err error)
328//sys Symlink(path string, link string) (err error)
107c1cdb 329//sys Symlinkat(oldpath string, newdirfd int, newpath string) (err error)
15c0b25d
AP
330//sys Sync() (err error)
331//sys Truncate(path string, length int64) (err error)
332//sys Umask(newmask int) (oldmask int)
333//sys Unlink(path string) (err error)
107c1cdb 334//sys Unlinkat(dirfd int, path string, flags int) (err error)
15c0b25d
AP
335//sys Unmount(path string, flags int) (err error)
336//sys write(fd int, p []byte) (n int, err error)
337//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
338//sys munmap(addr uintptr, length uintptr) (err error)
339//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
340//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
341//sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error)
342
343/*
344 * Unimplemented
345 */
346// __getcwd
347// __semctl
348// __syscall
349// __sysctl
350// adjfreq
351// break
352// clock_getres
353// clock_gettime
354// clock_settime
355// closefrom
356// execve
15c0b25d
AP
357// fcntl
358// fhopen
359// fhstat
360// fhstatfs
361// fork
15c0b25d
AP
362// futimens
363// getfh
364// getgid
365// getitimer
366// getlogin
367// getresgid
368// getresuid
369// getthrid
370// ktrace
371// lfs_bmapv
372// lfs_markv
373// lfs_segclean
374// lfs_segwait
15c0b25d
AP
375// mincore
376// minherit
15c0b25d
AP
377// mount
378// mquery
379// msgctl
380// msgget
381// msgrcv
382// msgsnd
383// nfssvc
384// nnpfspioctl
385// preadv
386// profil
387// pwritev
388// quotactl
15c0b25d
AP
389// readv
390// reboot
391// renameat
392// rfork
393// sched_yield
394// semget
395// semop
396// setgroups
397// setitimer
398// setsockopt
399// shmat
400// shmctl
401// shmdt
402// shmget
403// sigaction
404// sigaltstack
405// sigpending
406// sigprocmask
407// sigreturn
408// sigsuspend
15c0b25d
AP
409// sysarch
410// syscall
411// threxit
412// thrsigdivert
413// thrsleep
414// thrwakeup
15c0b25d
AP
415// vfork
416// writev