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 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 Getuid() (uid int) {
130 r0, _ := RawSyscallNoError(SYS_GETUID, 0, 0, 0)
131 uid = int(r0)
132 return
133 }
134
135
136
137 func Listen(s int, n int) (err error) {
138 _, _, e1 := Syscall(SYS_LISTEN, uintptr(s), uintptr(n), 0)
139 if e1 != 0 {
140 err = errnoErr(e1)
141 }
142 return
143 }
144
145
146
147 func pread(fd int, p []byte, offset int64) (n int, err error) {
148 var _p0 unsafe.Pointer
149 if len(p) > 0 {
150 _p0 = unsafe.Pointer(&p[0])
151 } else {
152 _p0 = unsafe.Pointer(&_zero)
153 }
154 r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
155 n = int(r0)
156 if e1 != 0 {
157 err = errnoErr(e1)
158 }
159 return
160 }
161
162
163
164 func pwrite(fd int, p []byte, offset int64) (n int, err error) {
165 var _p0 unsafe.Pointer
166 if len(p) > 0 {
167 _p0 = unsafe.Pointer(&p[0])
168 } else {
169 _p0 = unsafe.Pointer(&_zero)
170 }
171 r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
172 n = int(r0)
173 if e1 != 0 {
174 err = errnoErr(e1)
175 }
176 return
177 }
178
179
180
181 func Seek(fd int, offset int64, whence int) (off int64, err error) {
182 r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
183 off = int64(r0)
184 if e1 != 0 {
185 err = errnoErr(e1)
186 }
187 return
188 }
189
190
191
192 func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
193 r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0)
194 written = int(r0)
195 if e1 != 0 {
196 err = errnoErr(e1)
197 }
198 return
199 }
200
201
202
203 func setfsgid(gid int) (prev int, err error) {
204 r0, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0)
205 prev = int(r0)
206 if e1 != 0 {
207 err = errnoErr(e1)
208 }
209 return
210 }
211
212
213
214 func setfsuid(uid int) (prev int, err error) {
215 r0, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0)
216 prev = int(r0)
217 if e1 != 0 {
218 err = errnoErr(e1)
219 }
220 return
221 }
222
223
224
225 func Shutdown(fd int, how int) (err error) {
226 _, _, e1 := Syscall(SYS_SHUTDOWN, uintptr(fd), uintptr(how), 0)
227 if e1 != 0 {
228 err = errnoErr(e1)
229 }
230 return
231 }
232
233
234
235 func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
236 r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags))
237 n = int64(r0)
238 if e1 != 0 {
239 err = errnoErr(e1)
240 }
241 return
242 }
243
244
245
246 func Statfs(path string, buf *Statfs_t) (err error) {
247 var _p0 *byte
248 _p0, err = BytePtrFromString(path)
249 if err != nil {
250 return
251 }
252 _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
253 if e1 != 0 {
254 err = errnoErr(e1)
255 }
256 return
257 }
258
259
260
261 func SyncFileRange(fd int, off int64, n int64, flags int) (err error) {
262 _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0)
263 if e1 != 0 {
264 err = errnoErr(e1)
265 }
266 return
267 }
268
269
270
271 func Truncate(path string, length int64) (err error) {
272 var _p0 *byte
273 _p0, err = BytePtrFromString(path)
274 if err != nil {
275 return
276 }
277 _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
278 if e1 != 0 {
279 err = errnoErr(e1)
280 }
281 return
282 }
283
284
285
286 func accept4(s int, rsa *RawSockaddrAny, addrlen *_Socklen, flags int) (fd int, err error) {
287 r0, _, e1 := Syscall6(SYS_ACCEPT4, uintptr(s), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)), uintptr(flags), 0, 0)
288 fd = int(r0)
289 if e1 != 0 {
290 err = errnoErr(e1)
291 }
292 return
293 }
294
295
296
297 func bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
298 _, _, e1 := Syscall(SYS_BIND, uintptr(s), uintptr(addr), uintptr(addrlen))
299 if e1 != 0 {
300 err = errnoErr(e1)
301 }
302 return
303 }
304
305
306
307 func connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) {
308 _, _, e1 := Syscall(SYS_CONNECT, uintptr(s), uintptr(addr), uintptr(addrlen))
309 if e1 != 0 {
310 err = errnoErr(e1)
311 }
312 return
313 }
314
315
316
317 func getgroups(n int, list *_Gid_t) (nn int, err error) {
318 r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
319 nn = int(r0)
320 if e1 != 0 {
321 err = errnoErr(e1)
322 }
323 return
324 }
325
326
327
328 func setgroups(n int, list *_Gid_t) (err error) {
329 _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
330 if e1 != 0 {
331 err = errnoErr(e1)
332 }
333 return
334 }
335
336
337
338 func getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) {
339 _, _, e1 := Syscall6(SYS_GETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(unsafe.Pointer(vallen)), 0)
340 if e1 != 0 {
341 err = errnoErr(e1)
342 }
343 return
344 }
345
346
347
348 func setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) {
349 _, _, e1 := Syscall6(SYS_SETSOCKOPT, uintptr(s), uintptr(level), uintptr(name), uintptr(val), uintptr(vallen), 0)
350 if e1 != 0 {
351 err = errnoErr(e1)
352 }
353 return
354 }
355
356
357
358 func socket(domain int, typ int, proto int) (fd int, err error) {
359 r0, _, e1 := RawSyscall(SYS_SOCKET, uintptr(domain), uintptr(typ), uintptr(proto))
360 fd = int(r0)
361 if e1 != 0 {
362 err = errnoErr(e1)
363 }
364 return
365 }
366
367
368
369 func socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) {
370 _, _, e1 := RawSyscall6(SYS_SOCKETPAIR, uintptr(domain), uintptr(typ), uintptr(proto), uintptr(unsafe.Pointer(fd)), 0, 0)
371 if e1 != 0 {
372 err = errnoErr(e1)
373 }
374 return
375 }
376
377
378
379 func getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
380 _, _, e1 := RawSyscall(SYS_GETPEERNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
381 if e1 != 0 {
382 err = errnoErr(e1)
383 }
384 return
385 }
386
387
388
389 func getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) {
390 _, _, e1 := RawSyscall(SYS_GETSOCKNAME, uintptr(fd), uintptr(unsafe.Pointer(rsa)), uintptr(unsafe.Pointer(addrlen)))
391 if e1 != 0 {
392 err = errnoErr(e1)
393 }
394 return
395 }
396
397
398
399 func recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) {
400 var _p0 unsafe.Pointer
401 if len(p) > 0 {
402 _p0 = unsafe.Pointer(&p[0])
403 } else {
404 _p0 = unsafe.Pointer(&_zero)
405 }
406 r0, _, e1 := Syscall6(SYS_RECVFROM, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(flags), uintptr(unsafe.Pointer(from)), uintptr(unsafe.Pointer(fromlen)))
407 n = int(r0)
408 if e1 != 0 {
409 err = errnoErr(e1)
410 }
411 return
412 }
413
414
415
416 func sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) {
417 var _p0 unsafe.Pointer
418 if len(buf) > 0 {
419 _p0 = unsafe.Pointer(&buf[0])
420 } else {
421 _p0 = unsafe.Pointer(&_zero)
422 }
423 _, _, e1 := Syscall6(SYS_SENDTO, uintptr(s), uintptr(_p0), uintptr(len(buf)), uintptr(flags), uintptr(to), uintptr(addrlen))
424 if e1 != 0 {
425 err = errnoErr(e1)
426 }
427 return
428 }
429
430
431
432 func recvmsg(s int, msg *Msghdr, flags int) (n int, err error) {
433 r0, _, e1 := Syscall(SYS_RECVMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
434 n = int(r0)
435 if e1 != 0 {
436 err = errnoErr(e1)
437 }
438 return
439 }
440
441
442
443 func sendmsg(s int, msg *Msghdr, flags int) (n int, err error) {
444 r0, _, e1 := Syscall(SYS_SENDMSG, uintptr(s), uintptr(unsafe.Pointer(msg)), uintptr(flags))
445 n = int(r0)
446 if e1 != 0 {
447 err = errnoErr(e1)
448 }
449 return
450 }
451
452
453
454 func mmap(addr uintptr, length uintptr, prot int, flags int, fd int, offset int64) (xaddr uintptr, err error) {
455 r0, _, e1 := Syscall6(SYS_MMAP, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(offset))
456 xaddr = uintptr(r0)
457 if e1 != 0 {
458 err = errnoErr(e1)
459 }
460 return
461 }
462
463
464
465 func Gettimeofday(tv *Timeval) (err error) {
466 _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
467 if e1 != 0 {
468 err = errnoErr(e1)
469 }
470 return
471 }
472
473
474
475 func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) {
476 var _p0 *byte
477 _p0, err = BytePtrFromString(cmdline)
478 if err != nil {
479 return
480 }
481 _, _, e1 := Syscall6(SYS_KEXEC_FILE_LOAD, uintptr(kernelFd), uintptr(initrdFd), uintptr(cmdlineLen), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
482 if e1 != 0 {
483 err = errnoErr(e1)
484 }
485 return
486 }
487
View as plain text