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_GETRLIMIT, 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 Pause() (err error) {
219 _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0)
220 if e1 != 0 {
221 err = errnoErr(e1)
222 }
223 return
224 }
225
226
227
228 func Pread(fd int, p []byte, offset int64) (n int, err error) {
229 var _p0 unsafe.Pointer
230 if len(p) > 0 {
231 _p0 = unsafe.Pointer(&p[0])
232 } else {
233 _p0 = unsafe.Pointer(&_zero)
234 }
235 r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
236 n = int(r0)
237 if e1 != 0 {
238 err = errnoErr(e1)
239 }
240 return
241 }
242
243
244
245 func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
246 var _p0 unsafe.Pointer
247 if len(p) > 0 {
248 _p0 = unsafe.Pointer(&p[0])
249 } else {
250 _p0 = unsafe.Pointer(&_zero)
251 }
252 r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
253 n = int(r0)
254 if e1 != 0 {
255 err = errnoErr(e1)
256 }
257 return
258 }
259
260
261
262 func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
263 var _p0 *byte
264 _p0, err = BytePtrFromString(oldpath)
265 if err != nil {
266 return
267 }
268 var _p1 *byte
269 _p1, err = BytePtrFromString(newpath)
270 if err != nil {
271 return
272 }
273 _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0)
274 if e1 != 0 {
275 err = errnoErr(e1)
276 }
277 return
278 }
279
280
281
282 func Seek(fd int, offset int64, whence int) (off int64, err error) {
283 r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
284 off = int64(r0)
285 if e1 != 0 {
286 err = errnoErr(e1)
287 }
288 return
289 }
290
291
292
293 func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
294 r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0)
295 written = int(r0)
296 if e1 != 0 {
297 err = errnoErr(e1)
298 }
299 return
300 }
301
302
303
304 func setfsgid(gid int) (prev int, err error) {
305 r0, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0)
306 prev = int(r0)
307 if e1 != 0 {
308 err = errnoErr(e1)
309 }
310 return
311 }
312
313
314
315 func setfsuid(uid int) (prev int, err error) {
316 r0, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0)
317 prev = int(r0)
318 if e1 != 0 {
319 err = errnoErr(e1)
320 }
321 return
322 }
323
324
325
326 func Setregid(rgid int, egid int) (err error) {
327 _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
328 if e1 != 0 {
329 err = errnoErr(e1)
330 }
331 return
332 }
333
334
335
336 func Setresgid(rgid int, egid int, sgid int) (err error) {
337 _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid))
338 if e1 != 0 {
339 err = errnoErr(e1)
340 }
341 return
342 }
343
344
345
346 func Setresuid(ruid int, euid int, suid int) (err error) {
347 _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid))
348 if e1 != 0 {
349 err = errnoErr(e1)
350 }
351 return
352 }
353
354
355
356 func Setrlimit(resource int, rlim *Rlimit) (err error) {
357 _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
358 if e1 != 0 {
359 err = errnoErr(e1)
360 }
361 return
362 }
363
364
365
366 func Setreuid(ruid int, euid int) (err error) {
367 _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
368 if e1 != 0 {
369 err = errnoErr(e1)
370 }
371 return
372 }
373
374
375
376 func Shutdown(fd int, how int) (err error) {
377 _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0)
378 if e1 != 0 {
379 err = errnoErr(e1)
380 }
381 return
382 }
383
384
385
386 func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
387 r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags))
388 n = int64(r0)
389 if e1 != 0 {
390 err = errnoErr(e1)
391 }
392 return
393 }
394
395
396
397 func Statfs(path string, buf *Statfs_t) (err error) {
398 var _p0 *byte
399 _p0, err = BytePtrFromString(path)
400 if err != nil {
401 return
402 }
403 _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
404 if e1 != 0 {
405 err = errnoErr(e1)
406 }
407 return
408 }
409
410
411
412 func SyncFileRange(fd int, off int64, n int64, flags int) (err error) {
413 _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0)
414 if e1 != 0 {
415 err = errnoErr(e1)
416 }
417 return
418 }
419
420
421
422 func Truncate(path string, length int64) (err error) {
423 var _p0 *byte
424 _p0, err = BytePtrFromString(path)
425 if err != nil {
426 return
427 }
428 _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
429 if e1 != 0 {
430 err = errnoErr(e1)
431 }
432 return
433 }
434
435
436
437 func Ustat(dev int, ubuf *Ustat_t) (err error) {
438 _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0)
439 if e1 != 0 {
440 err = errnoErr(e1)
441 }
442 return
443 }
444
445
446
447 func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
448 r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
449 fd = int(r0)
450 if e1 != 0 {
451 err = errnoErr(e1)
452 }
453 return
454 }
455
456
457
458 func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) {
459 r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
460 fd = int(r0)
461 if e1 != 0 {
462 err = errnoErr(e1)
463 }
464 return
465 }
466
467
468
469 func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
470 _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
471 if e1 != 0 {
472 err = errnoErr(e1)
473 }
474 return
475 }
476
477
478
479 func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
480 _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
481 if e1 != 0 {
482 err = errnoErr(e1)
483 }
484 return
485 }
486
487
488
489 func getgroups(n int, list *_Gid_t) (nn int, err error) {
490 r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
491 nn = int(r0)
492 if e1 != 0 {
493 err = errnoErr(e1)
494 }
495 return
496 }
497
498
499
500 func setgroups(n int, list *_Gid_t) (err error) {
501 _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
502 if e1 != 0 {
503 err = errnoErr(e1)
504 }
505 return
506 }
507
508
509
510 func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
511 _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
512 if e1 != 0 {
513 err = errnoErr(e1)
514 }
515 return
516 }
517
518
519
520 func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
521 _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
522 if e1 != 0 {
523 err = errnoErr(e1)
524 }
525 return
526 }
527
528
529
530 func socket(domain int, typ int, proto int) (fd int, err error) {
531 r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
532 fd = int(r0)
533 if e1 != 0 {
534 err = errnoErr(e1)
535 }
536 return
537 }
538
539
540
541 func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
542 _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
543 if e1 != 0 {
544 err = errnoErr(e1)
545 }
546 return
547 }
548
549
550
551 func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
552 _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
553 if e1 != 0 {
554 err = errnoErr(e1)
555 }
556 return
557 }
558
559
560
561 func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
562 _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
563 if e1 != 0 {
564 err = errnoErr(e1)
565 }
566 return
567 }
568
569
570
571 func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
572 var _p0 unsafe.Pointer
573 if len(p) > 0 {
574 _p0 = unsafe.Pointer(&p[0])
575 } else {
576 _p0 = unsafe.Pointer(&_zero)
577 }
578 r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
579 n = int(r0)
580 if e1 != 0 {
581 err = errnoErr(e1)
582 }
583 return
584 }
585
586
587
588 func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
589 var _p0 unsafe.Pointer
590 if len(buf) > 0 {
591 _p0 = unsafe.Pointer(&buf[0])
592 } else {
593 _p0 = unsafe.Pointer(&_zero)
594 }
595 _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
596 if e1 != 0 {
597 err = errnoErr(e1)
598 }
599 return
600 }
601
602
603
604 func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
605 r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
606 n = int(r0)
607 if e1 != 0 {
608 err = errnoErr(e1)
609 }
610 return
611 }
612
613
614
615 func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
616 r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
617 n = int(r0)
618 if e1 != 0 {
619 err = errnoErr(e1)
620 }
621 return
622 }
623
624
625
626 func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
627 r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset))
628 xaddr = uintptr(r0)
629 if e1 != 0 {
630 err = errnoErr(e1)
631 }
632 return
633 }
634
635
636
637 func futimesat(dirfd int, path string, times *[2]Timeval) (err error) {
638 var _p0 *byte
639 _p0, err = BytePtrFromString(path)
640 if err != nil {
641 return
642 }
643 _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)))
644 if e1 != 0 {
645 err = errnoErr(e1)
646 }
647 return
648 }
649
650
651
652 func Utime(path string, buf *Utimbuf) (err error) {
653 var _p0 *byte
654 _p0, err = BytePtrFromString(path)
655 if err != nil {
656 return
657 }
658 _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
659 if e1 != 0 {
660 err = errnoErr(e1)
661 }
662 return
663 }
664
665
666
667 func utimes(path string, times *[2]Timeval) (err error) {
668 var _p0 *byte
669 _p0, err = BytePtrFromString(path)
670 if err != nil {
671 return
672 }
673 _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0)
674 if e1 != 0 {
675 err = errnoErr(e1)
676 }
677 return
678 }
679
680
681
682 func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) {
683 var _p0 *byte
684 _p0, err = BytePtrFromString(cmdline)
685 if err != nil {
686 return
687 }
688 _, _, e1 := Syscall6(SYS_KEXEC_FILE_LOAD, uintptr(kernelFd), uintptr(initrdFd), uintptr(cmdlineLen), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
689 if e1 != 0 {
690 err = errnoErr(e1)
691 }
692 return
693 }
694
View as plain text