diff options
Diffstat (limited to 'interface/syscalls.c')
| -rw-r--r-- | interface/syscalls.c | 63 |
1 files changed, 35 insertions, 28 deletions
diff --git a/interface/syscalls.c b/interface/syscalls.c index 7d12002..06846bb 100644 --- a/interface/syscalls.c +++ b/interface/syscalls.c @@ -1,3 +1,5 @@ +#include "syscalls.h" + #include <stdint.h> #include <stdio.h> #include <string.h> @@ -7,8 +9,9 @@ #include <sys/stat.h> #include <sys/termios.h> -#include "fs.h" -#include "syscalls.h" +#include <errno.h> + +// BASICS // // everybody is root uid_t getuid(void) @@ -27,6 +30,20 @@ void sync(void) { } +// set working directory - we simply save this in PWD environment var +int chdir(const char *path) +{ + sprintf(buf,"PWD=%s",path); + putenv(buf); + return 0; // assume success +} + +// get working dir (see chdir) +char* getwd(char *buf) +{ + return getenv("PWD"); +} + // C NEWLIB // // first of all we have a few posix syscalls required by newlib @@ -202,7 +219,7 @@ int write(int file, char *ptr, int len) ////////////////////////////////////////////////////////////////////// -int _readdir(const char *name,fs_dirent *dirs,int max) +int _readdir(const char *name,void *dirs,int max) { return syscall(SYSCALL_READDIR,name,dirs,max); } @@ -222,23 +239,16 @@ int _lstat(const char *file, struct stat *st) return syscall(SYSCALL_LSTAT,file,st,0); } -// EXTRA STUFF - - static struct termios tty1; // only one global terminal managed here... more might/should follow - //TODO : implement this properly +// termios - int tcgetattr(int fd, struct termios *termios_p) + int tcgetattr(int fd, struct termios *termios_p) { - syscall(SYSCALL_UNIMPLEMENTED,"tcgetattr",0,0); - *termios_p=tty1; - return 0; + return syscall(SYSCALL_TCGETATTR,fd,termios_p,0); } int tcsetattr(int fd, int optional_actions, const struct termios *termios_p) { - syscall(SYSCALL_UNIMPLEMENTED,"tcsetattr",0,0); - tty1=*termios_p; - return 0; + return syscall(SYSCALL_TCSETATTR,fd,termios_p,0); } /* @@ -302,15 +312,6 @@ int _lstat(const char *file, struct stat *st) return syscall(SYSCALL_UNIMPLEMENTED,"mkdir",0,0); } - int chdir(const char *path) - { - return syscall(SYSCALL_UNIMPLEMENTED,"chdir",0,0); - } - - char* getwd(char *buf) - { - return syscall(SYSCALL_UNIMPLEMENTED,"getwd",0,0); - } char *ttyname(int fd) { @@ -319,14 +320,15 @@ int _lstat(const char *file, struct stat *st) // - struct dirent *readdir(DIR *dirp) + struct void *readdir(DIR *dirp) // returns dirent { return syscall(SYSCALL_UNIMPLEMENTED,"readdir",0,0); } DIR *opendir(const char *name) { - return syscall(SYSCALL_UNIMPLEMENTED,"opendir",0,0); + errno=EACCES; + return syscall(SYSCALL_UNIMPLEMENTED,"opendir",name,0); } int closedir(DIR *dirp) @@ -432,8 +434,7 @@ int gethostname(char *name, size_t len) ssize_t readlink(const char *pathname, char *buf, size_t bufsiz) { - syscall(SYSCALL_UNIMPLEMENTED,"readlink",0,0); - return 0; + return syscall(SYSCALL_UNIMPLEMENTED,"readlink",pathname,0); } int rmdir(const char *pathname) @@ -468,7 +469,7 @@ int execvp(const char *file, char *const argv[]) long sysconf(int name) { - syscall(SYSCALL_UNIMPLEMENTED,"sysconf",0,0); + return syscall(SYSCALL_UNIMPLEMENTED,"sysconf",name,0); return 0; } @@ -477,3 +478,9 @@ int chmod(const char *pathname, mode_t mode) syscall(SYSCALL_UNIMPLEMENTED,"chmod",0,0); return 0; } + +void _flushing() +{ + fflush(stdout); +} + |
