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