From ad88539715c50f30c4e8fca27338158dc33feaaa Mon Sep 17 00:00:00 2001 From: "Charles.Forsyth" Date: Sat, 14 Jul 2007 09:52:44 +0000 Subject: 20070714-1052 --- emu/port/inferno.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'emu/port/inferno.c') diff --git a/emu/port/inferno.c b/emu/port/inferno.c index 1149d623..b568f9fa 100644 --- a/emu/port/inferno.c +++ b/emu/port/inferno.c @@ -270,6 +270,35 @@ Sys_read(void *fp) acquire(); } +void +Sys_readn(void *fp) +{ + int fd, m, n, t; + F_Sys_readn *f; + + f = fp; + n = f->n; + if(f->buf == (Array*)H || n < 0) { + *f->ret = 0; + return; + } + if(n > f->buf->len) + n = f->buf->len; + fd = fdchk(f->fd); + + release(); + for(t = 0; t < n; t += m){ + m = kread(fd, (char*)f->buf->data+t, n-t); + if(m <= 0){ + if(t == 0) + t = m; + break; + } + } + *f->ret = t; + acquire(); +} + void Sys_pread(void *fp) { -- cgit v1.2.3