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