diff options
| author | rsc <devnull@localhost> | 2003-12-09 06:06:07 +0000 |
|---|---|---|
| committer | rsc <devnull@localhost> | 2003-12-09 06:06:07 +0000 |
| commit | ceb04770830a7610a5a9a21aa96a4ba4cece2a5d (patch) | |
| tree | b739b6d6ccc6d14c4aa28c575f434e0c9dc26c48 /src/libfs/write.c | |
| parent | 4e6ed88aa81979cfd5fde4697fb763f57f516cc4 (diff) | |
| download | plan9port-ceb04770830a7610a5a9a21aa96a4ba4cece2a5d.tar.gz plan9port-ceb04770830a7610a5a9a21aa96a4ba4cece2a5d.zip | |
check everything in so i can move to linux and valgrind.
Diffstat (limited to 'src/libfs/write.c')
| -rw-r--r-- | src/libfs/write.c | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/libfs/write.c b/src/libfs/write.c index 96ecfa86..5652b491 100644 --- a/src/libfs/write.c +++ b/src/libfs/write.c @@ -8,39 +8,39 @@ #include "fsimpl.h" long -fspwrite(Fid *fd, void *buf, long n, vlong offset) +fspwrite(Fid *fid, void *buf, long n, vlong offset) { Fcall tx, rx; void *freep; - tx.type = Tread; + tx.type = Twrite; + tx.fid = fid->fid; if(offset == -1){ - qlock(&fd->lk); - tx.offset = fd->offset; - fd->offset += n; - qunlock(&fd->lk); + qlock(&fid->lk); + tx.offset = fid->offset; + qunlock(&fid->lk); }else tx.offset = offset; tx.count = n; tx.data = buf; - fsrpc(fd->fs, &tx, &rx, &freep); + fsrpc(fid->fs, &tx, &rx, &freep); if(rx.type == Rerror){ - if(offset == -1){ - qlock(&fd->lk); - fd->offset -= n; - qunlock(&fd->lk); - } werrstr("%s", rx.ename); free(freep); return -1; } + if(offset == -1 && rx.count){ + qlock(&fid->lk); + fid->offset += rx.count; + qunlock(&fid->lk); + } free(freep); return rx.count; } long -fswrite(Fid *fd, void *buf, long n) +fswrite(Fid *fid, void *buf, long n) { - return fspwrite(fd, buf, n, -1); + return fspwrite(fid, buf, n, -1); } |
