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