summaryrefslogtreecommitdiff
path: root/kernel/syscalls.c
diff options
context:
space:
mode:
authorMichal Idziorek <m.i@gmx.at>2015-05-24 01:51:03 +0200
committerMichal Idziorek <m.i@gmx.at>2015-05-24 01:51:03 +0200
commitf5d8d7bee20742a7a101665ebca630ff8e05d77b (patch)
tree29e8e1106c4e587a9fb860836669e66725d68fc1 /kernel/syscalls.c
parent98eb242e282650e9c6645dd2e5290e144b105bb4 (diff)
impronving io
Diffstat (limited to 'kernel/syscalls.c')
-rw-r--r--kernel/syscalls.c60
1 files changed, 13 insertions, 47 deletions
diff --git a/kernel/syscalls.c b/kernel/syscalls.c
index c025b06..f5169e7 100644
--- a/kernel/syscalls.c
+++ b/kernel/syscalls.c
@@ -52,61 +52,27 @@ 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
// stdin TODO: other descroptiors!
if(file!=0) panic(FOOLOS_MODULE_NAME,"unhandled syscall: read (only stdin)");
- {
- if(eof)
- {
- eof=false;
- return 0;
- }
- char c;
- int l=0;
-
- while(1)
- {
- while(!fifo_has(&get_fool()->std_in));
- c=fifo_get(&get_fool()->std_in);
- bool ret=true;
-
- if(ret)
- {
- if(c==0x08)
- {
- if(l>0)
- {
- //console_del_char();
- buf--;
- l--;
- }
- }
- else{
-
- *buf=c;
- buf++;
- l++;
- //if(c!=0x04)console_put_char_white(c);
- if(c=='\n')return l;
- if(c==0x04)
- {
- l--;
- buf--;
- eof=true;
- return l;
- }
- }
-
- }
-
- }
+ char c;
+ int l=0;
+
+ while(1)
+ {
+ while(!fifo_has(&get_fool()->std_in));
+ c=fifo_get(&get_fool()->std_in);
+ *buf=c;
+ buf++;
+ l++;
+ if(l==len)return l;
+ if(c=='\n')return l;
}
+
}