From owner-freebsd-hackers Thu Jun 5 17:14:39 1997 Return-Path: Received: (from root@localhost) by hub.freebsd.org (8.8.5/8.8.5) id RAA15715 for hackers-outgoing; Thu, 5 Jun 1997 17:14:39 -0700 (PDT) Received: from implode.root.com (implode.root.com [198.145.90.17]) by hub.freebsd.org (8.8.5/8.8.5) with ESMTP id RAA15710 for ; Thu, 5 Jun 1997 17:14:36 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by implode.root.com (8.8.5/8.8.5) with SMTP id RAA04933; Thu, 5 Jun 1997 17:15:45 -0700 (PDT) Message-Id: <199706060015.RAA04933@implode.root.com> X-Authentication-Warning: implode.root.com: localhost [127.0.0.1] didn't use HELO protocol To: luoqi@watermarkgroup.com (Luoqi Chen) cc: hackers@FreeBSD.ORG Subject: Re: discrepancy in mmap(2) about MAP_ANON In-reply-to: Your message of "Thu, 05 Jun 1997 12:09:52 EDT." <9706051609.AA13720@watermarkgroup.com> From: David Greenman Reply-To: dg@root.com Date: Thu, 05 Jun 1997 17:15:45 -0700 Sender: owner-hackers@FreeBSD.ORG X-Loop: FreeBSD.org Precedence: bulk > >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