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