2 meinOS - A unix-like x86 microkernel operating system
3 Copyright (C) 2008 Janosch Gräf <janosch.graef@gmx.net>
5 This program is free software: you can redistribute it and/or modify
6 it under the terms of the GNU Lesser General Public License as published by
7 the Free Software Foundation, either version 3 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public License
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
22 #include <sys/types.h>
29 #define NULL ((void*)0)
32 #define POSIX_VERSION 200112L
33 #define POSIX2_VERSION 200112L
35 #define SEEK_SET 0 // Seek from beginning of file
36 #define SEEK_CUR 1 // Seek from current position
37 #define SEEK_END 2 // Seek from end of file
39 #define STDIN_FILENO 0
40 #define STDOUT_FILENO 1
41 #define STDERR_FILENO 2
43 #define _exit(r) _Exit(r)
44 #define getpid() syscall_call(SYSCALL_PROC_GETPID,0)
45 #define getppid() getppidbypid(getpid())
52 #define getuid() syscall_call(SYSCALL_PROC_GETUID,1,1)
53 #define geteuid() syscall_call(SYSCALL_PROC_GETUID,1,2)
54 #define getgid() syscall_call(SYSCALL_PROC_GETGID,1,1)
55 #define getegid() syscall_call(SYSCALL_PROC_GETGID,1,2)
57 #define setuid(uid) syscall_call(SYSCALL_PROC_SETUID,2,7,uid)
58 #define seteuid(uid) syscall_call(SYSCALL_PROC_SETUID,2,2,uid)
59 #define setreuid(uid) syscall_call(SYSCALL_PROC_SETUID,2,3,uid)
60 #define setgid(gid) syscall_call(SYSCALL_PROC_SETGID,2,7,gid)
61 #define setegid(gid) syscall_call(SYSCALL_PROC_SETGID,2,2,uid)
62 #define setregid(gid) syscall_call(SYSCALL_PROC_SETGID,2,3,gid)
64 #define dup(fildes) dup2(fildes,0)
65 // meinOS has no "ttys"
67 /// @todo When symlinks are (completely) implemented, this has to be rewritten
68 #define lstat(path,buf) stat(path,buf)
71 int optind
,opterr
,optopt
;
74 int chown(const char *file
,uid_t uid
,gid_t gid
);
75 int fchown(int fildes
,uid_t uid
,gid_t gid
);
76 int symlink(const char *path1
,const char *path2
);
77 ssize_t
readlink(const char *path
,char *buf
,size_t bufsize
);
78 int symlink(const char *src
,const char *dest
);
79 int link(const char *src
, const char *dest
);
80 int access(const char *path
,int amode
);
81 int chdir(const char *dir
);
82 int fchdir(int fildes
);
83 char *getcwd(char *, size_t);
84 int dup2(int fildes
,int fildes2
);
85 int close(int fildes
);
86 ssize_t
read(int fildes
,void *buf
,size_t nbyte
);
87 ssize_t
write(int fildes
,const void *buf
,size_t count
);
88 ssize_t
pread(int fildes
,void *buf
,size_t count
,off_t offset
);
89 ssize_t
pwrite(int fildes
,const void *buf
,size_t count
,off_t offset
);
90 off_t
lseek(int fildes
,off_t offset
,int whence
);
91 int unlink(const char *path
);
92 int rmdir(const char *path
);
93 int ftruncate(int fildes
,off_t length
);
94 int truncate(const char *path
,off_t length
);
95 int pipe(int fildes
[2]);
97 int gethostname(char *, size_t); ///< @todo implement uname(...);
98 void swab(const void *buf1
,void *buf2
,ssize_t size
);
99 unsigned sleep(unsigned sec
);
100 int usleep(useconds_t usec
);
102 int getopt(int argc
, char *const *argv
, const char *optstring
);
104 int execl(const char *path
, ... /*, (char *)0 */);
105 int execv(const char *path
, char *const argv
[]);
106 int execle(const char *path
, ... /*, (char *)0, char *const envp[]*/);
107 int execve(const char *path
, char *const argv
[], char *const envp
[]);
108 int execlp(const char *file
, ... /*, (char *)0 */);
109 int execvp(const char *file
, char *const argv
[]);