Skip to content

p8-read-fs: Filesystem Reading Integration with Constants Deduplication#18

Closed
Yash-Rawat-IIT-D wants to merge 60 commits into
codenet:p4-trapsfrom
Yash-Rawat-IIT-D:p8-read-fs
Closed

p8-read-fs: Filesystem Reading Integration with Constants Deduplication#18
Yash-Rawat-IIT-D wants to merge 60 commits into
codenet:p4-trapsfrom
Yash-Rawat-IIT-D:p8-read-fs

Conversation

@Yash-Rawat-IIT-D

Copy link
Copy Markdown

Overview:
Integrated p8-read-fs functionality from PR #6 (Amber-Agarwal/rem-amber) on top of unmerged p7-mkfs changes from PR #17. Applied compatibility fixes for constants deduplication and Rust 2024 edition.

Credit: Original p8-read-fs implementation by Amber-Agarwal (PR #6)

Changes Made:

  1. Filesystem Integration (src/fs.rs)

    • Added inode cache with ICACHE static (50 in-memory inodes)
    • Implemented core functions: iinit(), iget(), iread(), stati(), readi()
    • Added bmap() for block mapping (direct + indirect blocks)
    • Added parse_dirent() helper for directory entry parsing
    • Proper buffer release in bmap() (fixes C version leak)
  2. Constants Deduplication

    • Removed duplicate definitions: ROOTINO, NDIRECT, NINDIRECT, DIRSIZ, DINODE_SIZE, IPB
    • Imported from constants.rs (single source of truth)
    • Fixed type compatibility: IPB usage with explicit casts
  3. Rust Compatibility

    • Replaced mutable static references with raw pointers
    • Used &raw mut and &raw const patterns in iinit() and iread()
    • Eliminates undefined behavior from static aliasing

Constraints Met:

  • Semantic equivalence with C implementation
  • Zero compilation warnings
  • Proper error handling and bounds checking

Validation:

  • Platform: WSL (Windows Subsystem for Linux)
  • Toolchain: Rust nightly with build-std
  • Build: make clean && make completes with 0 warnings, 0 errors
  • Runtime: make qemu displays:
    • Superblock fields (size, nblocks, ninodes, logstart, inodestart, bmapstart)
    • Root directory entries (., .., welcome.txt)
    • welcome.txt stats (device, inode number, type, links, size)
    • welcome.txt contents (ASCII art banner)

@codenet codenet mentioned this pull request May 1, 2026
@codenet

codenet commented May 1, 2026

Copy link
Copy Markdown
Owner

I have manually merged this branch. I dislike the significant copy-pasting of code that has happened in mkfs.rs. Can you kindly remove it? Maybe create some common fs_h.rs or something? We can discuss here: https://discord.com/channels/1482638649144119376/1499695428898258977

@codenet

codenet commented May 1, 2026

Copy link
Copy Markdown
Owner

fs_h was merged manually. closing this too.

@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.

6 participants