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