mirror of
https://github.com/0intro/libtask
synced 2024-12-22 11:12:35 +03:00
implement fdreadn
This commit is contained in:
parent
0d454584f8
commit
02b74edba1
5
README
5
README
@ -98,6 +98,11 @@ int fdread(int, void*, int);
|
||||
Like regular read(), but puts task to sleep while waiting for
|
||||
data instead of blocking the whole program.
|
||||
|
||||
int fdreadn(int, void*, int);
|
||||
|
||||
Like fdread(), but does successive read calls until n bytes have
|
||||
been read, or a read system call returns a non-positive count.
|
||||
|
||||
int fdwrite(int, void*, int);
|
||||
|
||||
Like regular write(), but puts task to sleep while waiting to
|
||||
|
16
fd.c
16
fd.c
@ -290,6 +290,22 @@ fdread(int fd, void *buf, int n)
|
||||
return m;
|
||||
}
|
||||
|
||||
int
|
||||
fdreadn(int fd, void *buf, int n)
|
||||
{
|
||||
int m, tot;
|
||||
|
||||
for(tot=0; tot<n; tot+=m){
|
||||
m = fdread(fd, (char*)buf+tot, n-tot);
|
||||
if(m < 0)
|
||||
return m;
|
||||
if(m == 0)
|
||||
break;
|
||||
}
|
||||
|
||||
return tot;
|
||||
}
|
||||
|
||||
int
|
||||
fdwrite(int fd, void *buf, int n)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user