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_WAIT, 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(dirfd 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_NEWFSTATAT, uintptr(dirfd), 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 Lchown(path string, uid int, gid int) (err error) {
174 var _p0 *byte
175 _p0, err = BytePtrFromString(path)
176 if err != nil {
177 return
178 }
179 _, _, e1 := Syscall(SYS_LCHOWN, uintptr(unsafe.Pointer(_p0)), uintptr(uid), uintptr(gid))
180 if e1 != 0 {
181 err = errnoErr(e1)
182 }
183 return
184 }
185
186
187
188 func Lstat(path string, stat *Stat_t) (err error) {
189 var _p0 *byte
190 _p0, err = BytePtrFromString(path)
191 if err != nil {
192 return
193 }
194 _, _, e1 := Syscall(SYS_LSTAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
195 if e1 != 0 {
196 err = errnoErr(e1)
197 }
198 return
199 }
200
201
202
203 func Pause() (err error) {
204 _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0)
205 if e1 != 0 {
206 err = errnoErr(e1)
207 }
208 return
209 }
210
211
212
213 func Pread(fd int, p []byte, offset int64) (n int, err error) {
214 var _p0 unsafe.Pointer
215 if len(p) > 0 {
216 _p0 = unsafe.Pointer(&p[0])
217 } else {
218 _p0 = unsafe.Pointer(&_zero)
219 }
220 r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
221 n = int(r0)
222 if e1 != 0 {
223 err = errnoErr(e1)
224 }
225 return
226 }
227
228
229
230 func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
231 var _p0 unsafe.Pointer
232 if len(p) > 0 {
233 _p0 = unsafe.Pointer(&p[0])
234 } else {
235 _p0 = unsafe.Pointer(&_zero)
236 }
237 r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), 0, 0)
238 n = int(r0)
239 if e1 != 0 {
240 err = errnoErr(e1)
241 }
242 return
243 }
244
245
246
247 func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
248 var _p0 *byte
249 _p0, err = BytePtrFromString(oldpath)
250 if err != nil {
251 return
252 }
253 var _p1 *byte
254 _p1, err = BytePtrFromString(newpath)
255 if err != nil {
256 return
257 }
258 _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0)
259 if e1 != 0 {
260 err = errnoErr(e1)
261 }
262 return
263 }
264
265
266
267 func Seek(fd int, offset int64, whence int) (off int64, err error) {
268 r0, _, e1 := Syscall(SYS_LSEEK, uintptr(fd), uintptr(offset), uintptr(whence))
269 off = int64(r0)
270 if e1 != 0 {
271 err = errnoErr(e1)
272 }
273 return
274 }
275
276
277
278 func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
279 r0, _, e1 := Syscall6(SYS_SELECT, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
280 n = int(r0)
281 if e1 != 0 {
282 err = errnoErr(e1)
283 }
284 return
285 }
286
287
288
289 func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
290 r0, _, e1 := Syscall6(SYS_SENDFILE, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0)
291 written = int(r0)
292 if e1 != 0 {
293 err = errnoErr(e1)
294 }
295 return
296 }
297
298
299
300 func setfsgid(gid int) (prev int, err error) {
301 r0, _, e1 := Syscall(SYS_SETFSGID, uintptr(gid), 0, 0)
302 prev = int(r0)
303 if e1 != 0 {
304 err = errnoErr(e1)
305 }
306 return
307 }
308
309
310
311 func setfsuid(uid int) (prev int, err error) {
312 r0, _, e1 := Syscall(SYS_SETFSUID, uintptr(uid), 0, 0)
313 prev = int(r0)
314 if e1 != 0 {
315 err = errnoErr(e1)
316 }
317 return
318 }
319
320
321
322 func Setregid(rgid int, egid int) (err error) {
323 _, _, e1 := RawSyscall(SYS_SETREGID, uintptr(rgid), uintptr(egid), 0)
324 if e1 != 0 {
325 err = errnoErr(e1)
326 }
327 return
328 }
329
330
331
332 func Setresgid(rgid int, egid int, sgid int) (err error) {
333 _, _, e1 := RawSyscall(SYS_SETRESGID, uintptr(rgid), uintptr(egid), uintptr(sgid))
334 if e1 != 0 {
335 err = errnoErr(e1)
336 }
337 return
338 }
339
340
341
342 func Setresuid(ruid int, euid int, suid int) (err error) {
343 _, _, e1 := RawSyscall(SYS_SETRESUID, uintptr(ruid), uintptr(euid), uintptr(suid))
344 if e1 != 0 {
345 err = errnoErr(e1)
346 }
347 return
348 }
349
350
351
352 func Setrlimit(resource int, rlim *Rlimit) (err error) {
353 _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
354 if e1 != 0 {
355 err = errnoErr(e1)
356 }
357 return
358 }
359
360
361
362 func Setreuid(ruid int, euid int) (err error) {
363 _, _, e1 := RawSyscall(SYS_SETREUID, uintptr(ruid), uintptr(euid), 0)
364 if e1 != 0 {
365 err = errnoErr(e1)
366 }
367 return
368 }
369
370
371
372 func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) {
373 r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags))
374 n = int64(r0)
375 if e1 != 0 {
376 err = errnoErr(e1)
377 }
378 return
379 }
380
381
382
383 func Stat(path string, stat *Stat_t) (err error) {
384 var _p0 *byte
385 _p0, err = BytePtrFromString(path)
386 if err != nil {
387 return
388 }
389 _, _, e1 := Syscall(SYS_STAT, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
390 if e1 != 0 {
391 err = errnoErr(e1)
392 }
393 return
394 }
395
396
397
398 func Statfs(path string, buf *Statfs_t) (err error) {
399 var _p0 *byte
400 _p0, err = BytePtrFromString(path)
401 if err != nil {
402 return
403 }
404 _, _, e1 := Syscall(SYS_STATFS, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
405 if e1 != 0 {
406 err = errnoErr(e1)
407 }
408 return
409 }
410
411
412
413 func SyncFileRange(fd int, off int64, n int64, flags int) (err error) {
414 _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(n), uintptr(flags), 0, 0)
415 if e1 != 0 {
416 err = errnoErr(e1)
417 }
418 return
419 }
420
421
422
423 func Truncate(path string, length int64) (err error) {
424 var _p0 *byte
425 _p0, err = BytePtrFromString(path)
426 if err != nil {
427 return
428 }
429 _, _, e1 := Syscall(SYS_TRUNCATE, uintptr(unsafe.Pointer(_p0)), uintptr(length), 0)
430 if e1 != 0 {
431 err = errnoErr(e1)
432 }
433 return
434 }
435
436
437
438 func Ustat(dev int, ubuf *Ustat_t) (err error) {
439 _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0)
440 if e1 != 0 {
441 err = errnoErr(e1)
442 }
443 return
444 }
445
446
447
448 func getgroups(n int, list *_Gid_t) (nn int, err error) {
449 r0, _, e1 := RawSyscall(SYS_GETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
450 nn = int(r0)
451 if e1 != 0 {
452 err = errnoErr(e1)
453 }
454 return
455 }
456
457
458
459 func setgroups(n int, list *_Gid_t) (err error) {
460 _, _, e1 := RawSyscall(SYS_SETGROUPS, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
461 if e1 != 0 {
462 err = errnoErr(e1)
463 }
464 return
465 }
466
467
468
469 func futimesat(dirfd int, path string, times *[2]Timeval) (err error) {
470 var _p0 *byte
471 _p0, err = BytePtrFromString(path)
472 if err != nil {
473 return
474 }
475 _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)))
476 if e1 != 0 {
477 err = errnoErr(e1)
478 }
479 return
480 }
481
482
483
484 func Gettimeofday(tv *Timeval) (err error) {
485 _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
486 if e1 != 0 {
487 err = errnoErr(e1)
488 }
489 return
490 }
491
492
493
494 func Utime(path string, buf *Utimbuf) (err error) {
495 var _p0 *byte
496 _p0, err = BytePtrFromString(path)
497 if err != nil {
498 return
499 }
500 _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
501 if e1 != 0 {
502 err = errnoErr(e1)
503 }
504 return
505 }
506
507
508
509 func utimes(path string, times *[2]Timeval) (err error) {
510 var _p0 *byte
511 _p0, err = BytePtrFromString(path)
512 if err != nil {
513 return
514 }
515 _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0)
516 if e1 != 0 {
517 err = errnoErr(e1)
518 }
519 return
520 }
521
522
523
524 func kexecFileLoad(kernelFd int, initrdFd int, cmdlineLen int, cmdline string, flags int) (err error) {
525 var _p0 *byte
526 _p0, err = BytePtrFromString(cmdline)
527 if err != nil {
528 return
529 }
530 _, _, e1 := Syscall6(SYS_KEXEC_FILE_LOAD, uintptr(kernelFd), uintptr(initrdFd), uintptr(cmdlineLen), uintptr(unsafe.Pointer(_p0)), uintptr(flags), 0)
531 if e1 != 0 {
532 err = errnoErr(e1)
533 }
534 return
535 }
536
View as plain text