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