diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-11-18 12:53:31 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2012-11-18 12:53:31 +0100 |
commit | f188f2f0738b4888130f9f07181f4cc367afb2d1 (patch) | |
tree | 992b55922f2ef922b363fcfdb94d8c2053c512a0 /sys/src/cmd/hjfs | |
parent | 68639edbad03554a6ce7ec8ba0e54288ba6378e4 (diff) |
hjfs: eleminate seek syscalls
reduce syscalls by using pread/pwrite instead
of seek/read/write.
Diffstat (limited to 'sys/src/cmd/hjfs')
-rw-r--r-- | sys/src/cmd/hjfs/dev.c | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/sys/src/cmd/hjfs/dev.c b/sys/src/cmd/hjfs/dev.c index 45c3a9e09..4826b4bdd 100644 --- a/sys/src/cmd/hjfs/dev.c +++ b/sys/src/cmd/hjfs/dev.c @@ -30,20 +30,27 @@ devwork(void *v) b->error = Einval; goto reply; } - seek(d->fd, b->off * BLOCK, 0); b->error = nil; if(b->op & BWRITE){ memset(buf, 0, sizeof(buf)); pack(b, buf); - if(write(d->fd, buf, BLOCK) < BLOCK){ + if(pwrite(d->fd, buf, BLOCK, b->off*BLOCK) < BLOCK){ dprint("hjfs: write: %r\n"); b->error = Eio; } }else{ - if(readn(d->fd, buf, BLOCK) < 0){ - dprint("hjfs: read: %r\n"); + int n, m; + + for(n = 0; n < BLOCK; n += m){ + m = pread(d->fd, buf+n, BLOCK-n, b->off*BLOCK+n); + if(m < 0) + dprint("hjfs: read: %r\n"); + if(m <= 0) + break; + } + if(n < BLOCK) b->error = Eio; - }else + else unpack(b, buf); } reply: |