diff options
Diffstat (limited to 'kernel/syscalls.c')
| -rw-r--r-- | kernel/syscalls.c | 40 |
1 files changed, 33 insertions, 7 deletions
diff --git a/kernel/syscalls.c b/kernel/syscalls.c index e4d31b5..5939cff 100644 --- a/kernel/syscalls.c +++ b/kernel/syscalls.c @@ -114,29 +114,55 @@ int syscall_write(int file, char *buf, int len) int syscall_read(int file, char *buf, int len) { + static bool eof=false; #ifdef LOG_SYSCALLS log(FOOLOS_MODULE_NAME,FOOLOS_LOG_INFO,"read(file=%d, buf=0x%08X, len=%d)", file,buf,len); #endif - if(file!=0) panic(FOOLOS_MODULE_NAME,"unhandled syscall"); - // stdin TODO: other descroptiors! + if(file!=0) panic(FOOLOS_MODULE_NAME,"unhandled syscall"); { + if(eof) + { + eof=false; + return 0; + } char c; + int l=0; while(1) { - asm("cli"); bool ret=ringbuffer_get(&c); - asm("sti"); if(ret) { - *buf=c; - if(c=='X')return 0; - return 1; + if(c==0x08) + { + if(l>0) + { + console_del_char(); + buf--; + l--; + } + } + else{ + + *buf=c; + buf++; + l++; + if(c!=0x04)console_put_char_red(c); + if(c=='\n')return l; + if(c==0x04) + { + l--; + buf--; + eof=true; + return l; + } + } + } } |
