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