Date: Fri, 13 Dec 1996 12:19:52 -0700 (MST) From: Terry Lambert <terry@lambert.org> To: scrappy@hub.org (Marc G. Fournier) Cc: erich@lodgenet.com, hackers@freebsd.org Subject: Re: Multiple Buffer allocation of Shared Memory Message-ID: <199612131919.MAA15610@phaeton.artisoft.com> In-Reply-To: <Pine.NEB.3.95.961213002725.14115D-100000@hub.org> from "Marc G. Fournier" at Dec 13, 96 00:47:09 am
next in thread | previous in thread | raw e-mail | index | archive | help
> parent: > > open named file (O_RDONLY, O_RDWR, or it doesn't matter?) > ftruncate named file > mmap it using something similar to: > mmap(0, <size of file>, 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, <size of file>, 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.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199612131919.MAA15610>