00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030 #include <ubixos/types.h>
00031 #include <sys/thread.h>
00032 #include <sys/gen_calls.h>
00033 #include <sys/kern_descrip.h>
00034 #include <ubixos/sched.h>
00035 #include <lib/kprintf.h>
00036 #include <lib/kmalloc.h>
00037 #include <string.h>
00038 #include <assert.h>
00039
00040
00041 int getpid(struct thread *td, struct getpid_args *uap) {
00042 #ifdef DEBUG
00043 kprintf("[%s:%i]",__FILE__,__LINE__);
00044 #endif
00045 td->td_retval[0] = _current->id;
00046 return (0);
00047 }
00048
00049
00050 int getuid(struct thread *td, struct getuid_args *uap) {
00051 #ifdef DEBUG
00052 kprintf("[%s:%i]",__FILE__,__LINE__);
00053 #endif
00054 td->td_retval[0] = _current->uid;
00055 return (0);
00056 }
00057
00058
00059 int getgid(struct thread *td, struct getgid_args *uap) {
00060 #ifdef DEBUG
00061 kprintf("[%s:%i]",__FILE__,__LINE__);
00062 #endif
00063 td->td_retval[0] = _current->gid;
00064 return (0);
00065 }
00066
00067 int sys_write(struct thread *td, struct write_args *uap) {
00068 char *buffer = 0x0;
00069 char *in = 0x0;
00070
00071 #ifdef DEBUG
00072 kprintf("[%s:%i]",__FILE__,__LINE__);
00073 #endif
00074 kprintf("sw[%i]",uap->fd);
00075
00076 if (uap->fd == 2) {
00077 kprintf("stderr: %s",uap->buf);
00078 }
00079
00080 if (uap->fd == 1) {
00081 in = (char *)uap->buf;
00082 buffer = kmalloc(1024);
00083 memcpy(buffer,uap->buf,uap->nbyte);
00084 kprintf("%s",buffer);
00085 kfree(buffer);
00086 td->td_retval[0] = uap->nbyte;
00087 }
00088 else {
00089 kprintf("[%i]",uap->nbyte);
00090 buffer = kmalloc(uap->nbyte);
00091 memcpy(buffer,uap->buf,uap->nbyte);
00092
00093 kfree(buffer);
00094 kprintf("(%i) %s",uap->fd,uap->buf);
00095 td->td_retval[0] = uap->nbyte;
00096 }
00097 return(0x0);
00098 }
00099
00100 int issetugid(register struct thread *td, struct issetugid_args *uap) {
00101 #ifdef DEBUG
00102 kprintf("[%s:%i]",__FILE__,__LINE__);
00103 #endif
00104 td->td_retval[0] = 0;
00105 return (0);
00106 }
00107
00108 int readlink(struct thread *td,struct readlink_args *uap) {
00109 #ifdef DEBUG
00110 kprintf("[%s:%i]",__FILE__,__LINE__);
00111 #endif
00112 kprintf("readlink: [%s:%i]\n",uap->path,uap->count);
00113 td->td_retval[0] = -1;
00114 td->td_retval[1] = 0x0;
00115 return(0x0);
00116 }
00117
00118 int gettimeofday_new(struct thread *td, struct gettimeofday_args *uap) {
00119 #ifdef DEBUG
00120 kprintf("[%s:%i]",__FILE__,__LINE__);
00121 #endif
00122 return(0x0);
00123 }
00124
00125 int read(struct thread *td,struct read_args *uap) {
00126 int error = 0x0;
00127 size_t count = 0x0;
00128 struct file *fd = 0x0;
00129
00130 #ifdef DEBUG
00131 kprintf("[%s:%i]",__FILE__,__LINE__);
00132 #endif
00133
00134 error = getfd(td,&fd,uap->fd);
00135
00136 if (error)
00137 return(error);
00138
00139 count = fread(uap->buf,uap->nbyte,0x1,fd->fd);
00140 kprintf("count: %i\n",count);
00141 td->td_retval[0] = count;
00142
00143 return(error);
00144 }
00145
00149 int setitimer(struct thread *td, struct setitimer_args *uap) {
00150 int error = 0x0;
00151
00152 return(error);
00153 }
00154
00155
00156
00157