• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Using mmap to extend an existing mapping?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Using mmap to extend an existing mapping?


  • Subject: Using mmap to extend an existing mapping?
  • From: Jens Alfke <email@hidden>
  • Date: Wed, 7 Oct 2009 10:32:11 -0700

I'm calling mmap to create a new mapping of a file. Later on I append data to the file (just using regular write calls) and then I want to map in the new data. If possible I want to grow the existing mapping in place, to avoid invalidating all the existing pointers.

Based on the mmap(2) man page, it sounded as though I could do this by passing in the base address of the old mapping and the MAP_FIXED flag; and it would replace the mapping with a larger one if possible, or return MAP_FAILED if there wasn't room.

::mmap(_start, newLength, PROT_READ, MAP_SHARED | MAP_FIXED, _fd, _position);

Instead, what I see happening (by running vmmap(1) before and after the call) is that the mmap call blows away any other following VM regions to make room for my request. Since these regions are often things like stacks, object code or malloc heaps, this is immediately fatal. :-(

Is there any way to get the behavior I want, where mmap will extend the mapping but will fail rather than deleting any other mappings?

—Jens

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Using mmap to extend an existing mapping?
      • From: Terry Lambert <email@hidden>
  • Prev by Date: Re: How to work on case-sensitive projects?
  • Next by Date: Re: How to work on case-sensitive projects?
  • Previous by thread: Snow Leopard, filter scheme prevents shutdown
  • Next by thread: Re: Using mmap to extend an existing mapping?
  • Index(es):
    • Date
    • Thread