Re: mmap(MAP_SHARED | MAP_ANON) broke!

Eric W. Biederman (ebiederm@cse.unl.edu)
11 Jan 1997 06:04:05 -0600


>>>>> "Sujal" == Sujal Patel <smpatel@prognet.com> writes:

Sujal> On Fri, 10 Jan 1997, Mark Hemment wrote:
>> I guess you need this so that the anon mapped pages are not marked
>> COW upon fork().

Sujal> Correct.

>> There might be another problem, or two, but if you have enough
>> memory just try changing do_mmap() and see what happens.

There is also another solution (That's a real hack).
x = mmap(..., MAP_ANON |MAP_PRIVATE, ...);
fd = open("/proc/self/mem");
y = mmap(...., MAP_SHARED, ..., fd, x);
munmap(x);

There are some problems with this multiple mappings at different
adresses may have some problems, and it isn't a supported linux feature.
But for the moment it seems to work alright.

This might also be useful. I wish someone could trace through the
kernel and get whatever about the above sequence that works into the
regular mmap command. Oh, well.

Eric