]>
Commit | Line | Data |
---|---|---|
15c0b25d AP |
1 | // Copyright 2018 The Go Authors. All rights reserved. |
2 | // Use of this source code is governed by a BSD-style | |
3 | // license that can be found in the LICENSE file. | |
4 | ||
5 | // +build aix | |
6 | ||
7 | // Aix system calls. | |
8 | // This file is compiled as ordinary Go code, | |
9 | // but it is also input to mksyscall, | |
10 | // which parses the //sys lines and generates system call stubs. | |
11 | // Note that sometimes we use a lowercase //sys name and | |
12 | // wrap it in our own nicer implementation. | |
13 | ||
14 | package unix | |
15 | ||
107c1cdb | 16 | import "unsafe" |
15c0b25d AP |
17 | |
18 | /* | |
19 | * Wrapped | |
20 | */ | |
21 | ||
22 | //sys utimes(path string, times *[2]Timeval) (err error) | |
23 | func Utimes(path string, tv []Timeval) error { | |
24 | if len(tv) != 2 { | |
25 | return EINVAL | |
26 | } | |
27 | return utimes(path, (*[2]Timeval)(unsafe.Pointer(&tv[0]))) | |
28 | } | |
29 | ||
30 | //sys utimensat(dirfd int, path string, times *[2]Timespec, flag int) (err error) | |
31 | func UtimesNano(path string, ts []Timespec) error { | |
32 | if len(ts) != 2 { | |
33 | return EINVAL | |
34 | } | |
35 | return utimensat(AT_FDCWD, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), 0) | |
36 | } | |
37 | ||
38 | func UtimesNanoAt(dirfd int, path string, ts []Timespec, flags int) error { | |
39 | if ts == nil { | |
40 | return utimensat(dirfd, path, nil, flags) | |
41 | } | |
42 | if len(ts) != 2 { | |
43 | return EINVAL | |
44 | } | |
45 | return utimensat(dirfd, path, (*[2]Timespec)(unsafe.Pointer(&ts[0])), flags) | |
46 | } | |
47 | ||
48 | func (sa *SockaddrInet4) sockaddr() (unsafe.Pointer, _Socklen, error) { | |
49 | if sa.Port < 0 || sa.Port > 0xFFFF { | |
50 | return nil, 0, EINVAL | |
51 | } | |
52 | sa.raw.Family = AF_INET | |
53 | p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) | |
54 | p[0] = byte(sa.Port >> 8) | |
55 | p[1] = byte(sa.Port) | |
56 | for i := 0; i < len(sa.Addr); i++ { | |
57 | sa.raw.Addr[i] = sa.Addr[i] | |
58 | } | |
59 | return unsafe.Pointer(&sa.raw), SizeofSockaddrInet4, nil | |
60 | } | |
61 | ||
62 | func (sa *SockaddrInet6) sockaddr() (unsafe.Pointer, _Socklen, error) { | |
63 | if sa.Port < 0 || sa.Port > 0xFFFF { | |
64 | return nil, 0, EINVAL | |
65 | } | |
66 | sa.raw.Family = AF_INET6 | |
67 | p := (*[2]byte)(unsafe.Pointer(&sa.raw.Port)) | |
68 | p[0] = byte(sa.Port >> 8) | |
69 | p[1] = byte(sa.Port) | |
70 | sa.raw.Scope_id = sa.ZoneId | |
71 | for i := 0; i < len(sa.Addr); i++ { | |
72 | sa.raw.Addr[i] = sa.Addr[i] | |
73 | } | |
74 | return unsafe.Pointer(&sa.raw), SizeofSockaddrInet6, nil | |
75 | } | |
76 | ||
77 | func (sa *SockaddrUnix) sockaddr() (unsafe.Pointer, _Socklen, error) { | |
78 | name := sa.Name | |
79 | n := len(name) | |
80 | if n > len(sa.raw.Path) { | |
81 | return nil, 0, EINVAL | |
82 | } | |
83 | if n == len(sa.raw.Path) && name[0] != '@' { | |
84 | return nil, 0, EINVAL | |
85 | } | |
86 | sa.raw.Family = AF_UNIX | |
87 | for i := 0; i < n; i++ { | |
88 | sa.raw.Path[i] = uint8(name[i]) | |
89 | } | |
90 | // length is family (uint16), name, NUL. | |
91 | sl := _Socklen(2) | |
92 | if n > 0 { | |
93 | sl += _Socklen(n) + 1 | |
94 | } | |
95 | if sa.raw.Path[0] == '@' { | |
96 | sa.raw.Path[0] = 0 | |
97 | // Don't count trailing NUL for abstract address. | |
98 | sl-- | |
99 | } | |
100 | ||
101 | return unsafe.Pointer(&sa.raw), sl, nil | |
102 | } | |
103 | ||
104 | func Getsockname(fd int) (sa Sockaddr, err error) { | |
105 | var rsa RawSockaddrAny | |
106 | var len _Socklen = SizeofSockaddrAny | |
107 | if err = getsockname(fd, &rsa, &len); err != nil { | |
108 | return | |
109 | } | |
110 | return anyToSockaddr(fd, &rsa) | |
111 | } | |
112 | ||
113 | //sys getcwd(buf []byte) (err error) | |
114 | ||
115 | const ImplementsGetwd = true | |
116 | ||
117 | func Getwd() (ret string, err error) { | |
118 | for len := uint64(4096); ; len *= 2 { | |
119 | b := make([]byte, len) | |
120 | err := getcwd(b) | |
121 | if err == nil { | |
122 | i := 0 | |
123 | for b[i] != 0 { | |
124 | i++ | |
125 | } | |
126 | return string(b[0:i]), nil | |
127 | } | |
128 | if err != ERANGE { | |
129 | return "", err | |
130 | } | |
131 | } | |
132 | } | |
133 | ||
134 | func Getcwd(buf []byte) (n int, err error) { | |
135 | err = getcwd(buf) | |
136 | if err == nil { | |
137 | i := 0 | |
138 | for buf[i] != 0 { | |
139 | i++ | |
140 | } | |
141 | n = i + 1 | |
142 | } | |
143 | return | |
144 | } | |
145 | ||
146 | func Getgroups() (gids []int, err error) { | |
147 | n, err := getgroups(0, nil) | |
148 | if err != nil { | |
149 | return nil, err | |
150 | } | |
151 | if n == 0 { | |
152 | return nil, nil | |
153 | } | |
154 | ||
155 | // Sanity check group count. Max is 16 on BSD. | |
156 | if n < 0 || n > 1000 { | |
157 | return nil, EINVAL | |
158 | } | |
159 | ||
160 | a := make([]_Gid_t, n) | |
161 | n, err = getgroups(n, &a[0]) | |
162 | if err != nil { | |
163 | return nil, err | |
164 | } | |
165 | gids = make([]int, n) | |
166 | for i, v := range a[0:n] { | |
167 | gids[i] = int(v) | |
168 | } | |
169 | return | |
170 | } | |
171 | ||
172 | func Setgroups(gids []int) (err error) { | |
173 | if len(gids) == 0 { | |
174 | return setgroups(0, nil) | |
175 | } | |
176 | ||
177 | a := make([]_Gid_t, len(gids)) | |
178 | for i, v := range gids { | |
179 | a[i] = _Gid_t(v) | |
180 | } | |
181 | return setgroups(len(a), &a[0]) | |
182 | } | |
183 | ||
184 | /* | |
185 | * Socket | |
186 | */ | |
187 | ||
188 | //sys accept(s int, rsa *RawSockaddrAny, addrlen *_Socklen) (fd int, err error) | |
189 | ||
190 | func Accept(fd int) (nfd int, sa Sockaddr, err error) { | |
191 | var rsa RawSockaddrAny | |
192 | var len _Socklen = SizeofSockaddrAny | |
193 | nfd, err = accept(fd, &rsa, &len) | |
194 | if nfd == -1 { | |
195 | return | |
196 | } | |
197 | sa, err = anyToSockaddr(fd, &rsa) | |
198 | if err != nil { | |
199 | Close(nfd) | |
200 | nfd = 0 | |
201 | } | |
202 | return | |
203 | } | |
204 | ||
205 | func Recvmsg(fd int, p, oob []byte, flags int) (n, oobn int, recvflags int, from Sockaddr, err error) { | |
206 | // Recvmsg not implemented on AIX | |
207 | sa := new(SockaddrUnix) | |
208 | return -1, -1, -1, sa, ENOSYS | |
209 | } | |
210 | ||
211 | func Sendmsg(fd int, p, oob []byte, to Sockaddr, flags int) (err error) { | |
212 | _, err = SendmsgN(fd, p, oob, to, flags) | |
213 | return | |
214 | } | |
215 | ||
216 | func SendmsgN(fd int, p, oob []byte, to Sockaddr, flags int) (n int, err error) { | |
217 | // SendmsgN not implemented on AIX | |
218 | return -1, ENOSYS | |
219 | } | |
220 | ||
221 | func anyToSockaddr(fd int, rsa *RawSockaddrAny) (Sockaddr, error) { | |
222 | switch rsa.Addr.Family { | |
223 | ||
224 | case AF_UNIX: | |
225 | pp := (*RawSockaddrUnix)(unsafe.Pointer(rsa)) | |
226 | sa := new(SockaddrUnix) | |
227 | ||
228 | // Some versions of AIX have a bug in getsockname (see IV78655). | |
229 | // We can't rely on sa.Len being set correctly. | |
107c1cdb | 230 | n := SizeofSockaddrUnix - 3 // subtract leading Family, Len, terminating NUL. |
15c0b25d AP |
231 | for i := 0; i < n; i++ { |
232 | if pp.Path[i] == 0 { | |
233 | n = i | |
234 | break | |
235 | } | |
236 | } | |
237 | ||
238 | bytes := (*[10000]byte)(unsafe.Pointer(&pp.Path[0]))[0:n] | |
239 | sa.Name = string(bytes) | |
240 | return sa, nil | |
241 | ||
242 | case AF_INET: | |
243 | pp := (*RawSockaddrInet4)(unsafe.Pointer(rsa)) | |
244 | sa := new(SockaddrInet4) | |
245 | p := (*[2]byte)(unsafe.Pointer(&pp.Port)) | |
246 | sa.Port = int(p[0])<<8 + int(p[1]) | |
247 | for i := 0; i < len(sa.Addr); i++ { | |
248 | sa.Addr[i] = pp.Addr[i] | |
249 | } | |
250 | return sa, nil | |
251 | ||
252 | case AF_INET6: | |
253 | pp := (*RawSockaddrInet6)(unsafe.Pointer(rsa)) | |
254 | sa := new(SockaddrInet6) | |
255 | p := (*[2]byte)(unsafe.Pointer(&pp.Port)) | |
256 | sa.Port = int(p[0])<<8 + int(p[1]) | |
257 | sa.ZoneId = pp.Scope_id | |
258 | for i := 0; i < len(sa.Addr); i++ { | |
259 | sa.Addr[i] = pp.Addr[i] | |
260 | } | |
261 | return sa, nil | |
262 | } | |
263 | return nil, EAFNOSUPPORT | |
264 | } | |
265 | ||
266 | func Gettimeofday(tv *Timeval) (err error) { | |
267 | err = gettimeofday(tv, nil) | |
268 | return | |
269 | } | |
270 | ||
107c1cdb ND |
271 | func Sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { |
272 | if raceenabled { | |
273 | raceReleaseMerge(unsafe.Pointer(&ioSync)) | |
274 | } | |
275 | return sendfile(outfd, infd, offset, count) | |
276 | } | |
277 | ||
15c0b25d AP |
278 | // TODO |
279 | func sendfile(outfd int, infd int, offset *int64, count int) (written int, err error) { | |
280 | return -1, ENOSYS | |
281 | } | |
282 | ||
283 | //sys getdirent(fd int, buf []byte) (n int, err error) | |
284 | func ReadDirent(fd int, buf []byte) (n int, err error) { | |
285 | return getdirent(fd, buf) | |
286 | } | |
287 | ||
288 | //sys wait4(pid Pid_t, status *_C_int, options int, rusage *Rusage) (wpid Pid_t, err error) | |
289 | func Wait4(pid int, wstatus *WaitStatus, options int, rusage *Rusage) (wpid int, err error) { | |
290 | var status _C_int | |
291 | var r Pid_t | |
292 | err = ERESTART | |
293 | // AIX wait4 may return with ERESTART errno, while the processus is still | |
294 | // active. | |
295 | for err == ERESTART { | |
296 | r, err = wait4(Pid_t(pid), &status, options, rusage) | |
297 | } | |
298 | wpid = int(r) | |
299 | if wstatus != nil { | |
300 | *wstatus = WaitStatus(status) | |
301 | } | |
302 | return | |
303 | } | |
304 | ||
305 | /* | |
306 | * Wait | |
307 | */ | |
308 | ||
309 | type WaitStatus uint32 | |
310 | ||
311 | func (w WaitStatus) Stopped() bool { return w&0x40 != 0 } | |
312 | func (w WaitStatus) StopSignal() Signal { | |
313 | if !w.Stopped() { | |
314 | return -1 | |
315 | } | |
316 | return Signal(w>>8) & 0xFF | |
317 | } | |
318 | ||
319 | func (w WaitStatus) Exited() bool { return w&0xFF == 0 } | |
320 | func (w WaitStatus) ExitStatus() int { | |
321 | if !w.Exited() { | |
322 | return -1 | |
323 | } | |
324 | return int((w >> 8) & 0xFF) | |
325 | } | |
326 | ||
327 | func (w WaitStatus) Signaled() bool { return w&0x40 == 0 && w&0xFF != 0 } | |
328 | func (w WaitStatus) Signal() Signal { | |
329 | if !w.Signaled() { | |
330 | return -1 | |
331 | } | |
332 | return Signal(w>>16) & 0xFF | |
333 | } | |
334 | ||
335 | func (w WaitStatus) Continued() bool { return w&0x01000000 != 0 } | |
336 | ||
337 | func (w WaitStatus) CoreDump() bool { return w&0x200 != 0 } | |
338 | ||
339 | func (w WaitStatus) TrapCause() int { return -1 } | |
340 | ||
341 | //sys ioctl(fd int, req uint, arg uintptr) (err error) | |
342 | ||
343 | // ioctl itself should not be exposed directly, but additional get/set | |
344 | // functions for specific types are permissible. | |
345 | ||
346 | // IoctlSetInt performs an ioctl operation which sets an integer value | |
347 | // on fd, using the specified request number. | |
348 | func IoctlSetInt(fd int, req uint, value int) error { | |
349 | return ioctl(fd, req, uintptr(value)) | |
350 | } | |
351 | ||
352 | func ioctlSetWinsize(fd int, req uint, value *Winsize) error { | |
353 | return ioctl(fd, req, uintptr(unsafe.Pointer(value))) | |
354 | } | |
355 | ||
356 | func ioctlSetTermios(fd int, req uint, value *Termios) error { | |
357 | return ioctl(fd, req, uintptr(unsafe.Pointer(value))) | |
358 | } | |
359 | ||
360 | // IoctlGetInt performs an ioctl operation which gets an integer value | |
361 | // from fd, using the specified request number. | |
362 | func IoctlGetInt(fd int, req uint) (int, error) { | |
363 | var value int | |
364 | err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) | |
365 | return value, err | |
366 | } | |
367 | ||
368 | func IoctlGetWinsize(fd int, req uint) (*Winsize, error) { | |
369 | var value Winsize | |
370 | err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) | |
371 | return &value, err | |
372 | } | |
373 | ||
374 | func IoctlGetTermios(fd int, req uint) (*Termios, error) { | |
375 | var value Termios | |
376 | err := ioctl(fd, req, uintptr(unsafe.Pointer(&value))) | |
377 | return &value, err | |
378 | } | |
379 | ||
380 | // fcntl must never be called with cmd=F_DUP2FD because it doesn't work on AIX | |
381 | // There is no way to create a custom fcntl and to keep //sys fcntl easily, | |
382 | // Therefore, the programmer must call dup2 instead of fcntl in this case. | |
383 | ||
384 | // FcntlInt performs a fcntl syscall on fd with the provided command and argument. | |
385 | //sys FcntlInt(fd uintptr, cmd int, arg int) (r int,err error) = fcntl | |
386 | ||
387 | // FcntlFlock performs a fcntl syscall for the F_GETLK, F_SETLK or F_SETLKW command. | |
388 | //sys FcntlFlock(fd uintptr, cmd int, lk *Flock_t) (err error) = fcntl | |
389 | ||
390 | //sys fcntl(fd int, cmd int, arg int) (val int, err error) | |
391 | ||
15c0b25d AP |
392 | /* |
393 | * Direct access | |
394 | */ | |
395 | ||
396 | //sys Acct(path string) (err error) | |
397 | //sys Chdir(path string) (err error) | |
398 | //sys Chroot(path string) (err error) | |
399 | //sys Close(fd int) (err error) | |
400 | //sys Dup(oldfd int) (fd int, err error) | |
401 | //sys Exit(code int) | |
402 | //sys Faccessat(dirfd int, path string, mode uint32, flags int) (err error) | |
403 | //sys Fchdir(fd int) (err error) | |
404 | //sys Fchmod(fd int, mode uint32) (err error) | |
405 | //sys Fchmodat(dirfd int, path string, mode uint32, flags int) (err error) | |
406 | //sys Fchownat(dirfd int, path string, uid int, gid int, flags int) (err error) | |
407 | //sys Fdatasync(fd int) (err error) | |
408 | //sys Fsync(fd int) (err error) | |
409 | // readdir_r | |
410 | //sysnb Getpgid(pid int) (pgid int, err error) | |
411 | ||
412 | //sys Getpgrp() (pid int) | |
413 | ||
414 | //sysnb Getpid() (pid int) | |
415 | //sysnb Getppid() (ppid int) | |
416 | //sys Getpriority(which int, who int) (prio int, err error) | |
417 | //sysnb Getrusage(who int, rusage *Rusage) (err error) | |
418 | //sysnb Getsid(pid int) (sid int, err error) | |
419 | //sysnb Kill(pid int, sig Signal) (err error) | |
420 | //sys Klogctl(typ int, buf []byte) (n int, err error) = syslog | |
421 | //sys Mkdir(dirfd int, path string, mode uint32) (err error) | |
422 | //sys Mkdirat(dirfd int, path string, mode uint32) (err error) | |
423 | //sys Mkfifo(path string, mode uint32) (err error) | |
424 | //sys Mknod(path string, mode uint32, dev int) (err error) | |
425 | //sys Mknodat(dirfd int, path string, mode uint32, dev int) (err error) | |
426 | //sys Nanosleep(time *Timespec, leftover *Timespec) (err error) | |
427 | //sys Open(path string, mode int, perm uint32) (fd int, err error) = open64 | |
428 | //sys Openat(dirfd int, path string, flags int, mode uint32) (fd int, err error) | |
429 | //sys read(fd int, p []byte) (n int, err error) | |
430 | //sys Readlink(path string, buf []byte) (n int, err error) | |
431 | //sys Renameat(olddirfd int, oldpath string, newdirfd int, newpath string) (err error) | |
432 | //sys Setdomainname(p []byte) (err error) | |
433 | //sys Sethostname(p []byte) (err error) | |
434 | //sysnb Setpgid(pid int, pgid int) (err error) | |
435 | //sysnb Setsid() (pid int, err error) | |
436 | //sysnb Settimeofday(tv *Timeval) (err error) | |
437 | ||
438 | //sys Setuid(uid int) (err error) | |
439 | //sys Setgid(uid int) (err error) | |
440 | ||
441 | //sys Setpriority(which int, who int, prio int) (err error) | |
442 | //sys Statx(dirfd int, path string, flags int, mask int, stat *Statx_t) (err error) | |
443 | //sys Sync() | |
444 | //sysnb Times(tms *Tms) (ticks uintptr, err error) | |
445 | //sysnb Umask(mask int) (oldmask int) | |
446 | //sysnb Uname(buf *Utsname) (err error) | |
15c0b25d AP |
447 | //sys Unlink(path string) (err error) |
448 | //sys Unlinkat(dirfd int, path string, flags int) (err error) | |
449 | //sys Ustat(dev int, ubuf *Ustat_t) (err error) | |
450 | //sys write(fd int, p []byte) (n int, err error) | |
451 | //sys readlen(fd int, p *byte, np int) (n int, err error) = read | |
452 | //sys writelen(fd int, p *byte, np int) (n int, err error) = write | |
453 | ||
454 | //sys Dup2(oldfd int, newfd int) (err error) | |
455 | //sys Fadvise(fd int, offset int64, length int64, advice int) (err error) = posix_fadvise64 | |
456 | //sys Fchown(fd int, uid int, gid int) (err error) | |
457 | //sys Fstat(fd int, stat *Stat_t) (err error) | |
458 | //sys Fstatat(dirfd int, path string, stat *Stat_t, flags int) (err error) = fstatat | |
459 | //sys Fstatfs(fd int, buf *Statfs_t) (err error) | |
460 | //sys Ftruncate(fd int, length int64) (err error) | |
461 | //sysnb Getegid() (egid int) | |
462 | //sysnb Geteuid() (euid int) | |
463 | //sysnb Getgid() (gid int) | |
464 | //sysnb Getuid() (uid int) | |
465 | //sys Lchown(path string, uid int, gid int) (err error) | |
466 | //sys Listen(s int, n int) (err error) | |
467 | //sys Lstat(path string, stat *Stat_t) (err error) | |
468 | //sys Pause() (err error) | |
469 | //sys Pread(fd int, p []byte, offset int64) (n int, err error) = pread64 | |
470 | //sys Pwrite(fd int, p []byte, offset int64) (n int, err error) = pwrite64 | |
107c1cdb | 471 | //sys Select(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timeval) (n int, err error) |
15c0b25d AP |
472 | //sys Pselect(nfd int, r *FdSet, w *FdSet, e *FdSet, timeout *Timespec, sigmask *Sigset_t) (n int, err error) |
473 | //sysnb Setregid(rgid int, egid int) (err error) | |
474 | //sysnb Setreuid(ruid int, euid int) (err error) | |
475 | //sys Shutdown(fd int, how int) (err error) | |
476 | //sys Splice(rfd int, roff *int64, wfd int, woff *int64, len int, flags int) (n int64, err error) | |
477 | //sys Stat(path string, stat *Stat_t) (err error) | |
478 | //sys Statfs(path string, buf *Statfs_t) (err error) | |
479 | //sys Truncate(path string, length int64) (err error) | |
480 | ||
481 | //sys bind(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) | |
482 | //sys connect(s int, addr unsafe.Pointer, addrlen _Socklen) (err error) | |
483 | //sysnb getgroups(n int, list *_Gid_t) (nn int, err error) | |
484 | //sysnb setgroups(n int, list *_Gid_t) (err error) | |
485 | //sys getsockopt(s int, level int, name int, val unsafe.Pointer, vallen *_Socklen) (err error) | |
486 | //sys setsockopt(s int, level int, name int, val unsafe.Pointer, vallen uintptr) (err error) | |
487 | //sysnb socket(domain int, typ int, proto int) (fd int, err error) | |
488 | //sysnb socketpair(domain int, typ int, proto int, fd *[2]int32) (err error) | |
489 | //sysnb getpeername(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) | |
490 | //sysnb getsockname(fd int, rsa *RawSockaddrAny, addrlen *_Socklen) (err error) | |
491 | //sys recvfrom(fd int, p []byte, flags int, from *RawSockaddrAny, fromlen *_Socklen) (n int, err error) | |
492 | //sys sendto(s int, buf []byte, flags int, to unsafe.Pointer, addrlen _Socklen) (err error) | |
107c1cdb ND |
493 | |
494 | // In order to use msghdr structure with Control, Controllen, nrecvmsg and nsendmsg must be used. | |
495 | //sys recvmsg(s int, msg *Msghdr, flags int) (n int, err error) = nrecvmsg | |
496 | //sys sendmsg(s int, msg *Msghdr, flags int) (n int, err error) = nsendmsg | |
15c0b25d AP |
497 | |
498 | //sys munmap(addr uintptr, length uintptr) (err error) | |
499 | ||
500 | var mapper = &mmapper{ | |
501 | active: make(map[*byte][]byte), | |
502 | mmap: mmap, | |
503 | munmap: munmap, | |
504 | } | |
505 | ||
506 | func Mmap(fd int, offset int64, length int, prot int, flags int) (data []byte, err error) { | |
507 | return mapper.Mmap(fd, offset, length, prot, flags) | |
508 | } | |
509 | ||
510 | func Munmap(b []byte) (err error) { | |
511 | return mapper.Munmap(b) | |
512 | } | |
513 | ||
514 | //sys Madvise(b []byte, advice int) (err error) | |
515 | //sys Mprotect(b []byte, prot int) (err error) | |
516 | //sys Mlock(b []byte) (err error) | |
517 | //sys Mlockall(flags int) (err error) | |
518 | //sys Msync(b []byte, flags int) (err error) | |
519 | //sys Munlock(b []byte) (err error) | |
520 | //sys Munlockall() (err error) | |
521 | ||
522 | //sysnb pipe(p *[2]_C_int) (err error) | |
523 | ||
524 | func Pipe(p []int) (err error) { | |
525 | if len(p) != 2 { | |
526 | return EINVAL | |
527 | } | |
528 | var pp [2]_C_int | |
529 | err = pipe(&pp) | |
530 | p[0] = int(pp[0]) | |
531 | p[1] = int(pp[1]) | |
532 | return | |
533 | } | |
534 | ||
535 | //sys poll(fds *PollFd, nfds int, timeout int) (n int, err error) | |
536 | ||
537 | func Poll(fds []PollFd, timeout int) (n int, err error) { | |
538 | if len(fds) == 0 { | |
539 | return poll(nil, 0, timeout) | |
540 | } | |
541 | return poll(&fds[0], len(fds), timeout) | |
542 | } | |
543 | ||
544 | //sys gettimeofday(tv *Timeval, tzp *Timezone) (err error) | |
545 | //sysnb Time(t *Time_t) (tt Time_t, err error) | |
546 | //sys Utime(path string, buf *Utimbuf) (err error) | |
107c1cdb ND |
547 | |
548 | //sys Getsystemcfg(label int) (n uint64) | |
549 | ||
550 | //sys umount(target string) (err error) | |
551 | func Unmount(target string, flags int) (err error) { | |
552 | if flags != 0 { | |
553 | // AIX doesn't have any flags for umount. | |
554 | return ENOSYS | |
555 | } | |
556 | return umount(target) | |
557 | } |