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