summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1996-05-02 15:41:16 +0000
committerRoland McGrath <roland@gnu.org>1996-05-02 15:41:16 +0000
commit929931ed6cecd7dca8898485a9c5038c99115eda (patch)
tree68c147bffd0fbd39a92dbf438d191a0ebe6cead2
parent4f0593cc021714fbd887dfca79d4328d4cd07199 (diff)
(map): Fix fencepost error in check of current mapping window.
Request round_page (LEN) bytes in io_read to avoid many small reads.
-rw-r--r--exec/exec.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/exec/exec.c b/exec/exec.c
index 678de109..1734c5c3 100644
--- a/exec/exec.c
+++ b/exec/exec.c
@@ -428,7 +428,7 @@ map (struct execdata *e, off_t posn, size_t len)
size_t offset;
if ((f->__target & ~(f->__bufsize - 1)) == (posn & ~(f->__bufsize - 1)) &&
- f->__buffer + (posn + len - f->__target) <= f->__get_limit)
+ f->__buffer + (posn + len - f->__target) < f->__get_limit)
/* The current mapping window covers it. */
offset = posn & (f->__bufsize - 1);
else if (e->filemap == MACH_PORT_NULL)
@@ -436,7 +436,8 @@ map (struct execdata *e, off_t posn, size_t len)
/* No mapping for the file. Read the data by RPC. */
char *buffer = f->__buffer;
mach_msg_type_number_t nread = f->__bufsize;
- e->error = io_read (e->file, &buffer, &nread, posn, len);
+ /* Read as much as we can get into the buffer right now. */
+ e->error = io_read (e->file, &buffer, &nread, posn, round_page (len));
if (e->error)
{
errno = e->error;