summaryrefslogtreecommitdiff
path: root/libstore
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>2001-08-15 06:10:39 +0000
committerRoland McGrath <roland@gnu.org>2001-08-15 06:10:39 +0000
commit5a2dc36112ef2a40bdd2a6187d998c3db4ad8f95 (patch)
tree79626cedecfd0347f024a9fc4471eaa47eb94acc /libstore
parentd77023eb04c94c402e75bb328103311a4b71c7cc (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')
-rw-r--r--libstore/copy.c16
-rw-r--r--libstore/derive.c7
2 files changed, 14 insertions, 9 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;
diff --git a/libstore/derive.c b/libstore/derive.c
index 41bcbaca..a76fbe1c 100644
--- a/libstore/derive.c
+++ b/libstore/derive.c
@@ -1,7 +1,7 @@
/* Calculation of various derived store fields
- Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
- Written by Miles Bader <miles@gnu.ai.mit.edu>
+ Copyright (C) 1995-97,2001 Free Software Foundation, Inc.
+ Written by Miles Bader <miles@gnu.org>
This file is part of the GNU Hurd.
The GNU Hurd is free software; you can redistribute it and/or
@@ -19,6 +19,8 @@
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111, USA. */
#include <assert.h>
+#include <sys/types.h>
+#include <mach.h>
#include "store.h"
@@ -34,6 +36,7 @@ _store_derive (struct store *store)
/* BLOCK & SIZE */
store->blocks = 0;
+ store->wrap_src = 0;
for (i = 0; i < num_runs; i++)
{