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(mask>>32), uintptr(dirFd), uintptr(unsafe.Pointer(pathname)))
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(off>>32), uintptr(len), uintptr(len>>32))
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, r1, e1 := Syscall6(SYS_TEE, uintptr(rfd), uintptr(wfd), uintptr(len), uintptr(flags), 0, 0)
40 n = int64(int64(r1)<<32 | 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_64, uintptr(fd), uintptr(offset), uintptr(offset>>32), uintptr(length), uintptr(length>>32), uintptr(advice))
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_FCHOWN32, 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_FSTAT64, 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_FSTATAT64, 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 Ftruncate(fd int, length int64) (err error) {
112 _, _, e1 := Syscall(SYS_FTRUNCATE64, uintptr(fd), uintptr(length), uintptr(length>>32))
113 if e1 != 0 {
114 err = errnoErr(e1)
115 }
116 return
117 }
118
119
120
121 func Getegid() (egid int) {
122 r0, _ := RawSyscallNoError(SYS_GETEGID32, 0, 0, 0)
123 egid = int(r0)
124 return
125 }
126
127
128
129 func Geteuid() (euid int) {
130 r0, _ := RawSyscallNoError(SYS_GETEUID32, 0, 0, 0)
131 euid = int(r0)
132 return
133 }
134
135
136
137 func Getgid() (gid int) {
138 r0, _ := RawSyscallNoError(SYS_GETGID32, 0, 0, 0)
139 gid = int(r0)
140 return
141 }
142
143
144
145 func Getuid() (uid int) {
146 r0, _ := RawSyscallNoError(SYS_GETUID32, 0, 0, 0)
147 uid = int(r0)
148 return
149 }
150
151
152
153 func Ioperm(from int, num int, on int) (err error) {
154 _, _, e1 := Syscall(SYS_IOPERM, uintptr(from), uintptr(num), uintptr(on))
155 if e1 != 0 {
156 err = errnoErr(e1)
157 }
158 return
159 }
160
161
162
163 func Iopl(level int) (err error) {
164 _, _, e1 := Syscall(SYS_IOPL, uintptr(level), 0, 0)
165 if e1 != 0 {
166 err = errnoErr(e1)
167 }
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_LCHOWN32, 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_LSTAT64, 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 Pread(fd int, p []byte, offset int64) (n int, err error) {
204 var _p0 unsafe.Pointer
205 if len(p) > 0 {
206 _p0 = unsafe.Pointer(&p[0])
207 } else {
208 _p0 = unsafe.Pointer(&_zero)
209 }
210 r0, _, e1 := Syscall6(SYS_PREAD64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
211 n = int(r0)
212 if e1 != 0 {
213 err = errnoErr(e1)
214 }
215 return
216 }
217
218
219
220 func Pwrite(fd int, p []byte, offset int64) (n int, err error) {
221 var _p0 unsafe.Pointer
222 if len(p) > 0 {
223 _p0 = unsafe.Pointer(&p[0])
224 } else {
225 _p0 = unsafe.Pointer(&_zero)
226 }
227 r0, _, e1 := Syscall6(SYS_PWRITE64, uintptr(fd), uintptr(_p0), uintptr(len(p)), uintptr(offset), uintptr(offset>>32), 0)
228 n = int(r0)
229 if e1 != 0 {
230 err = errnoErr(e1)
231 }
232 return
233 }
234
235
236
237 func Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) {
238 var _p0 *byte
239 _p0, err = BytePtrFromString(oldpath)
240 if err != nil {
241 return
242 }
243 var _p1 *byte
244 _p1, err = BytePtrFromString(newpath)
245 if err != nil {
246 return
247 }
248 _, _, e1 := Syscall6(SYS_RENAMEAT, uintptr(olddirfd), uintptr(unsafe.Pointer(_p0)), uintptr(newdirfd), uintptr(unsafe.Pointer(_p1)), 0, 0)
249 if e1 != 0 {
250 err = errnoErr(e1)
251 }
252 return
253 }
254
255
256
257 func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) {
258 r0, _, e1 := Syscall6(SYS_SENDFILE64, uintptr(outfd), uintptr(infd), uintptr(unsafe.Pointer(offset)), uintptr(count), 0, 0)
259 written = int(r0)
260 if e1 != 0 {
261 err = errnoErr(e1)
262 }
263 return
264 }
265
266
267
268 func setfsgid(gid int) (prev int, err error) {
269 r0, _, e1 := Syscall(SYS_SETFSGID32, uintptr(gid), 0, 0)
270 prev = int(r0)
271 if e1 != 0 {
272 err = errnoErr(e1)
273 }
274 return
275 }
276
277
278
279 func setfsuid(uid int) (prev int, err error) {
280 r0, _, e1 := Syscall(SYS_SETFSUID32, uintptr(uid), 0, 0)
281 prev = int(r0)
282 if e1 != 0 {
283 err = errnoErr(e1)
284 }
285 return
286 }
287
288
289
290 func Setregid(rgid int, egid int) (err error) {
291 _, _, e1 := RawSyscall(SYS_SETREGID32, uintptr(rgid), uintptr(egid), 0)
292 if e1 != 0 {
293 err = errnoErr(e1)
294 }
295 return
296 }
297
298
299
300 func Setresgid(rgid int, egid int, sgid int) (err error) {
301 _, _, e1 := RawSyscall(SYS_SETRESGID32, uintptr(rgid), uintptr(egid), uintptr(sgid))
302 if e1 != 0 {
303 err = errnoErr(e1)
304 }
305 return
306 }
307
308
309
310 func Setresuid(ruid int, euid int, suid int) (err error) {
311 _, _, e1 := RawSyscall(SYS_SETRESUID32, uintptr(ruid), uintptr(euid), uintptr(suid))
312 if e1 != 0 {
313 err = errnoErr(e1)
314 }
315 return
316 }
317
318
319
320 func Setreuid(ruid int, euid int) (err error) {
321 _, _, e1 := RawSyscall(SYS_SETREUID32, uintptr(ruid), uintptr(euid), 0)
322 if e1 != 0 {
323 err = errnoErr(e1)
324 }
325 return
326 }
327
328
329
330 func Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int, err error) {
331 r0, _, e1 := Syscall6(SYS_SPLICE, uintptr(rfd), uintptr(unsafe.Pointer(roff)), uintptr(wfd), uintptr(unsafe.Pointer(woff)), uintptr(len), uintptr(flags))
332 n = int(r0)
333 if e1 != 0 {
334 err = errnoErr(e1)
335 }
336 return
337 }
338
339
340
341 func Stat(path string, stat *Stat_t) (err error) {
342 var _p0 *byte
343 _p0, err = BytePtrFromString(path)
344 if err != nil {
345 return
346 }
347 _, _, e1 := Syscall(SYS_STAT64, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(stat)), 0)
348 if e1 != 0 {
349 err = errnoErr(e1)
350 }
351 return
352 }
353
354
355
356 func SyncFileRange(fd int, off int64, n int64, flags int) (err error) {
357 _, _, e1 := Syscall6(SYS_SYNC_FILE_RANGE, uintptr(fd), uintptr(off), uintptr(off>>32), uintptr(n), uintptr(n>>32), uintptr(flags))
358 if e1 != 0 {
359 err = errnoErr(e1)
360 }
361 return
362 }
363
364
365
366 func Truncate(path string, length int64) (err error) {
367 var _p0 *byte
368 _p0, err = BytePtrFromString(path)
369 if err != nil {
370 return
371 }
372 _, _, e1 := Syscall(SYS_TRUNCATE64, uintptr(unsafe.Pointer(_p0)), uintptr(length), uintptr(length>>32))
373 if e1 != 0 {
374 err = errnoErr(e1)
375 }
376 return
377 }
378
379
380
381 func Ustat(dev int, ubuf *Ustat_t) (err error) {
382 _, _, e1 := Syscall(SYS_USTAT, uintptr(dev), uintptr(unsafe.Pointer(ubuf)), 0)
383 if e1 != 0 {
384 err = errnoErr(e1)
385 }
386 return
387 }
388
389
390
391 func getgroups(n int, list *_Gid_t) (nn int, err error) {
392 r0, _, e1 := RawSyscall(SYS_GETGROUPS32, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
393 nn = int(r0)
394 if e1 != 0 {
395 err = errnoErr(e1)
396 }
397 return
398 }
399
400
401
402 func setgroups(n int, list *_Gid_t) (err error) {
403 _, _, e1 := RawSyscall(SYS_SETGROUPS32, uintptr(n), uintptr(unsafe.Pointer(list)), 0)
404 if e1 != 0 {
405 err = errnoErr(e1)
406 }
407 return
408 }
409
410
411
412 func Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) {
413 r0, _, e1 := Syscall6(SYS__NEWSELECT, uintptr(nfd), uintptr(unsafe.Pointer(r)), uintptr(unsafe.Pointer(w)), uintptr(unsafe.Pointer(e)), uintptr(unsafe.Pointer(timeout)), 0)
414 n = int(r0)
415 if e1 != 0 {
416 err = errnoErr(e1)
417 }
418 return
419 }
420
421
422
423 func mmap2(addr uintptr, length uintptr, prot int, flags int, fd int, pageOffset uintptr) (xaddr uintptr, err error) {
424 r0, _, e1 := Syscall6(SYS_MMAP2, uintptr(addr), uintptr(length), uintptr(prot), uintptr(flags), uintptr(fd), uintptr(pageOffset))
425 xaddr = uintptr(r0)
426 if e1 != 0 {
427 err = errnoErr(e1)
428 }
429 return
430 }
431
432
433
434 func Pause() (err error) {
435 _, _, e1 := Syscall(SYS_PAUSE, 0, 0, 0)
436 if e1 != 0 {
437 err = errnoErr(e1)
438 }
439 return
440 }
441
442
443
444 func getrlimit(resource int, rlim *rlimit32) (err error) {
445 _, _, e1 := RawSyscall(SYS_GETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
446 if e1 != 0 {
447 err = errnoErr(e1)
448 }
449 return
450 }
451
452
453
454 func setrlimit(resource int, rlim *rlimit32) (err error) {
455 _, _, e1 := RawSyscall(SYS_SETRLIMIT, uintptr(resource), uintptr(unsafe.Pointer(rlim)), 0)
456 if e1 != 0 {
457 err = errnoErr(e1)
458 }
459 return
460 }
461
462
463
464 func futimesat(dirfd int, path string, times *[2]Timeval) (err error) {
465 var _p0 *byte
466 _p0, err = BytePtrFromString(path)
467 if err != nil {
468 return
469 }
470 _, _, e1 := Syscall(SYS_FUTIMESAT, uintptr(dirfd), uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)))
471 if e1 != 0 {
472 err = errnoErr(e1)
473 }
474 return
475 }
476
477
478
479 func Gettimeofday(tv *Timeval) (err error) {
480 _, _, e1 := RawSyscall(SYS_GETTIMEOFDAY, uintptr(unsafe.Pointer(tv)), 0, 0)
481 if e1 != 0 {
482 err = errnoErr(e1)
483 }
484 return
485 }
486
487
488
489 func Time(t *Time_t) (tt Time_t, err error) {
490 r0, _, e1 := RawSyscall(SYS_TIME, uintptr(unsafe.Pointer(t)), 0, 0)
491 tt = Time_t(r0)
492 if e1 != 0 {
493 err = errnoErr(e1)
494 }
495 return
496 }
497
498
499
500 func Utime(path string, buf *Utimbuf) (err error) {
501 var _p0 *byte
502 _p0, err = BytePtrFromString(path)
503 if err != nil {
504 return
505 }
506 _, _, e1 := Syscall(SYS_UTIME, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(buf)), 0)
507 if e1 != 0 {
508 err = errnoErr(e1)
509 }
510 return
511 }
512
513
514
515 func utimes(path string, times *[2]Timeval) (err error) {
516 var _p0 *byte
517 _p0, err = BytePtrFromString(path)
518 if err != nil {
519 return
520 }
521 _, _, e1 := Syscall(SYS_UTIMES, uintptr(unsafe.Pointer(_p0)), uintptr(unsafe.Pointer(times)), 0)
522 if e1 != 0 {
523 err = errnoErr(e1)
524 }
525 return
526 }
527
View as plain text