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 | |
parent | 4e6ed88aa81979cfd5fde4697fb763f57f516cc4 (diff) | |
download | plan9port-ceb04770830a7610a5a9a21aa96a4ba4cece2a5d.tar.gz plan9port-ceb04770830a7610a5a9a21aa96a4ba4cece2a5d.tar.bz2 plan9port-ceb04770830a7610a5a9a21aa96a4ba4cece2a5d.zip |
check everything in so i can move to linux and valgrind.
Diffstat (limited to 'src/libfs')
-rw-r--r-- | src/libfs/fs.c | 13 | ||||
-rw-r--r-- | src/libfs/read.c | 3 | ||||
-rw-r--r-- | src/libfs/write.c | 28 |
3 files changed, 28 insertions, 16 deletions
diff --git a/src/libfs/fs.c b/src/libfs/fs.c index 985071c1..c06e19d8 100644 --- a/src/libfs/fs.c +++ b/src/libfs/fs.c @@ -22,6 +22,10 @@ fsinit(int fd) { Fsys *fs; + fmtinstall('F', fcallfmt); + fmtinstall('D', dirfmt); + fmtinstall('M', dirmodefmt); + fs = mallocz(sizeof(Fsys), 1); if(fs == nil) return nil; @@ -141,8 +145,12 @@ fsrpc(Fsys *fs, Fcall *tx, Fcall *rx, void **freep) n = sizeS2M(tx); tpkt = malloc(n); +fprint(2, "tpkt %p\n", tpkt); + if(freep) + *freep = nil; if(tpkt == nil) return -1; + fprint(2, "<- %F\n", tx); nn = convS2M(tx, tpkt, n); if(nn != n){ free(tpkt); @@ -151,7 +159,9 @@ fsrpc(Fsys *fs, Fcall *tx, Fcall *rx, void **freep) return -1; } rpkt = muxrpc(&fs->mux, tpkt); +fprint(2, "tpkt %p\n", tpkt); free(tpkt); +fprint(2, "tpkt freed\n"); if(rpkt == nil) return -1; n = GBIT32((uchar*)rpkt); @@ -162,6 +172,7 @@ fsrpc(Fsys *fs, Fcall *tx, Fcall *rx, void **freep) fprint(2, "%r\n"); return -1; } + fprint(2, "-> %F\n", rx); if(rx->type == Rerror){ werrstr("%s", rx->ename); free(rpkt); @@ -261,7 +272,7 @@ _fsrecv(Mux *mux) fprint(2, "libfs out of memory reading 9p packet; here comes trouble\n"); return nil; } - PBIT32(buf, n); + PBIT32(pkt, n); if(readn(fs->fd, pkt+4, n-4) != n-4){ free(pkt); return nil; diff --git a/src/libfs/read.c b/src/libfs/read.c index ca6c628c..1ef2cb3a 100644 --- a/src/libfs/read.c +++ b/src/libfs/read.c @@ -14,6 +14,7 @@ fspread(Fid *fid, void *buf, long n, vlong offset) void *freep; tx.type = Tread; + tx.fid = fid->fid; if(offset == -1){ qlock(&fid->lk); tx.offset = fid->offset; @@ -32,7 +33,7 @@ fspread(Fid *fid, void *buf, long n, vlong offset) memmove(buf, rx.data, rx.count); if(offset == -1){ qlock(&fid->lk); - tx.offset += n; + fid->offset += rx.count; qunlock(&fid->lk); } } 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); } |