Subject: Naming Anonymous mmap'd Regions
To: None <tech-kern@NetBSD.ORG>
From: Curt Sampson <cjs@portal.ca>
List: tech-kern
Date: 08/16/1997 14:01:20
The manual page for mmap(2) seems to imply that one can name an
anonymous region with a file descriptor:

    The file descriptor used for creating MAP_ANON regions is
    used only for naming, and may be specified as -1 if no name
    is associated with the region.

However, if the MAP_ANON is set, we test for descriptors other than
-1, and return EINVAL.

So what's the deal here? Is it really useful to be able to name
anonymous regions? It seems to me it would save some hassle, since
people doing file I/O on the file can't screw up your region, and
if you're mapping a large region, you don't have to allocate that
much disk space on a filesystem (it may be better in some circumstances
to use swap instead). And of course it would prevent anyone from
doing a truncate("/tmp/my_mmap_file", 0) and segfaulting your
application.

cjs

Curt Sampson    cjs@portal.ca		Info at http://www.portal.ca/
Internet Portal Services, Inc.		`And malt does more than Milton can
Vancouver, BC   (604) 257-9400		 To justify God's ways to man.'