2 * Acess2 POSIX Emulation Layer
6 * - POSIX->Acess VFS call translation
11 #include <sys/select.h>
14 int unlink(const char *pathname)
16 return _SysUnlink(pathname);
19 int open(const char *path, int openmode, ...)
21 mode_t create_mode = 0;
24 switch( openmode & O_RDWR )
28 case O_RDONLY: openflags |= OPENFLAG_READ; break;
29 case O_WRONLY: openflags |= OPENFLAG_WRITE; break;
30 case O_RDWR: openflags |= OPENFLAG_READ|OPENFLAG_WRITE; break;
33 if( openmode & O_CREAT ) {
34 openflags |= OPENFLAG_CREATE;
36 va_start(args, openmode);
37 create_mode = va_arg(args, mode_t);
41 return _SysOpen(path, openflags, create_mode);
44 int creat(const char *path, mode_t mode)
46 // TODO: Make native call to do this cheaper
47 int fd = _SysOpen(path, OPENFLAG_CREATE, mode);
48 if( fd == -1 ) return -1;
59 ssize_t write(int fd, const void *buf, size_t count)
61 return _SysWrite(fd, buf, count);
64 ssize_t read(int fd, void *buf, size_t count)
66 return _SysRead(fd, buf, count);
69 int seek(int fd, int whence, off_t dest)
71 return _SysSeek(fd, whence, dest);
81 return _SysClone(CLONE_VM, 0);
84 int execv(const char *b, char *v[])
86 return _SysExecVE(b, v, NULL);
91 // NOTE: Acess's CopyFD doesn't cause offset sharing
92 // TODO: Check that -1 does cause a new allocation
93 return _SysCopyFD(oldfd, -1);
96 int dup2(int oldfd, int newfd)
98 // NOTE: Acess's CopyFD doesn't cause offset sharing
99 return _SysCopyFD(oldfd, newfd);
112 int kill(pid_t pid, int signal)
114 // TODO: Need special handling?
115 return _SysKill(pid, signal);
118 int select(int nfd, fd_set *rfd, fd_set *wfd, fd_set *efd, struct timeval *timeout)
123 long long int ltimeout = 0;
124 ltimeout = timeout->tv_sec*1000 + timeout->tv_usec / 1000;
125 int ret = _SysSelect(nfd, rfd, wfd, efd, <imeout, 0);
130 return _SysSelect(nfd, rfd, wfd, efd, NULL, 0);
134 int pipe(int pipefd[2])
136 pipefd[0] = _SysOpen("/Devices/fifo/anon", OPENFLAG_READ|OPENFLAG_WRITE);
137 pipefd[1] = _SysCopyFD(pipefd[0], -1);
138 _SysFDFlags(pipefd[1], OPENFLAG_READ|OPENFLAG_WRITE, OPENFLAG_WRITE);