- Implemented first time functions.
[planlOS.git] / programs / libc / unistd.c
blobc5d47bee8f4187b8eab62fa8bb2845f4ab6a2e44
1 /*
2 Copyright (C) 2008 Mathias Gottschlag
4 Permission is hereby granted, free of charge, to any person obtaining a copy of
5 this software and associated documentation files (the "Software"), to deal in the
6 Software without restriction, including without limitation the rights to use,
7 copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the
8 Software, and to permit persons to whom the Software is furnished to do so,
9 subject to the following conditions:
11 The above copyright notice and this permission notice shall be included in all
12 copies or substantial portions of the Software.
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
15 INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
16 PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
17 HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
18 OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
19 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 #include <unistd.h>
23 #include <fcntl.h>
24 #include <planlos/syscalls.h>
26 pid_t fork(void)
28 int status = -1;
29 asm volatile("int $0x80" : "=b"(status): "a"(SYS_FORK));
30 return status;
33 int execl(const char *path, const char *arg0, ...)
35 int status = -1;
36 asm volatile("int $0x80" : "=b"(status): "a"(SYS_EXEC), "b"(path));
37 return status;
39 int execle(const char *path, const char *arg0, ...)
41 return -1;
43 int execlp(const char *file, const char *arg0, ...)
45 return -1;
47 int execv(const char *path, char *const argv[])
49 return -1;
51 int execve(const char *file, char *const argv[], char *const env[])
53 return -1;
55 int execvp(const char *path, char *const argv[])
57 return -1;
60 char *getcwd(char *buf, size_t size)
62 int status = -1;
63 asm volatile("int $0x80" : "=b"(status): "a"(SYS_GETWD), "b"(buf), "c"(size));
64 if (status == -1) return 0;
65 return buf;
67 int chdir(const char *path)
69 int status = -1;
70 asm volatile("int $0x80" : "=b"(status): "a"(SYS_CHDIR), "b"(path));
71 return status;
73 int dup(int fd)
75 return fcntl(fd, F_DUPFD, 0);
77 int dup2(int fd, int fd2)
79 return fcntl(fd, F_DUPFD, fd2);
82 pid_t getpid(void)
84 int pid;
85 asm volatile("int $0x80" : "=b"(pid): "a"(SYS_GETPID));
86 return pid;
90 int isatty(int fildes)
92 return 1;
95 int access(const char *path, int amode)
97 return R_OK;
100 char *setlocale(int category, const char *locale)
102 return 0;
105 pid_t tcgetpgrp(int fd)
107 return -1;
109 pid_t getpgrp(void)
111 return 0;