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