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