Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 26 Jun 1999 23:22:02 -0400 (EDT)
From:      Zhihui Zhang <zzhang@cs.binghamton.edu>
To:        freebsd-hackers@freebsd.org
Subject:   Implementation of mmap() in FreeBSD
Message-ID:  <Pine.GSO.3.96.990626230627.15421B-100000@sol.cs.binghamton.edu>

next in thread | raw e-mail | index | archive | help

From the source code of mmap(), it seems to me that FreeBSD can not handle
mmap() when the specified file range [offset, offset + length] does not
align with memory page boundary.  The mmap() automatically enlarges the
mapped area on BOTH ends of the given range to a page boundary.  In the
following figure, the two X areas are not specified by the user, they are
included because we do rounding on both ends.

       +---+----------+---------+-----+
       | X |          |         |  X  |
       +---+----------+---------+-----+
       ^              ^               ^
       |              |               |
     page boundary  page boundary   page boundary

Then a problem is what will happen if I read/write at the areas marked as
X?  What will happen if I write into the area marked by the right X and
that area lies beyond the end of the file?  According to the book by
W. Richard Stevens, if we write to the area marked by the right X, the
changes should not be reflected in the file (or expand the file).

All these situations seem to me are not handled by FreeBSD mmap() code. I
hope I am wrong. I also wonder why we can not add some information to the
backing object, so that we can handle these situations. If these problems
do exist, how hard it is to fix them?

Any help or hint is appreciated.

--------------------------------------------------
Zhihui Zhang.  Please visit http://www.freebsd.org
--------------------------------------------------



To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-hackers" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.GSO.3.96.990626230627.15421B-100000>