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_PWAIT, 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(fd 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_FSTATAT, uintptr(fd), 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 Listen(s int, n int) (err error) {
174 _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0)
175 if e1 != 0 {
176 err = errnoErr(e1)
177 }
178 return
179 }
180
181
182
183 func Pread(fd int, p []byte, offset int64) (n int, err error) {
184 var _p0 unsafe.Pointer
185 if len(p) > 0 {
186 _p0 = unsafe.Pointer(&p[0])
187 } else {
188 _p0 = unsafe.Pointer(&_zero)
189 }
190 r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
191 n = int(r0)
192 if e1 != 0 {
193 err = errnoErr(e1)
194 }
195 return
196 }
197
198
199
200 func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
201 var _p0 unsafe.Pointer
202 if len(p) > 0 {
203 _p0 = unsafe.Pointer(&p[0])
204 } else {
205 _p0 = unsafe.Pointer(&_zero)
206 }
207 r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
208 n = int(r0)
209 if e1 != 0 {
210 err = errnoErr(e1)
211 }
212 return
213 }
214
215
216
217 func Seek(fd int, offset int64, whence int) (off int64, err error) {
218 r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
219 off = int64(r0)
220 if e1 != 0 {
221 err = errnoErr(e1)
222 }
223 return
224 }
225
226
227
228 func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
229 r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0)
230 written = int(r0)
231 if e1 != 0 {
232 err = errnoErr(e1)
233 }
234 return
235 }
236
237
238
239 func setfsgid(gid int) (prev int, err error) {
240 r0, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0)
241 prev = int(r0)
242 if e1 != 0 {
243 err = errnoErr(e1)
244 }
245 return
246 }
247
248
249
250 func setfsuid(uid int) (prev int, err error) {
251 r0, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0)
252 prev = int(r0)
253 if e1 != 0 {
254 err = errnoErr(e1)
255 }
256 return
257 }
258
259
260
261 func Setregid(rgid int, egid int) (err error) {
262 _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
263 if e1 != 0 {
264 err = errnoErr(e1)
265 }
266 return
267 }
268
269
270
271 func Setresgid(rgid int, egid int, sgid int) (err error) {
272 _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid))
273 if e1 != 0 {
274 err = errnoErr(e1)
275 }
276 return
277 }
278
279
280
281 func Setresuid(ruid int, euid int, suid int) (err error) {
282 _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid))
283 if e1 != 0 {
284 err = errnoErr(e1)
285 }
286 return
287 }
288
289
290
291 func Setrlimit(resource int, rlim *Rlimit) (err error) {
292 _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
293 if e1 != 0 {
294 err = errnoErr(e1)
295 }
296 return
297 }
298
299
300
301 func Setreuid(ruid int, euid int) (err error) {
302 _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
303 if e1 != 0 {
304 err = errnoErr(e1)
305 }
306 return
307 }
308
309
310
311 func Shutdown(fd int, how int) (err error) {
312 _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0)
313 if e1 != 0 {
314 err = errnoErr(e1)
315 }
316 return
317 }
318
319
320
321 func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
322 r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags))
323 n = int64(r0)
324 if e1 != 0 {
325 err = errnoErr(e1)
326 }
327 return
328 }
329
330
331
332 func Statfs(path string, buf *Statfs_t) (err error) {
333 var _p0 *byte
334 _p0, err = BytePtrFromString(path)
335 if err != nil {
336 return
337 }
338 _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
339 if e1 != 0 {
340 err = errnoErr(e1)
341 }
342 return
343 }
344
345
346
347 func SyncFileRange(fd int, off int64, n int64, flags int) (err error) {
348 _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0)
349 if e1 != 0 {
350 err = errnoErr(e1)
351 }
352 return
353 }
354
355
356
357 func Truncate(path string, length int64) (err error) {
358 var _p0 *byte
359 _p0, err = BytePtrFromString(path)
360 if err != nil {
361 return
362 }
363 _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
364 if e1 != 0 {
365 err = errnoErr(e1)
366 }
367 return
368 }
369
370
371
372 func accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) {
373 r0, _, e1 := Syscall(SYS_ACCEPT, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
374 fd = int(r0)
375 if e1 != 0 {
376 err = errnoErr(e1)
377 }
378 return
379 }
380
381
382
383 func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) {
384 r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
385 fd = int(r0)
386 if e1 != 0 {
387 err = errnoErr(e1)
388 }
389 return
390 }
391
392
393
394 func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
395 _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
396 if e1 != 0 {
397 err = errnoErr(e1)
398 }
399 return
400 }
401
402
403
404 func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
405 _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
406 if e1 != 0 {
407 err = errnoErr(e1)
408 }
409 return
410 }
411
412
413
414 func getgroups(n int, list *_Gid_t) (nn int, err error) {
415 r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
416 nn = int(r0)
417 if e1 != 0 {
418 err = errnoErr(e1)
419 }
420 return
421 }
422
423
424
425 func setgroups(n int, list *_Gid_t) (err error) {
426 _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
427 if e1 != 0 {
428 err = errnoErr(e1)
429 }
430 return
431 }
432
433
434
435 func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
436 _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
437 if e1 != 0 {
438 err = errnoErr(e1)
439 }
440 return
441 }
442
443
444
445 func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
446 _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
447 if e1 != 0 {
448 err = errnoErr(e1)
449 }
450 return
451 }
452
453
454
455 func socket(domain int, typ int, proto int) (fd int, err error) {
456 r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
457 fd = int(r0)
458 if e1 != 0 {
459 err = errnoErr(e1)
460 }
461 return
462 }
463
464
465
466 func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
467 _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
468 if e1 != 0 {
469 err = errnoErr(e1)
470 }
471 return
472 }
473
474
475
476 func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
477 _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
478 if e1 != 0 {
479 err = errnoErr(e1)
480 }
481 return
482 }
483
484
485
486 func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
487 _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
488 if e1 != 0 {
489 err = errnoErr(e1)
490 }
491 return
492 }
493
494
495
496 func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
497 var _p0 unsafe.Pointer
498 if len(p) > 0 {
499 _p0 = unsafe.Pointer(&p[0])
500 } else {
501 _p0 = unsafe.Pointer(&_zero)
502 }
503 r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
504 n = int(r0)
505 if e1 != 0 {
506 err = errnoErr(e1)
507 }
508 return
509 }
510
511
512
513 func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
514 var _p0 unsafe.Pointer
515 if len(buf) > 0 {
516 _p0 = unsafe.Pointer(&buf[0])
517 } else {
518 _p0 = unsafe.Pointer(&_zero)
519 }
520 _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
521 if e1 != 0 {
522 err = errnoErr(e1)
523 }
524 return
525 }
526
527
528
529 func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
530 r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
531 n = int(r0)
532 if e1 != 0 {
533 err = errnoErr(e1)
534 }
535 return
536 }
537
538
539
540 func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
541 r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
542 n = int(r0)
543 if e1 != 0 {
544 err = errnoErr(e1)
545 }
546 return
547 }
548
549
550
551 func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
552 r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset))
553 xaddr = uintptr(r0)
554 if e1 != 0 {
555 err = errnoErr(e1)
556 }
557 return
558 }
559
560
561
562 func Gettimeofday(tv *Timeval) (err error) {
563 _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
564 if e1 != 0 {
565 err = errnoErr(e1)
566 }
567 return
568 }
569
570
571
572 func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) {
573 var _p0 *byte
574 _p0, err = BytePtrFromString(cmdline)
575 if err != nil {
576 return
577 }
578 _, _, e1 := Syscall6(SYS_KEXEC_FILE_LOAD, uintptr(kernelFd), uintptr(initrdFd), uintptr(cmdlineLen), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
579 if e1 != 0 {
580 err = errnoErr(e1)
581 }
582 return
583 }
584
View as plain text