From owner-freebsd-hackers Sat Jun 26 20:34: 0 1999 Delivered-To: freebsd-hackers@freebsd.org Received: from sol (cs1-gw.cs.binghamton.edu [128.226.171.72]) by hub.freebsd.org (Postfix) with SMTP id D762C14CF0 for ; Sat, 26 Jun 1999 20:33:58 -0700 (PDT) (envelope-from zzhang@cs.binghamton.edu) Received: from localhost (zzhang@localhost) by sol (SMI-8.6/8.6.9) with SMTP id XAA15452 for ; Sat, 26 Jun 1999 23:22:03 -0400 Date: Sat, 26 Jun 1999 23:22:02 -0400 (EDT) From: Zhihui Zhang To: freebsd-hackers@freebsd.org Subject: Implementation of mmap() in FreeBSD Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG 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