CS 4414/5416:
Systems Programming

Lab 6: Memory-Mapped File I/O

2026-10-02

Lab Logistics Reminder

Primary goal: Work together on something

  • Fine to have small groups (up to 4)
  • Work on the lab assignment during the hour

This week is about memory-mapped file manipulation in Rust.

Success Condition

cargo run mine.dat init    # Create database mine.dat
cargo run mine.dat add 1 3 # Add the edge (1,3) to mine.dat
cargo run mine.dat add 6 7 # Add the edge (6,7) to mine.dat
cargo run mine.dat show    # Show the contents of mine.dat

This should produce

1,3
6,7

Key Crates

There are two crates that you’ll need to understand:

  • memmap2: Uses virtual memory to map a file into memory
  • zerocopy: Utilities to reinterpret raw bytes (e.g. from a mapped file) as Rust data types, and to go the other way.

Getting the material

Repo: https://github.coecis.cornell.edu/cs4414-f26/lab-06

At the end of the hour run cargo package and submit the crate file as a group on Gradescope (I will grade based on whether the crate builds and the “hello world” test from the first slide works).