]> git.immae.eu Git - github/fretlink/terraform-provider-statuscake.git/blame - vendor/golang.org/x/sys/unix/syscall_dragonfly.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_dragonfly.go
CommitLineData
15c0b25d
AP
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
5// DragonFly BSD 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 "unsafe"
16
17// SockaddrDatalink implements the Sockaddr interface for AF_LINK type sockets.
18type SockaddrDatalink struct {
19 Len uint8
20 Family uint8
21 Index uint16
22 Type uint8
23 Nlen uint8
24 Alen uint8
25 Slen uint8
26 Data [12]int8
27 Rcf uint16
28 Route [16]uint16
29 raw RawSockaddrDatalink
30}
31
32// Translate "kern.hostname" to []_C_int{0,1,2,3}.
33func nametomib(name string) (mib []_C_int, err error) {
34 const siz = unsafe.Sizeof(mib[0])
35
36 // NOTE(rsc): It seems strange to set the buffer to have
37 // size CTL_MAXNAME+2 but use only CTL_MAXNAME
38 // as the size. I don't know why the +2 is here, but the
39 // kernel uses +2 for its own implementation of this function.
40 // I am scared that if we don't include the +2 here, the kernel
41 // will silently write 2 words farther than we specify
42 // and we'll get memory corruption.
43 var buf [CTL_MAXNAME + 2]_C_int
44 n := uintptr(CTL_MAXNAME) * siz
45
46 p := (*byte)(unsafe.Pointer(&buf[0]))
47 bytes, err := ByteSliceFromString(name)
48 if err != nil {
49 return nil, err
50 }
51
52 // Magic sysctl: "setting" 0.3 to a string name
53 // lets you read back the array of integers form.
54 if err = sysctl([]_C_int{0, 3}, p, &n, &bytes[0], uintptr(len(name))); err != nil {
55 return nil, err
56 }
57 return buf[0 : n/siz], nil
58}
59
60//sysnb pipe() (r int, w int, err error)
61
62func Pipe(p []int) (err error) {
63 if len(p) != 2 {
64 return EINVAL
65 }
66 p[0], p[1], err = pipe()
67 return
68}
69
70//sys extpread(fd int, p []byte, flags int, offset int64) (n int, err error)
71func Pread(fd int, p []byte, offset int64) (n int, err error) {
72 return extpread(fd, p, 0, offset)
73}
74
75//sys extpwrite(fd int, p []byte, flags int, offset int64) (n int, err error)
76func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
77 return extpwrite(fd, p, 0, offset)
78}
79
80func Accept4(fd, flags int) (nfd int, sa Sockaddr, err error) {
81 var rsa RawSockaddrAny
82 var len _Socklen = SizeofSockaddrAny
83 nfd, err = accept4(fd, &rsa, &len, flags)
84 if err != nil {
85 return
86 }
87 if len > SizeofSockaddrAny {
88 panic("RawSockaddrAny too small")
89 }
90 sa, err = anyToSockaddr(fd, &rsa)
91 if err != nil {
92 Close(nfd)
93 nfd = 0
94 }
95 return
96}
97
98const ImplementsGetwd = true
99
100//sys Getcwd(buf []byte) (n int, err error) = SYS___GETCWD
101
102func Getwd() (string, error) {
103 var buf [PathMax]byte
104 _, err := Getcwd(buf[0:])
105 if err != nil {
106 return "", err
107 }
108 n := clen(buf[:])
109 if n < 1 {
110 return "", EINVAL
111 }
112 return string(buf[:n]), nil
113}
114
115func Getfsstat(buf []Statfs_t, flags int) (n int, err error) {
116 var _p0 unsafe.Pointer
117 var bufsize uintptr
118 if len(buf) > 0 {
119 _p0 = unsafe.Pointer(&buf[0])
120 bufsize = unsafe.Sizeof(Statfs_t{}) * uintptr(len(buf))
121 }
122 r0, _, e1 := Syscall(SYS_GETFSSTAT, uintptr(_p0), bufsize, uintptr(flags))
123 n = int(r0)
124 if e1 != 0 {
125 err = e1
126 }
127 return
128}
129
130func setattrlistTimes(path string, times []Timespec, flags int) error {
131 // used on Darwin for UtimesNano
132 return ENOSYS
133}
134
135//sys ioctl(fd int, req uint, arg uintptr) (err error)
136
137// ioctl itself should not be exposed directly, but additional get/set
138// functions for specific types are permissible.
139
140// IoctlSetInt performs an ioctl operation which sets an integer value
141// on fd, using the specified request number.
142func IoctlSetInt(fd int, req uint, value int) error {
143 return ioctl(fd, req, uintptr(value))
144}
145
146func ioctlSetWinsize(fd int, req uint, value *Winsize) error {
147 return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
148}
149
150func ioctlSetTermios(fd int, req uint, value *Termios) error {
151 return ioctl(fd, req, uintptr(unsafe.Pointer(value)))
152}
153
154// IoctlGetInt performs an ioctl operation which gets an integer value
155// from fd, using the specified request number.
156func IoctlGetInt(fd int, req uint) (int, error) {
157 var value int
158 err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
159 return value, err
160}
161
162func IoctlGetWinsize(fd int, req uint) (*Winsize, error) {
163 var value Winsize
164 err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
165 return &value, err
166}
167
168func IoctlGetTermios(fd int, req uint) (*Termios, error) {
169 var value Termios
170 err := ioctl(fd, req, uintptr(unsafe.Pointer(&value)))
171 return &value, err
172}
173
174func sysctlUname(mib []_C_int, old *byte, oldlen *uintptr) error {
175 err := sysctl(mib, old, oldlen, nil, 0)
176 if err != nil {
177 // Utsname members on Dragonfly are only 32 bytes and
178 // the syscall returns ENOMEM in case the actual value
179 // is longer.
180 if err == ENOMEM {
181 err = nil
182 }
183 }
184 return err
185}
186
187func Uname(uname *Utsname) error {
188 mib := []_C_int{CTL_KERN, KERN_OSTYPE}
189 n := unsafe.Sizeof(uname.Sysname)
190 if err := sysctlUname(mib, &uname.Sysname[0], &n); err != nil {
191 return err
192 }
193 uname.Sysname[unsafe.Sizeof(uname.Sysname)-1] = 0
194
195 mib = []_C_int{CTL_KERN, KERN_HOSTNAME}
196 n = unsafe.Sizeof(uname.Nodename)
197 if err := sysctlUname(mib, &uname.Nodename[0], &n); err != nil {
198 return err
199 }
200 uname.Nodename[unsafe.Sizeof(uname.Nodename)-1] = 0
201
202 mib = []_C_int{CTL_KERN, KERN_OSRELEASE}
203 n = unsafe.Sizeof(uname.Release)
204 if err := sysctlUname(mib, &uname.Release[0], &n); err != nil {
205 return err
206 }
207 uname.Release[unsafe.Sizeof(uname.Release)-1] = 0
208
209 mib = []_C_int{CTL_KERN, KERN_VERSION}
210 n = unsafe.Sizeof(uname.Version)
211 if err := sysctlUname(mib, &uname.Version[0], &n); err != nil {
212 return err
213 }
214
215 // The version might have newlines or tabs in it, convert them to
216 // spaces.
217 for i, b := range uname.Version {
218 if b == '\n' || b == '\t' {
219 if i == len(uname.Version)-1 {
220 uname.Version[i] = 0
221 } else {
222 uname.Version[i] = ' '
223 }
224 }
225 }
226
227 mib = []_C_int{CTL_HW, HW_MACHINE}
228 n = unsafe.Sizeof(uname.Machine)
229 if err := sysctlUname(mib, &uname.Machine[0], &n); err != nil {
230 return err
231 }
232 uname.Machine[unsafe.Sizeof(uname.Machine)-1] = 0
233
234 return nil
235}
236
107c1cdb
ND
237func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
238 if raceenabled {
239 raceReleaseMerge(unsafe.Pointer(&ioSync))
240 }
241 return sendfile(outfd, infd, offset, count)
242}
243
15c0b25d
AP
244/*
245 * Exposed directly
246 */
247//sys Access(path string, mode uint32) (err error)
248//sys Adjtime(delta *Timeval, olddelta *Timeval) (err error)
249//sys Chdir(path string) (err error)
250//sys Chflags(path string, flags int) (err error)
251//sys Chmod(path string, mode uint32) (err error)
252//sys Chown(path string, uid int, gid int) (err error)
253//sys Chroot(path string) (err error)
254//sys Close(fd int) (err error)
255//sys Dup(fd int) (nfd int, err error)
256//sys Dup2(from int, to int) (err error)
257//sys Exit(code int)
107c1cdb 258//sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error)
15c0b25d
AP
259//sys Fchdir(fd int) (err error)
260//sys Fchflags(fd int, flags int) (err error)
261//sys Fchmod(fd int, mode uint32) (err error)
262//sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error)
263//sys Fchown(fd int, uid int, gid int) (err error)
107c1cdb 264//sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error)
15c0b25d
AP
265//sys Flock(fd int, how int) (err error)
266//sys Fpathconf(fd int, name int) (val int, err error)
267//sys Fstat(fd int, stat *Stat_t) (err error)
268//sys Fstatat(fd int, path string, stat *Stat_t, flags int) (err error)
269//sys Fstatfs(fd int, stat *Statfs_t) (err error)
270//sys Fsync(fd int) (err error)
271//sys Ftruncate(fd int, length int64) (err error)
272//sys Getdirentries(fd int, buf []byte, basep *uintptr) (n int, err error)
273//sys Getdtablesize() (size int)
274//sysnb Getegid() (egid int)
275//sysnb Geteuid() (uid int)
276//sysnb Getgid() (gid int)
277//sysnb Getpgid(pid int) (pgid int, err error)
278//sysnb Getpgrp() (pgrp int)
279//sysnb Getpid() (pid int)
280//sysnb Getppid() (ppid int)
281//sys Getpriority(which int, who int) (prio int, err error)
282//sysnb Getrlimit(which int, lim *Rlimit) (err error)
283//sysnb Getrusage(who int, rusage *Rusage) (err error)
284//sysnb Getsid(pid int) (sid int, err error)
285//sysnb Gettimeofday(tv *Timeval) (err error)
286//sysnb Getuid() (uid int)
287//sys Issetugid() (tainted bool)
288//sys Kill(pid int, signum syscall.Signal) (err error)
289//sys Kqueue() (fd int, err error)
290//sys Lchown(path string, uid int, gid int) (err error)
291//sys Link(path string, link string) (err error)
107c1cdb 292//sys Linkat(pathfd int, path string, linkfd int, link string, flags int) (err error)
15c0b25d
AP
293//sys Listen(s int, backlog int) (err error)
294//sys Lstat(path string, stat *Stat_t) (err error)
295//sys Mkdir(path string, mode uint32) (err error)
107c1cdb 296//sys Mkdirat(dirfd int, path string, mode uint32) (err error)
15c0b25d
AP
297//sys Mkfifo(path string, mode uint32) (err error)
298//sys Mknod(path string, mode uint32, dev int) (err error)
107c1cdb 299//sys Mknodat(fd int, path string, mode uint32, dev int) (err error)
15c0b25d
AP
300//sys Nanosleep(time *Timespec, leftover *Timespec) (err error)
301//sys Open(path string, mode int, perm uint32) (fd int, err error)
302//sys Openat(dirfd int, path string, mode int, perm uint32) (fd int, err error)
303//sys Pathconf(path string, name int) (val int, err error)
304//sys read(fd int, p []byte) (n int, err error)
305//sys Readlink(path string, buf []byte) (n int, err error)
306//sys Rename(from string, to string) (err error)
107c1cdb 307//sys Renameat(fromfd int, from string, tofd int, to string) (err error)
15c0b25d
AP
308//sys Revoke(path string) (err error)
309//sys Rmdir(path string) (err error)
310//sys Seek(fd int, offset int64, whence int) (newoffset int64, err error) = SYS_LSEEK
311//sys Select(n int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (err error)
312//sysnb Setegid(egid int) (err error)
313//sysnb Seteuid(euid int) (err error)
314//sysnb Setgid(gid int) (err error)
315//sys Setlogin(name string) (err error)
316//sysnb Setpgid(pid int, pgid int) (err error)
317//sys Setpriority(which int, who int, prio int) (err error)
318//sysnb Setregid(rgid int, egid int) (err error)
319//sysnb Setreuid(ruid int, euid int) (err error)
320//sysnb Setresgid(rgid int, egid int, sgid int) (err error)
321//sysnb Setresuid(ruid int, euid int, suid int) (err error)
322//sysnb Setrlimit(which int, lim *Rlimit) (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 Undelete(path string) (err error)
334//sys Unlink(path string) (err error)
107c1cdb 335//sys Unlinkat(dirfd int, path string, flags int) (err error)
15c0b25d
AP
336//sys Unmount(path string, flags int) (err error)
337//sys write(fd int, p []byte) (n int, err error)
338//sys mmap(addr uintptr, length uintptr, prot int, flag int, fd int, pos int64) (ret uintptr, err error)
339//sys munmap(addr uintptr, length uintptr) (err error)
340//sys readlen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_READ
341//sys writelen(fd int, buf *byte, nbuf int) (n int, err error) = SYS_WRITE
342//sys accept4(fd int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (nfd int, err error)
343//sys utimensat(dirfd int, path string, times *[2]Timespec, flags int) (err error)
344
345/*
346 * Unimplemented
347 * TODO(jsing): Update this list for DragonFly.
348 */
349// Profil
350// Sigaction
351// Sigprocmask
352// Getlogin
353// Sigpending
354// Sigaltstack
355// Reboot
356// Execve
357// Vfork
358// Sbrk
359// Sstk
360// Ovadvise
361// Mincore
362// Setitimer
363// Swapon
364// Select
365// Sigsuspend
366// Readv
367// Writev
368// Nfssvc
369// Getfh
370// Quotactl
371// Mount
372// Csops
373// Waitid
374// Add_profil
375// Kdebug_trace
376// Sigreturn
377// Atsocket
378// Kqueue_from_portset_np
379// Kqueue_portset
380// Getattrlist
381// Setattrlist
382// Getdirentriesattr
383// Searchfs
384// Delete
385// Copyfile
386// Watchevent
387// Waitevent
388// Modwatch
389// Getxattr
390// Fgetxattr
391// Setxattr
392// Fsetxattr
393// Removexattr
394// Fremovexattr
395// Listxattr
396// Flistxattr
397// Fsctl
398// Initgroups
399// Posix_spawn
400// Nfsclnt
401// Fhopen
402// Minherit
403// Semsys
404// Msgsys
405// Shmsys
406// Semctl
407// Semget
408// Semop
409// Msgctl
410// Msgget
411// Msgsnd
412// Msgrcv
413// Shmat
414// Shmctl
415// Shmdt
416// Shmget
417// Shm_open
418// Shm_unlink
419// Sem_open
420// Sem_close
421// Sem_unlink
422// Sem_wait
423// Sem_trywait
424// Sem_post
425// Sem_getvalue
426// Sem_init
427// Sem_destroy
428// Open_extended
429// Umask_extended
430// Stat_extended
431// Lstat_extended
432// Fstat_extended
433// Chmod_extended
434// Fchmod_extended
435// Access_extended
436// Settid
437// Gettid
438// Setsgroups
439// Getsgroups
440// Setwgroups
441// Getwgroups
442// Mkfifo_extended
443// Mkdir_extended
444// Identitysvc
445// Shared_region_check_np
446// Shared_region_map_np
447// __pthread_mutex_destroy
448// __pthread_mutex_init
449// __pthread_mutex_lock
450// __pthread_mutex_trylock
451// __pthread_mutex_unlock
452// __pthread_cond_init
453// __pthread_cond_destroy
454// __pthread_cond_broadcast
455// __pthread_cond_signal
456// Setsid_with_pid
457// __pthread_cond_timedwait
458// Aio_fsync
459// Aio_return
460// Aio_suspend
461// Aio_cancel
462// Aio_error
463// Aio_read
464// Aio_write
465// Lio_listio
466// __pthread_cond_wait
467// Iopolicysys
468// __pthread_kill
469// __pthread_sigmask
470// __sigwait
471// __disable_threadsignal
472// __pthread_markcancel
473// __pthread_canceled
474// __semwait_signal
475// Proc_info
476// Stat64_extended
477// Lstat64_extended
478// Fstat64_extended
479// __pthread_chdir
480// __pthread_fchdir
481// Audit
482// Auditon
483// Getauid
484// Setauid
485// Getaudit
486// Setaudit
487// Getaudit_addr
488// Setaudit_addr
489// Auditctl
490// Bsdthread_create
491// Bsdthread_terminate
492// Stack_snapshot
493// Bsdthread_register
494// Workq_open
495// Workq_ops
496// __mac_execve
497// __mac_syscall
498// __mac_get_file
499// __mac_set_file
500// __mac_get_link
501// __mac_set_link
502// __mac_get_proc
503// __mac_set_proc
504// __mac_get_fd
505// __mac_set_fd
506// __mac_get_pid
507// __mac_get_lcid
508// __mac_get_lctx
509// __mac_set_lctx
510// Setlcid
511// Read_nocancel
512// Write_nocancel
513// Open_nocancel
514// Close_nocancel
515// Wait4_nocancel
516// Recvmsg_nocancel
517// Sendmsg_nocancel
518// Recvfrom_nocancel
519// Accept_nocancel
520// Fcntl_nocancel
521// Select_nocancel
522// Fsync_nocancel
523// Connect_nocancel
524// Sigsuspend_nocancel
525// Readv_nocancel
526// Writev_nocancel
527// Sendto_nocancel
528// Pread_nocancel
529// Pwrite_nocancel
530// Waitid_nocancel
531// Msgsnd_nocancel
532// Msgrcv_nocancel
533// Sem_wait_nocancel
534// Aio_suspend_nocancel
535// __sigwait_nocancel
536// __semwait_signal_nocancel
537// __mac_mount
538// __mac_get_mount
539// __mac_getfsstat