plan9port

fork of plan9port with libvec, libstr and libsdb
Log | Files | Refs | README | LICENSE

commit 493f3d0fbf548303a8f468ffffca8476607ee2cd
parent 298f6bd657fd2c0cd6c1fc049be9e2a139e2ae05
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:
Msrc/libfs/write.c | 6++++--
1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/libfs/write.c b/src/libfs/write.c @@ -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;