From: Alan Cox Date: Sat, 16 May 2015 11:01:04 +0000 (+0100) Subject: read/write: A zero byte read or write is a no-op not an error X-Git-Url: https://git.ndcode.org/public/gitweb.cgi?a=commitdiff_plain;h=f70462b6a21c34790d4c874dcc61356c2b87b4f5;p=FUZIX.git read/write: A zero byte read or write is a no-op not an error --- diff --git a/Kernel/syscall_fs.c b/Kernel/syscall_fs.c index 78799a92..24a6265c 100644 --- a/Kernel/syscall_fs.c +++ b/Kernel/syscall_fs.c @@ -426,6 +426,9 @@ arg_t _read(void) inoptr ino; uint8_t flag; + if (!nbytes) + return 0; + if (!valaddr(buf, nbytes)) return -1; /* Set up u_base, u_offset, ino; check permissions, file num. */ @@ -486,6 +489,9 @@ arg_t _write(void) inoptr ino; uint8_t flag; + if (!nbytes) + return 0; + if (!valaddr(buf, nbytes)) return -1; /* Set up u_base, u_offset, ino; check permissions, file num. */