diff options
| author | rsc <devnull@localhost> | 2004-02-29 22:10:26 +0000 |
|---|---|---|
| committer | rsc <devnull@localhost> | 2004-02-29 22:10:26 +0000 |
| commit | 5a8e63b2f016735364d17866d5e2bcb35d20c78b (patch) | |
| tree | d5d0ce11e087efaf81c77311bac9d30aed41783d /src/libfs/write.c | |
| parent | d51419bf4397cf13d0c50bf84c125477c6bed307 (diff) | |
| download | plan9port-5a8e63b2f016735364d17866d5e2bcb35d20c78b.tar.gz plan9port-5a8e63b2f016735364d17866d5e2bcb35d20c78b.zip | |
Fighting the good fight.
Move libfmt, libutf into subdirectories of lib9.
Add poll-based socket i/o to libthread, so that we can
avoid using multiple procs when possible, thus removing
dependence on crappy pthreads implementations.
Convert samterm, acme to the single-proc libthread.
Bring libcomplete, acme up-to-date w.r.t. Plan 9 distribution.
Diffstat (limited to 'src/libfs/write.c')
| -rw-r--r-- | src/libfs/write.c | 29 |
1 files changed, 27 insertions, 2 deletions
diff --git a/src/libfs/write.c b/src/libfs/write.c index 5652b491..bae2083e 100644 --- a/src/libfs/write.c +++ b/src/libfs/write.c @@ -7,8 +7,8 @@ #include <fs.h> #include "fsimpl.h" -long -fspwrite(Fid *fid, void *buf, long n, vlong offset) +static long +_fspwrite(Fid *fid, void *buf, long n, vlong offset) { Fcall tx, rx; void *freep; @@ -40,6 +40,31 @@ fspwrite(Fid *fid, void *buf, long n, vlong offset) } long +fspwrite(Fid *fid, void *buf, long n, vlong offset) +{ + long tot, want, got; + uint msize; + + msize = fid->fs->msize - IOHDRSZ; + tot = 0; + while(tot < n){ + want = n - tot; + if(want > msize) + want = msize; + got = _fspwrite(fid, buf, want, offset); + if(got < 0){ + if(tot == 0) + return got; + break; + } + tot += got; + if(offset != -1) + offset += got; + } + return tot; +} + +long fswrite(Fid *fid, void *buf, long n) { return fspwrite(fid, buf, n, -1); |
