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