tmake sure a write of 0 bytes does a 0-length write. - plan9port - [fork] Plan 9 from user space
(HTM) git clone git://src.adamsgaard.dk/plan9port
(DIR) Log
(DIR) Files
(DIR) Refs
(DIR) README
(DIR) LICENSE
---
(DIR) commit 493f3d0fbf548303a8f468ffffca8476607ee2cd
(DIR) parent 298f6bd657fd2c0cd6c1fc049be9e2a139e2ae05
(HTM) Author: rsc <devnull@localhost>
Date: Fri, 22 Oct 2004 17:14:17 +0000
make sure a write of 0 bytes does a 0-length write.
Diffstat:
M src/libfs/write.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
---
(DIR) diff --git a/src/libfs/write.c b/src/libfs/write.c
t@@ -43,16 +43,18 @@ _fspwrite(Fid *fid, void *buf, long n, vlong offset)
long
fspwrite(Fid *fid, void *buf, long n, vlong offset)
{
- long tot, want, got;
+ long tot, want, got, first;
uint msize;
msize = fid->fs->msize - IOHDRSZ;
tot = 0;
- while(tot < n){
+ first = 1;
+ while(tot < n || first){
want = n - tot;
if(want > msize)
want = msize;
got = _fspwrite(fid, buf, want, offset);
+ first = 0;
if(got < 0){
if(tot == 0)
return got;