Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 05 Jun 1997 17:15:45 -0700
From:      David Greenman <dg@root.com>
To:        luoqi@watermarkgroup.com (Luoqi Chen)
Cc:        hackers@FreeBSD.ORG
Subject:   Re: discrepancy in mmap(2) about MAP_ANON 
Message-ID:  <199706060015.RAA04933@implode.root.com>
In-Reply-To: Your message of "Thu, 05 Jun 1997 12:09:52 EDT." <9706051609.AA13720@watermarkgroup.com> 

next in thread | previous in thread | raw e-mail | index | archive | help
>
>The mmap(2) man page:
>
>     MAP_ANON    Map anonymous memory not associated with any specific file.
>                 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.
>
>So a file descriptor other than -1 can be used with MAP_ANON, and along
>with offset it names the mapped region (so it is possible to map the same
>region at another address).
>
>But in fact mmap() returns EINVAL. Here's the code in vm/vm_mmap.c,
>
>        if (((flags & MAP_FIXED) && (addr & PAGE_MASK)) ||
>            (ssize_t) uap->len < 0 || ((flags & MAP_ANON) && uap->fd != -1))
>                return (EINVAL);

   The man page is wrong. We don't support external mapping of "named"
anonymous regions. In fact, the code that supports named anonymous regions
is scheduled to be removed. It's only use over the history of FreeBSD was
as a kernel-internal method of keeping track of SYSV shared regions. We've
recently rewritten that code to do things differently.

-DG

David Greenman
Core-team/Principal Architect, The FreeBSD Project



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199706060015.RAA04933>