1
2
3
4
5
6
7 package unix
8
9 import (
10 "syscall"
11 "unsafe"
12 )
13
14 var _ syscall.Errno
15
16
17
18 func fanotifyMark(fd int, flags uint, mask uint64, dirFd int, pathname *byte) (err error) {
19 _, _, e1 := Syscall6(SYS_FANOTIFY_MARK, uintptr(fd), uintptr(flags), uintptr(mask), uintptr(mask>>32), uintptr(dirFd), uintptr(unsafe.Pointer(pathname)))
20 if e1 != 0 {
21 err = errnoErr(e1)
22 }
23 return
24 }
25
26
27
28 func Fallocate(fd int, mode uint32, off int64, len int64) (err error) {
29 _, _, e1 := Syscall6(SYS_FALLOCATE, uintptr(fd), uintptr(mode), uintptr(off), uintptr(off>>32), uintptr(len), uintptr(len>>32))
30 if e1 != 0 {
31 err = errnoErr(e1)
32 }
33 return
34 }
35
36
37
38 func Tee(rfd int, wfd int, len int, flags int) (n int64, err error) {
39 r0, r1, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0)
40 n = int64(int64(r1)<<32 | int64(r0))
41 if e1 != 0 {
42 err = errnoErr(e1)
43 }
44 return
45 }
46
47
48
49 func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
50 r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
51 fd = int(r0)
52 if e1 != 0 {
53 err = errnoErr(e1)
54 }
55 return
56 }
57
58
59
60 func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) {
61 r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
62 fd = int(r0)
63 if e1 != 0 {
64 err = errnoErr(e1)
65 }
66 return
67 }
68
69
70
71 func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
72 _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
73 if e1 != 0 {
74 err = errnoErr(e1)
75 }
76 return
77 }
78
79
80
81 func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
82 _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
83 if e1 != 0 {
84 err = errnoErr(e1)
85 }
86 return
87 }
88
89
90
91 func getgroups(n int, list *_Gid_t) (nn int, err error) {
92 r0, _, e1 := RawSyscall(SYS_GETGROUPS32, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
93 nn = int(r0)
94 if e1 != 0 {
95 err = errnoErr(e1)
96 }
97 return
98 }
99
100
101
102 func setgroups(n int, list *_Gid_t) (err error) {
103 _, _, e1 := RawSyscall(SYS_SETGROUPS32, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
104 if e1 != 0 {
105 err = errnoErr(e1)
106 }
107 return
108 }
109
110
111
112 func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
113 _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
114 if e1 != 0 {
115 err = errnoErr(e1)
116 }
117 return
118 }
119
120
121
122 func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
123 _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
124 if e1 != 0 {
125 err = errnoErr(e1)
126 }
127 return
128 }
129
130
131
132 func socket(domain int, typ int, proto int) (fd int, err error) {
133 r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
134 fd = int(r0)
135 if e1 != 0 {
136 err = errnoErr(e1)
137 }
138 return
139 }
140
141
142
143 func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
144 _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
145 if e1 != 0 {
146 err = errnoErr(e1)
147 }
148 return
149 }
150
151
152
153 func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
154 _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
155 if e1 != 0 {
156 err = errnoErr(e1)
157 }
158 return
159 }
160
161
162
163 func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
164 var _p0 unsafe.Pointer
165 if len(p) > 0 {
166 _p0 = unsafe.Pointer(&p[0])
167 } else {
168 _p0 = unsafe.Pointer(&_zero)
169 }
170 r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
171 n = int(r0)
172 if e1 != 0 {
173 err = errnoErr(e1)
174 }
175 return
176 }
177
178
179
180 func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
181 var _p0 unsafe.Pointer
182 if len(buf) > 0 {
183 _p0 = unsafe.Pointer(&buf[0])
184 } else {
185 _p0 = unsafe.Pointer(&_zero)
186 }
187 _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
188 if e1 != 0 {
189 err = errnoErr(e1)
190 }
191 return
192 }
193
194
195
196 func socketpair(domain int, typ int, flags int, fd *[2]int32) (err error) {
197 _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(flags), uintptr(unsafe.Pointer(fd)), 0, 0)
198 if e1 != 0 {
199 err = errnoErr(e1)
200 }
201 return
202 }
203
204
205
206 func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
207 r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
208 n = int(r0)
209 if e1 != 0 {
210 err = errnoErr(e1)
211 }
212 return
213 }
214
215
216
217 func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
218 r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
219 n = int(r0)
220 if e1 != 0 {
221 err = errnoErr(e1)
222 }
223 return
224 }
225
226
227
228 func EpollWait(epfd int, events []EpollEvent, msec int) (n int, err error) {
229 var _p0 unsafe.Pointer
230 if len(events) > 0 {
231 _p0 = unsafe.Pointer(&events[0])
232 } else {
233 _p0 = unsafe.Pointer(&_zero)
234 }
235 r0, _, e1 := Syscall6(SYS_EPOLL_WAIT, uintptr(epfd), uintptr(_p0), uintptr(len(events)), uintptr(msec), 0, 0)
236 n = int(r0)
237 if e1 != 0 {
238 err = errnoErr(e1)
239 }
240 return
241 }
242
243
244
245 func Fchown(fd int, uid int, gid int) (err error) {
246 _, _, e1 := Syscall(SYS_FCHOWN32, uintptr(fd), uintptr(uid), uintptr(gid))
247 if e1 != 0 {
248 err = errnoErr(e1)
249 }
250 return
251 }
252
253
254
255 func Fstat(fd int, stat *Stat_t) (err error) {
256 _, _, e1 := Syscall(SYS_FSTAT64, uintptr(fd), uintptr(unsafe.Pointer(stat)), 0)
257 if e1 != 0 {
258 err = errnoErr(e1)
259 }
260 return
261 }
262
263
264
265 func Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) {
266 var _p0 *byte
267 _p0, err = BytePtrFromString(path)
268 if err != nil {
269 return
270 }
271 _, _, e1 := Syscall6(SYS_FSTATAT64, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), uintptr(flags), 0, 0)
272 if e1 != 0 {
273 err = errnoErr(e1)
274 }
275 return
276 }
277
278
279
280 func Getegid() (egid int) {
281 r0, _ := RawSyscallNoError(SYS_GETEGID32, 0, 0, 0)
282 egid = int(r0)
283 return
284 }
285
286
287
288 func Geteuid() (euid int) {
289 r0, _ := RawSyscallNoError(SYS_GETEUID32, 0, 0, 0)
290 euid = int(r0)
291 return
292 }
293
294
295
296 func Getgid() (gid int) {
297 r0, _ := RawSyscallNoError(SYS_GETGID32, 0, 0, 0)
298 gid = int(r0)
299 return
300 }
301
302
303
304 func Getuid() (uid int) {
305 r0, _ := RawSyscallNoError(SYS_GETUID32, 0, 0, 0)
306 uid = int(r0)
307 return
308 }
309
310
311
312 func Lchown(path string, uid int, gid int) (err error) {
313 var _p0 *byte
314 _p0, err = BytePtrFromString(path)
315 if err != nil {
316 return
317 }
318 _, _, e1 := Syscall(SYS_LCHOWN32, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
319 if e1 != 0 {
320 err = errnoErr(e1)
321 }
322 return
323 }
324
325
326
327 func Listen(s int, n int) (err error) {
328 _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0)
329 if e1 != 0 {
330 err = errnoErr(e1)
331 }
332 return
333 }
334
335
336
337 func Lstat(path string, stat *Stat_t) (err error) {
338 var _p0 *byte
339 _p0, err = BytePtrFromString(path)
340 if err != nil {
341 return
342 }
343 _, _, e1 := Syscall(SYS_LSTAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
344 if e1 != 0 {
345 err = errnoErr(e1)
346 }
347 return
348 }
349
350
351
352 func Pause() (err error) {
353 _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0)
354 if e1 != 0 {
355 err = errnoErr(e1)
356 }
357 return
358 }
359
360
361
362 func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
363 var _p0 *byte
364 _p0, err = BytePtrFromString(oldpath)
365 if err != nil {
366 return
367 }
368 var _p1 *byte
369 _p1, err = BytePtrFromString(newpath)
370 if err != nil {
371 return
372 }
373 _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0)
374 if e1 != 0 {
375 err = errnoErr(e1)
376 }
377 return
378 }
379
380
381
382 func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
383 r0, _, e1 := Syscall6(SYS_SENDFILE64, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0)
384 written = int(r0)
385 if e1 != 0 {
386 err = errnoErr(e1)
387 }
388 return
389 }
390
391
392
393 func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
394 r0, _, e1 := Syscall6(SYS__NEWSELECT, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
395 n = int(r0)
396 if e1 != 0 {
397 err = errnoErr(e1)
398 }
399 return
400 }
401
402
403
404 func setfsgid(gid int) (prev int, err error) {
405 r0, _, e1 := Syscall(SYS_SETFSGID32, uintptr(gid), 0, 0)
406 prev = int(r0)
407 if e1 != 0 {
408 err = errnoErr(e1)
409 }
410 return
411 }
412
413
414
415 func setfsuid(uid int) (prev int, err error) {
416 r0, _, e1 := Syscall(SYS_SETFSUID32, uintptr(uid), 0, 0)
417 prev = int(r0)
418 if e1 != 0 {
419 err = errnoErr(e1)
420 }
421 return
422 }
423
424
425
426 func Setregid(rgid int, egid int) (err error) {
427 _, _, e1 := RawSyscall(SYS_SETREGID32, uintptr(rgid), uintptr(egid), 0)
428 if e1 != 0 {
429 err = errnoErr(e1)
430 }
431 return
432 }
433
434
435
436 func Setresgid(rgid int, egid int, sgid int) (err error) {
437 _, _, e1 := RawSyscall(SYS_SETRESGID32, uintptr(rgid), uintptr(egid), uintptr(sgid))
438 if e1 != 0 {
439 err = errnoErr(e1)
440 }
441 return
442 }
443
444
445
446 func Setresuid(ruid int, euid int, suid int) (err error) {
447 _, _, e1 := RawSyscall(SYS_SETRESUID32, uintptr(ruid), uintptr(euid), uintptr(suid))
448 if e1 != 0 {
449 err = errnoErr(e1)
450 }
451 return
452 }
453
454
455
456 func Setreuid(ruid int, euid int) (err error) {
457 _, _, e1 := RawSyscall(SYS_SETREUID32, uintptr(ruid), uintptr(euid), 0)
458 if e1 != 0 {
459 err = errnoErr(e1)
460 }
461 return
462 }
463
464
465
466 func Shutdown(fd int, how int) (err error) {
467 _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0)
468 if e1 != 0 {
469 err = errnoErr(e1)
470 }
471 return
472 }
473
474
475
476 func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) {
477 r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags))
478 n = int(r0)
479 if e1 != 0 {
480 err = errnoErr(e1)
481 }
482 return
483 }
484
485
486
487 func Stat(path string, stat *Stat_t) (err error) {
488 var _p0 *byte
489 _p0, err = BytePtrFromString(path)
490 if err != nil {
491 return
492 }
493 _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
494 if e1 != 0 {
495 err = errnoErr(e1)
496 }
497 return
498 }
499
500
501
502 func Ustat(dev int, ubuf *Ustat_t) (err error) {
503 _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0)
504 if e1 != 0 {
505 err = errnoErr(e1)
506 }
507 return
508 }
509
510
511
512 func futimesat(dirfd int, path string, times *[2]Timeval) (err error) {
513 var _p0 *byte
514 _p0, err = BytePtrFromString(path)
515 if err != nil {
516 return
517 }
518 _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)))
519 if e1 != 0 {
520 err = errnoErr(e1)
521 }
522 return
523 }
524
525
526
527 func Gettimeofday(tv *Timeval) (err error) {
528 _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
529 if e1 != 0 {
530 err = errnoErr(e1)
531 }
532 return
533 }
534
535
536
537 func utimes(path string, times *[2]Timeval) (err error) {
538 var _p0 *byte
539 _p0, err = BytePtrFromString(path)
540 if err != nil {
541 return
542 }
543 _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0)
544 if e1 != 0 {
545 err = errnoErr(e1)
546 }
547 return
548 }
549
550
551
552 func Pread(fd int, p []byte, offset int64) (n int, err error) {
553 var _p0 unsafe.Pointer
554 if len(p) > 0 {
555 _p0 = unsafe.Pointer(&p[0])
556 } else {
557 _p0 = unsafe.Pointer(&_zero)
558 }
559 r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32))
560 n = int(r0)
561 if e1 != 0 {
562 err = errnoErr(e1)
563 }
564 return
565 }
566
567
568
569 func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
570 var _p0 unsafe.Pointer
571 if len(p) > 0 {
572 _p0 = unsafe.Pointer(&p[0])
573 } else {
574 _p0 = unsafe.Pointer(&_zero)
575 }
576 r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), 0, uintptr(offset), uintptr(offset>>32))
577 n = int(r0)
578 if e1 != 0 {
579 err = errnoErr(e1)
580 }
581 return
582 }
583
584
585
586 func Truncate(path string, length int64) (err error) {
587 var _p0 *byte
588 _p0, err = BytePtrFromString(path)
589 if err != nil {
590 return
591 }
592 _, _, e1 := Syscall6(SYS_TRUNCATE64, uintptr(unsafe.Pointer(_p0)), 0, uintptr(length), uintptr(length>>32), 0, 0)
593 if e1 != 0 {
594 err = errnoErr(e1)
595 }
596 return
597 }
598
599
600
601 func Ftruncate(fd int, length int64) (err error) {
602 _, _, e1 := Syscall6(SYS_FTRUNCATE64, uintptr(fd), 0, uintptr(length), uintptr(length>>32), 0, 0)
603 if e1 != 0 {
604 err = errnoErr(e1)
605 }
606 return
607 }
608
609
610
611 func mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error) {
612 r0, _, e1 := Syscall6(SYS_MMAP2, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(pageOffset))
613 xaddr = uintptr(r0)
614 if e1 != 0 {
615 err = errnoErr(e1)
616 }
617 return
618 }
619
620
621
622 func getrlimit(resource int, rlim *rlimit32) (err error) {
623 _, _, e1 := RawSyscall(SYS_UGETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
624 if e1 != 0 {
625 err = errnoErr(e1)
626 }
627 return
628 }
629
630
631
632 func setrlimit(resource int, rlim *rlimit32) (err error) {
633 _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
634 if e1 != 0 {
635 err = errnoErr(e1)
636 }
637 return
638 }
639
640
641
642 func armSyncFileRange(fd int, flags int, off int64, n int64) (err error) {
643 _, _, e1 := Syscall6(SYS_ARM_SYNC_FILE_RANGE, uintptr(fd), uintptr(flags), uintptr(off), uintptr(off>>32), uintptr(n), uintptr(n>>32))
644 if e1 != 0 {
645 err = errnoErr(e1)
646 }
647 return
648 }
649
650
651
652 func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) {
653 var _p0 *byte
654 _p0, err = BytePtrFromString(cmdline)
655 if err != nil {
656 return
657 }
658 _, _, e1 := Syscall6(SYS_KEXEC_FILE_LOAD, uintptr(kernelFd), uintptr(initrdFd), uintptr(cmdlineLen), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
659 if e1 != 0 {
660 err = errnoErr(e1)
661 }
662 return
663 }
664
View as plain text