>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 [EMAIL PROTECTED]
with "unsubscribe freebsd-hackers" in the body of the message

Reply via email to