Closed StephanvanSchaik closed 1 year ago
Looks good. Did you cut a release with this included?
Looks good. Did you cut a release with this included?
I haven't released a new version of mmap-rs yet that includes this PR, but I do think that mmap-rs is getting in good shape for a 0.6 release with the current changes. So let me see if I can get around to that by the end of this week.
Thanks. That'd be awesome.
@s1341 mmap-rs 0.6 is now available.
I finally got a chance to try this and ran into a roadblock.
I need to be able to reserve a very large region, and then commit pages in that region one at a time.
I can do it with split_off
, but then I am required to manage a bunch of Reserved
and Mmap
objects....
Can you think of a better implementation?
Is it possible for you to commit pages from the beginning to the end? If so, you could maintain just one Reserved
object and one Mmap
object by calling split_off()
on the first page of Reserved
, committing it, and merging it with the Mmap
object. I think that would simplify it a lot.
Nope. In the end I just keep a HashMap
of Reserved
that are split off of the large region. (Implementing ASAN shadow memory).
I don't see a cleaner way of doing it other than managing the objects into their own respective HashMap
objects. At least not without giving up on modelling it with Rust ownership and using the type system to restrict access depending on the type.
Yeah. Ok. That's what I figured, but I thought I'd pick your brain...
This introduces
Reserved
,ReservedNone
andReservedMut
to represent reserved memory mappings that can later on be committed. Similar toMmap
objects, these can be split and the permissions of the memory mappings can be changed. In addition, these implementTryInto
such that they can be converted into their correspondingMmap
object, committing the memory mapping on Microsoft Windows.Since these represent memory mappings without being backed by physical pages,
Reserved
objects do not implementDeref
orDerefMut
such that they are inaccessible until committed.See also PR #12 and PR #13.