Skip to content

p11-file-layer: Integration fixes for constants and eliminate warnings#21

Open
Yash-Rawat-IIT-D wants to merge 61 commits intocodenet:p4-trapsfrom
Yash-Rawat-IIT-D:p11-file-layer
Open

p11-file-layer: Integration fixes for constants and eliminate warnings#21
Yash-Rawat-IIT-D wants to merge 61 commits intocodenet:p4-trapsfrom
Yash-Rawat-IIT-D:p11-file-layer

Conversation

@Yash-Rawat-IIT-D
Copy link
Copy Markdown

Overview


Integrated p11-file-layer file descriptor and file operations functionality from PR #13. Applied integration fixes for constants organization, module integration, and Rust 2024 compatibility. Built on p10-write-fs (PR #20 submitted).

Credit: Original p11-file-layer implementation by Anoop Singh (greninja1947, PR #13: #13)
This PR: Integration fixes only (constants imports, static mut warnings)


Changes Made (Integration Work)

1. Constants Organization

Files: src/file.rs, src/fs.rs

  • Imported constants from constants.rs: T_DIR, T_FILE, DIRSIZ, DIRENT_SIZE
  • Imported parameters from param.rs: MAXOPBLOCKS, NFILE
  • Ensures single source of truth, matches C header pattern

2. Rust Compatibility

File: src/fs.rs

  • Fixed static mut references using raw const pointer pattern
  • Changed &SB&*(&raw const SB) in multiple functions
  • Applied to: readsb(), bfree(), ialloc(), iupdate(), bmap()
  • Eliminates static_mut_refs warnings and undefined behavior

Expected Behavior

On boot:

  • Creates /foo/hello.txt with content "hello"
  • Reads and prints file contents
  • Deletes /foo/hello.txt
  • Verifies /foo is empty
  • Reads and prints /welcome.txt contents (ASCII Banner)

Testing

Testing Environment: WSL (Windows Subsystem for Linux) with nightly compiler (no_std)

[PASS] Build: make kernel completes with 0 warnings, 0 errors
[PASS] Build: make xv6.img generates filesystem image correctly
[PASS] Runtime: make qemu shows expected behavior:
       - File create: /foo/hello.txt created successfully
       - File write: Content written correctly
       - File read: Content matches written data
       - File unlink: File deleted, directory emptied
       - Welcome text: /welcome.txt read and displayed
       - Filesystem operations: All file I/O operations working correctly

Files Modified

  • src/file.rs - Constants imported from constants.rs, param.rs
  • src/fs.rs - Static mut warnings fixed with raw const pointers
  • src/constants.rs - Removed duplicate KSTACKSIZE and NCPU constants (already in param.rs)
  • src/proc.rs - Updated imports for NCPU from constants.rs

Constraints Met

  • Semantic equivalence with C implementation
  • Zero compilation warnings/errors
  • Proper constants organization with single source of truth

ahilaan and others added 30 commits February 14, 2026 07:52
- Added src/mkfs.rs: pure Rust mkfs tool (based on sudoheckbeluga's
  work in PR codenet#5), adapted with FSSIZE=1000 and LOGSIZE=0 to match
  the C repo's p9-name-layer branch. No more ../col331/ dependency.
- Updated Makefile: mkfs now compiled with rustc from src/mkfs.rs
- Added name layer functions in src/fs.rs: irelse, namecmp,
  dirlookup, skipelem, namex, namei, nameiparent
- Updated welcome() in src/lib.rs to use namei("/welcome.txt")
- Added src/mkfs.rs: pure Rust mkfs tool (based on sudoheckbeluga's
  work in PR codenet#5), adapted with FSSIZE=1000 and LOGSIZE=0 to match
  the C repo's p9-name-layer branch. No more ../col331/ dependency.
- Updated Makefile: mkfs now compiled with rustc from src/mkfs.rs
- Added name layer functions in src/fs.rs: irelse, namecmp,
  dirlookup, skipelem, namex, namei, nameiparent
- Updated welcome() in src/lib.rs to use namei("/welcome.txt")
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.

7 participants