From 02b74edba1ab97e782f7fe0baaeecf2d447bd18d Mon Sep 17 00:00:00 2001 From: David du Colombier <0intro@gmail.com> Date: Sun, 3 Aug 2014 18:51:25 +0200 Subject: [PATCH] implement fdreadn --- README | 5 +++++ fd.c | 16 ++++++++++++++++ task.h | 1 + 3 files changed, 22 insertions(+) diff --git a/README b/README index 9c61468..4f50a3a 100644 --- a/README +++ b/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 diff --git a/fd.c b/fd.c index 4a7d51d..5b4f579 100644 --- a/fd.c +++ b/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