diff options
author | Roland McGrath <roland@gnu.org> | 2001-08-15 06:10:39 +0000 |
---|---|---|
committer | Roland McGrath <roland@gnu.org> | 2001-08-15 06:10:39 +0000 |
commit | 5a2dc36112ef2a40bdd2a6187d998c3db4ad8f95 (patch) | |
tree | 79626cedecfd0347f024a9fc4471eaa47eb94acc /libstore/copy.c | |
parent | d77023eb04c94c402e75bb328103311a4b71c7cc (diff) |
2001-08-12 Neal H Walfield <neal@cs.uml.edu>
* copy.c (copy_read): The protocol dictates that *LEN is in
bytes, not pages.
(copy_write): Be sure that the buffer passed to vm_read is
page-aligned. When determining how much to copy, use LEN, not the
uninitialized *AMOUNT.
(copy_clone): Use memcpy, not bcopy.
* derive.c: Include <sys/types.h> and <mach.h>.
(_store_derive): Initialize STORE->wrap_src.
Diffstat (limited to 'libstore/copy.c')
-rw-r--r-- | libstore/copy.c | 16 |
1 files changed, 9 insertions, 7 deletions
diff --git a/libstore/copy.c b/libstore/copy.c index b870f4fc..c82c0ed6 100644 --- a/libstore/copy.c +++ b/libstore/copy.c @@ -30,8 +30,8 @@ #include "store.h" static error_t -copy_read (struct store *store, - store_offset_t addr, size_t index, size_t amount, void **buf, size_t *len) +copy_read (struct store *store, store_offset_t addr, size_t index, + size_t amount, void **buf, size_t *len) { char *data = store->hook + (addr * store->block_size); @@ -39,7 +39,9 @@ copy_read (struct store *store, { /* When reading whole pages, we can avoid any real copying. */ error_t err = vm_read (mach_task_self (), - (vm_address_t) data, amount, (pointer_t *) buf, len); + (vm_address_t) data, amount, + (pointer_t *) buf, len); + *len *= vm_page_size; return err; } @@ -63,16 +65,16 @@ copy_write (struct store *store, { char *data = store->hook + (addr * store->block_size); - if (page_aligned (data) && page_aligned (len)) + if (page_aligned (data) && page_aligned (len) && page_aligned (buf)) { - /* When reading whole pages, we can avoid any real copying. */ + /* When writing whole pages, we can avoid any real copying. */ error_t err = vm_write (mach_task_self (), (vm_address_t) data, (vm_address_t) buf, len); *amount = len; return err; } - memcpy (data, buf, *amount); + memcpy (data, buf, len); *amount = len; return 0; } @@ -152,7 +154,7 @@ copy_clone (const struct store *from, struct store *to) if (buf != (void *) -1) { to->hook = buf; - bcopy (from->hook, to->hook, from->size); + memcpy (to->hook, from->hook, from->size); return 0; } return errno; |