Skip to content

P10 write fs#7

Closed
Amber-Agarwal wants to merge 3 commits into
codenet:p4-trapsfrom
Amber-Agarwal:p10-write-fs
Closed

P10 write fs#7
Amber-Agarwal wants to merge 3 commits into
codenet:p4-trapsfrom
Amber-Agarwal:p10-write-fs

Conversation

@Amber-Agarwal

@Amber-Agarwal Amber-Agarwal commented Feb 15, 2026

Copy link
Copy Markdown

IMPORTANT:- Note that in the implementation I have committed I have taken the MKFS from the C directory only so my makefile assumes MKFS to be already present in a specified folder. This was done as I didn't have the code for MKFS in rust. Once that code is added we can change the mkfs dependency in the Makefile.

This PR implements the filesystem write path in the Rust xv6 kernel and updates the boot-time demo to exercise directory/file creation and path lookup with writes.

I have currently implemented the following

Inode and block write support

  • Added block allocation and zeroing:
    • balloc
    • bzero
  • Added inode allocation/update lifecycle:
    • ialloc
    • iupdate
    • irelease
  • Extended block mapping to allocate blocks when needed:
    • bmap (direct + single indirect)
  • Added inode data write:
    • writei
  • Added required FS constants and helpers:
    • MAXFILE, BPB
    • inode type constants (T_DIR, T_FILE, T_DEV)
    • little-endian write helpers for on-disk metadata

Directory and pathname operations

  • Implemented directory search/link:
    • dirlookup
    • dirlink
  • Implemented pathname resolution:
    • skipelem
    • namex
    • namei
    • nameiparent
  • Added name comparison behavior consistent with DIRSIZ directory entries.

Boot demo changes (welcome)

  • Replaced direct root inode access flow with pathname-based flow:
    • Look up /
    • Create /foo if missing
    • Create /foo/greet.txt if missing by linking /welcome.txt
    • Read and print /foo/greet.txt

Behavior after this PR
On first boot:

  • /foo not found. Creating!
  • /foo/greet.txt not found. Creating!
  • Reads and prints contents from /foo/greet.txt

On later boots:

  • Finds existing entries and directly reads /foo/greet.txt

Validation

  • make xv6.img fs.img succeeds
  • make qemu boots successfully
  • Output confirms correct creation/lookup/read behavior across repeated boots

@codenet

codenet commented May 1, 2026

Copy link
Copy Markdown
Owner

merged superceded branch: #20

@codenet codenet closed this May 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants