summaryrefslogtreecommitdiff
path: root/mach-defpager
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@gnu.org>2001-06-05 00:59:37 +0000
committerMark Kettenis <kettenis@gnu.org>2001-06-05 00:59:37 +0000
commitf1a60268268acac56b9a245bcb9d93b0506a0e92 (patch)
tree68cae52f4e65e6c539ea087a6b1c9f9f77b2697a /mach-defpager
parent047e386605783af924c6856d6ca58cea1dd5e614 (diff)
* setup.c (page_read_file_direct): Fix logic to find the run that
contains the data to be read. Use size in bytes instead of blocks when calling device_read. (page_write_file_direct): Fix logic to find the run that contains the data to be written. Pass SIZE_WRITTEN to device_write call instead of &WROTE when writing a whole page. Correctly calculate SEGSIZE.
Diffstat (limited to 'mach-defpager')
-rw-r--r--mach-defpager/ChangeLog10
-rw-r--r--mach-defpager/setup.c29
2 files changed, 25 insertions, 14 deletions
diff --git a/mach-defpager/ChangeLog b/mach-defpager/ChangeLog
index 61bfe7b1..15412bd7 100644
--- a/mach-defpager/ChangeLog
+++ b/mach-defpager/ChangeLog
@@ -1,3 +1,13 @@
+2001-06-05 Mark Kettenis <kettenis@gnu.org>
+
+ * setup.c (page_read_file_direct): Fix logic to find the run that
+ contains the data to be read. Use size in bytes instead of blocks
+ when calling device_read.
+ (page_write_file_direct): Fix logic to find the run that contains
+ the data to be written. Pass SIZE_WRITTEN to device_write call
+ instead of &WROTE when writing a whole page. Correctly calculate
+ SEGSIZE.
+
2001-02-28 Roland McGrath <roland@frob.com>
* main.c (main): Instead of calling daemon, do the work ourselves but
diff --git a/mach-defpager/setup.c b/mach-defpager/setup.c
index 134036ae..5060dc0a 100644
--- a/mach-defpager/setup.c
+++ b/mach-defpager/setup.c
@@ -115,17 +115,17 @@ page_read_file_direct (struct file_direct *fdp,
assert (offset + (size >> fdp->bshift) <= fdp->fd_size);
/* Find the run containing the beginning of the page. */
- for (r = fdp->runs; r->length > offset; ++r)
+ for (r = fdp->runs; offset > r->length; ++r)
offset -= r->length;
if (offset + (size >> fdp->bshift) <= r->length)
/* The first run contains the whole page. */
- return device_read (fdp->device, 0,
- r->start + offset, size >> fdp->bshift,
- (char **) addr, size_read);
+ return device_read (fdp->device, 0, r->start + offset,
+ size, (char **) addr, size_read);
/* Read the first part of the run. */
- err = device_read (fdp->device, 0, r->start + offset, r->length - offset,
+ err = device_read (fdp->device, 0, r->start + offset,
+ (r->length - offset) << fdp->bshift,
(char **) addr, &nread);
if (err)
return err;
@@ -136,12 +136,13 @@ page_read_file_direct (struct file_direct *fdp,
{
readloc += nread;
offset += nread >> fdp->bshift;
- if (r->length > offset)
+ if (offset > r->length)
offset -= r++->length;
/* We always get another out-of-line page, so we have to copy
out of that page and deallocate it. */
- err = device_read (fdp->device, 0, r->start + offset, r->length - offset,
+ err = device_read (fdp->device, 0, r->start + offset,
+ (r->length - offset) << fdp->bshift,
&page, &nread);
if (err)
{
@@ -178,13 +179,13 @@ page_write_file_direct(struct file_direct *fdp,
assert (offset + (size >> fdp->bshift) <= fdp->fd_size);
/* Find the run containing the beginning of the page. */
- for (r = fdp->runs; r->length > offset; ++r)
+ for (r = fdp->runs; offset > r->length; ++r)
offset -= r->length;
if (offset + (size >> fdp->bshift) <= r->length)
/* The first run contains the whole page. */
- return device_write (fdp->device, 0,
- r->start + offset, (char *) addr, size, &wrote);
+ return device_write (fdp->device, 0, r->start + offset,
+ (char *) addr, size, size_written);
/* Write the first part of the run. */
err = device_write (fdp->device, 0,
@@ -201,14 +202,14 @@ page_write_file_direct(struct file_direct *fdp,
addr += wrote;
offset += wrote >> fdp->bshift;
- if (r->length > offset)
+ if (offset > r->length)
offset -= r++->length;
- segsize = (r->length - offset) >> fdp->bshift;
+ segsize = (r->length - offset) << fdp->bshift;
if (segsize > size)
segsize = size;
- err = device_write (fdp->device, 0,
- r->start + offset, (char *) addr, segsize, &wrote);
+ err = device_write (fdp->device, 0, r->start + offset,
+ (char *) addr, segsize, &wrote);
if (err)
{
vm_deallocate (mach_task_self (),