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_FSTATAT64, 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 Lchown(path string, uid int, gid int) (err error) {
173 var _p0 *byte
174 _p0, err = BytePtrFromString(path)
175 if err != nil {
176 return
177 }
178 _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
179 if e1 != 0 {
180 err = errnoErr(e1)
181 }
182 return
183 }
184
185
186
187 func Listen(s int, n int) (err error) {
188 _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0)
189 if e1 != 0 {
190 err = errnoErr(e1)
191 }
192 return
193 }
194
195
196
197 func Lstat(path string, stat *Stat_t) (err error) {
198 var _p0 *byte
199 _p0, err = BytePtrFromString(path)
200 if err != nil {
201 return
202 }
203 _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
204 if e1 != 0 {
205 err = errnoErr(e1)
206 }
207 return
208 }
209
210
211
212 func Pause() (err error) {
213 _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0)
214 if e1 != 0 {
215 err = errnoErr(e1)
216 }
217 return
218 }
219
220
221
222 func pread(fd int, p []byte, offset int64) (n int, err error) {
223 var _p0 unsafe.Pointer
224 if len(p) > 0 {
225 _p0 = unsafe.Pointer(&p[0])
226 } else {
227 _p0 = unsafe.Pointer(&_zero)
228 }
229 r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
230 n = int(r0)
231 if e1 != 0 {
232 err = errnoErr(e1)
233 }
234 return
235 }
236
237
238
239 func pwrite(fd int, p []byte, offset int64) (n int, err error) {
240 var _p0 unsafe.Pointer
241 if len(p) > 0 {
242 _p0 = unsafe.Pointer(&p[0])
243 } else {
244 _p0 = unsafe.Pointer(&_zero)
245 }
246 r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
247 n = int(r0)
248 if e1 != 0 {
249 err = errnoErr(e1)
250 }
251 return
252 }
253
254
255
256 func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
257 var _p0 *byte
258 _p0, err = BytePtrFromString(oldpath)
259 if err != nil {
260 return
261 }
262 var _p1 *byte
263 _p1, err = BytePtrFromString(newpath)
264 if err != nil {
265 return
266 }
267 _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0)
268 if e1 != 0 {
269 err = errnoErr(e1)
270 }
271 return
272 }
273
274
275
276 func Seek(fd int, offset int64, whence int) (off int64, err error) {
277 r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
278 off = int64(r0)
279 if e1 != 0 {
280 err = errnoErr(e1)
281 }
282 return
283 }
284
285
286
287 func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
288 r0, _, e1 := Syscall6(SYS_SELECT, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
289 n = int(r0)
290 if e1 != 0 {
291 err = errnoErr(e1)
292 }
293 return
294 }
295
296
297
298 func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
299 r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0)
300 written = int(r0)
301 if e1 != 0 {
302 err = errnoErr(e1)
303 }
304 return
305 }
306
307
308
309 func setfsgid(gid int) (prev int, err error) {
310 r0, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0)
311 prev = int(r0)
312 if e1 != 0 {
313 err = errnoErr(e1)
314 }
315 return
316 }
317
318
319
320 func setfsuid(uid int) (prev int, err error) {
321 r0, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0)
322 prev = int(r0)
323 if e1 != 0 {
324 err = errnoErr(e1)
325 }
326 return
327 }
328
329
330
331 func Shutdown(fd int, how int) (err error) {
332 _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0)
333 if e1 != 0 {
334 err = errnoErr(e1)
335 }
336 return
337 }
338
339
340
341 func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
342 r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags))
343 n = int64(r0)
344 if e1 != 0 {
345 err = errnoErr(e1)
346 }
347 return
348 }
349
350
351
352 func Stat(path string, stat *Stat_t) (err error) {
353 var _p0 *byte
354 _p0, err = BytePtrFromString(path)
355 if err != nil {
356 return
357 }
358 _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
359 if e1 != 0 {
360 err = errnoErr(e1)
361 }
362 return
363 }
364
365
366
367 func Statfs(path string, buf *Statfs_t) (err error) {
368 var _p0 *byte
369 _p0, err = BytePtrFromString(path)
370 if err != nil {
371 return
372 }
373 _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
374 if e1 != 0 {
375 err = errnoErr(e1)
376 }
377 return
378 }
379
380
381
382 func SyncFileRange(fd int, off int64, n int64, flags int) (err error) {
383 _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0)
384 if e1 != 0 {
385 err = errnoErr(e1)
386 }
387 return
388 }
389
390
391
392 func Truncate(path string, length int64) (err error) {
393 var _p0 *byte
394 _p0, err = BytePtrFromString(path)
395 if err != nil {
396 return
397 }
398 _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 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 Gettimeofday(tv *Timeval) (err error) {
602 _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
603 if e1 != 0 {
604 err = errnoErr(e1)
605 }
606 return
607 }
608
609
610
611 func Utime(path string, buf *Utimbuf) (err error) {
612 var _p0 *byte
613 _p0, err = BytePtrFromString(path)
614 if err != nil {
615 return
616 }
617 _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
618 if e1 != 0 {
619 err = errnoErr(e1)
620 }
621 return
622 }
623
624
625
626 func utimes(path string, times *[2]Timeval) (err error) {
627 var _p0 *byte
628 _p0, err = BytePtrFromString(path)
629 if err != nil {
630 return
631 }
632 _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0)
633 if e1 != 0 {
634 err = errnoErr(e1)
635 }
636 return
637 }
638
639
640
641 func Alarm(seconds uint) (remaining uint, err error) {
642 r0, _, e1 := Syscall(SYS_ALARM, uintptr(seconds), 0, 0)
643 remaining = uint(r0)
644 if e1 != 0 {
645 err = errnoErr(e1)
646 }
647 return
648 }
649
View as plain text