diff options
author | Roland McGrath <roland@gnu.org> | 1999-10-03 10:21:55 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 1999-10-03 10:21:55 +0000 |
commit | c3bcb575fa088392a48e5febd519f36e406eaf7a (patch) | |
tree | c6d9f37f3d01a3c7d970b9de2983015c4fd2c664 /libstore/rdwr.c | |
parent | 026470746999caa0d397d49a1d08cb4685ee39f0 (diff) |
1999-10-03 Roland McGrath <roland@baalperazim.frob.com>
* rdwr.c (store_read, store_write): Fix calculations broken in last
change, so they again properly account for starting intrarun offset.
Diffstat (limited to 'libstore/rdwr.c')
-rw-r--r-- | libstore/rdwr.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libstore/rdwr.c b/libstore/rdwr.c index c9163618..94b0fa24 100644 --- a/libstore/rdwr.c +++ b/libstore/rdwr.c @@ -112,16 +112,18 @@ store_write (struct store *store, addr = store_find_first_run (store, addr, &run, &runs_end, &base, &index); if (addr < 0) err = EIO; - else if ((len >> block_shift) <= run->length) + else if ((len >> block_shift) <= run->length - addr) /* The first run has it all... */ err = (*write)(store, base + run->start + addr, index, buf, len, amount); else /* ARGH, we've got to split up the write ... */ { - mach_msg_type_number_t try = run->length << block_shift, written; + mach_msg_type_number_t try, written; /* Write the initial bit in the first run. Errors here are returned. */ - err = (*write)(store, base + run->start + addr, index, buf, try, &written); + try = (run->length - addr) << block_shift; + err = (*write) (store, base + run->start + addr, index, buf, try, + &written); if (!err && written == try) /* Wrote the first bit successfully, now do the rest. Any errors @@ -183,7 +185,7 @@ store_read (struct store *store, assert ((amount & (block_shift - 1)) == 0); - if ((amount >> block_shift) <= run->length) + if ((amount >> block_shift) <= run->length - addr) /* The first run has it all... */ return (*read) (store, base + run->start + addr, index, amount, buf, len); else @@ -238,7 +240,7 @@ store_read (struct store *store, buf_end = whole_buf; err = seg_read (base + run->start + addr, - run->length << block_shift, &all); + (run->length - addr) << block_shift, &all); while (!err && all && amount > 0 && store_next_run (store, runs_end, &run, &base, &index)) { |