CopyOnWrite, // Share the mapped object only until it is written to;
// then, before the write takes place, copy the object.
// It is undefined whether this mapping will receive
- // the copy or the original. Ignored for alloc_and_map.
-
+ // the copy or the original.
+
+ Snapshot, // The mapped object will also be made CopyOnWrite, so
+ // that any writes to the mapped page via any mapping
+ // will cause a fault. Thus, after the snapshot, the
+ // only changes that will be visible will be through
+ // the new mapping. This is ideal for things like fork()
+ // and file versioning, and is used by AddrSpace.clone().
+ //
+ // If not set, then only the new mapping will be
+ // CopyOnWrite, so if another mapping updates the page
+ // before a write occurs through this mapping (thus
+ // breaking CopyOnWrite), the change will be visible in
+ // the new mapping. This is ideal for private
+ // mappings, where all that is desired is that the new
+ // mapping cannot change the underlying object (while
+ // keeping the mapping writeable).
+ //
+ // Ignored if CopyOnWrite is not set.
+
AccessFlags access:3,
// These are the requested read/write/execute
// permissions on the mapping. A missing permission (or
// By default, the old address space continues to be backed by
// whatever Mappables were in use, and pages in the new address space
// are backed by anonymous memory when a page in either is written to.
- // If old_space_is_anon is true, though, this is reversed, which is useful
+ // If flags.Reverse is true, though, this is reversed, which is useful
// when versioning a file to make the new version the one that gets
// stored to disk.
+ //
+ // The upstream address space is also marked as copy-on
- clone(AddrSpace addrspace out, bool clone_is_real);
+ clone(AddrSpace addrspace out, CloneFlags flags);
- // Create an anonymous RAM mapping.
-
- alloc_and_map(ulong len, ulong vstart inout,
- AllocFlags aflags, MapFlags mflags);
+ bitfield CloneFlags {
+ Reverse
+ };
// Mappable must be implemented by the local kernel, and must hold
// read/write/exec permissions appropriate for the MapFlags given.