Copy on write shares a page between two address spaces, mapped read-only in both, and copies it only when one of them writes, in the page-fault handler. A memory-mapped file is a file whose bytes are mapped into an address space: loads read the file, and stores, in a shared mapping, change it.
fork both entries point to the same frame, read-only. The child’s store faults; the handler copies the frame, points the child’s entry at the copy, writable, and the store runs again. The parent’s entry stays read-only: its next store faults too, and the handler, finding the frame no longer shared, makes the entry writable without copying.