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