From owner-freebsd-hackers Fri Dec 13 11:43:00 1996 Return-Path: Received: (from root@localhost) by freefall.freebsd.org (8.8.4/8.8.4) id LAA08650 for hackers-outgoing; Fri, 13 Dec 1996 11:43:00 -0800 (PST) Received: from phaeton.artisoft.com (phaeton.Artisoft.COM [198.17.250.211]) by freefall.freebsd.org (8.8.4/8.8.4) with SMTP id LAA08645 for ; Fri, 13 Dec 1996 11:42:52 -0800 (PST) Received: (from terry@localhost) by phaeton.artisoft.com (8.6.11/8.6.9) id MAA15610; Fri, 13 Dec 1996 12:19:53 -0700 From: Terry Lambert Message-Id: <199612131919.MAA15610@phaeton.artisoft.com> Subject: Re: Multiple Buffer allocation of Shared Memory To: scrappy@hub.org (Marc G. Fournier) Date: Fri, 13 Dec 1996 12:19:52 -0700 (MST) Cc: erich@lodgenet.com, hackers@freebsd.org In-Reply-To: from "Marc G. Fournier" at Dec 13, 96 00:47:09 am X-Mailer: ELM [version 2.4 PL24] MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk > parent: > > open named file (O_RDONLY, O_RDWR, or it doesn't matter?) > ftruncate named file > mmap it using something similar to: > mmap(0, , PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0); > close named file > > child: > > open named file (again, does the mode matter?) > mmap it using something similar to: > mmap(0, , PROT_READ, MAP_SHARED, fd, 0); > close named file I believe the mode does not matter. Specifically, the mode is on the fd, not on the vp. All fd's point to the same vp. One posible change in the future, however, is honoring the read/write restrictions on the fd when the fd is mmap'ed. This may be done so that fd's inherited from suid/sgid modes and opened read-only *remain* read-only independent of what you specify to mmap. I'm not sure if fd's inherited this way can currently be mapped or not... it's an interesting special case. Either way, I'd suggest opening O_RDWR if you plan to later map the file PROT_READ|PROT_WRITE. > Is that the gist of it? Then I can "read/write" the mmap'd area > just like I would a similarly malloc()'d area, correct? Yes. Terry Lambert terry@lambert.org --- Any opinions in this posting are my own and not those of my present or previous employers.