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