Skip to content

feat(mmap): full MAP_* support + page_cache integration

StellaOS requested to merge feat/mmap into main

Based on latest main (cf2a0718) with page_cache already merged.

  • MapBackend::FileBacked: add shared:bool field
  • sys_mmap: parse MAP_SHARED/PRIVATE/ANONYMOUS/FIXED flags; anonymous mapping (fd=-1) uses MapBackend::Anonymous; validate prot vs fd open mode (EACCES); reject illegal SHARED+PRIVATE combos (EINVAL); check offset alignment.
  • Page fault: use file_page_load(file, pgoff) from page_cache; MAP_SHARED+Writable marks page.dirty for write-back.
  • fork_cow: MAP_SHARED areas skip COW — share physical frame with writable PTE (dirty tracked via page.dirty).
  • munmap: call file_page_sync(file) before unmapping MAP_SHARED.
  • sys_msync: full implementation via file_page_sync.
  • Added MemorySet::find_area_mut helper.

NOTE: mmap_base shares starting address with heap_bottom (ProcessControlBlockInner::new) — long-term address space collision risk.

Merge request reports