Skip to content

Conversation

@ryanbreen
Copy link
Owner

Summary

This PR completes the ext2 filesystem implementation for Breenix:

  • mkdir/rmdir: Create and remove directories with proper . and .. entries
  • link: Create hard links with link count management
  • symlink/readlink: Create and read symbolic links (optimized fast symlinks for targets ≤60 bytes)
  • Double/triple indirect blocks: Support for files up to ~4TB
  • Block deallocation: Proper cleanup when files are unlinked

New Syscalls

Syscall Number Description
link 86 Create hard link
symlink 88 Create symbolic link
readlink 89 Read symbolic link target

Files Changed (12 files, +1629 lines)

  • kernel/src/fs/ext2/ - Core filesystem operations
  • kernel/src/syscall/ - Syscall handlers and dispatch
  • libs/libbreenix/ - Userspace syscall wrappers
  • userspace/tests/ - Updated large file test

Test plan

  • Build completes with zero warnings
  • Boot stages test passes (96/98 stages, failures unrelated to fs)
  • fs_write_test passes
  • fs_rename_test passes
  • fs_large_file_test passes
  • All existing filesystem tests pass

🤖 Generated with Claude Code

ryanbreen and others added 2 commits January 4, 2026 11:06
…ile support

This commit completes the ext2 filesystem implementation with:

Directory Operations:
- mkdir: Create new directories with proper . and .. entries
- rmdir: Remove empty directories with ENOTEMPTY validation

Link Operations:
- link: Create hard links with proper link count management
- symlink: Create symbolic links (fast symlinks for targets ≤60 bytes)
- readlink: Read symbolic link targets

Large File Support:
- Double indirect blocks (files up to ~64MB with 1KB blocks)
- Triple indirect blocks (files up to ~4TB with 4KB blocks)
- Extended set_block_num() to handle all indirect levels

Block Management:
- Proper block deallocation on unlink
- Recursive traversal of indirect blocks for cleanup
- increment_free_blocks() and increment_free_inodes() for superblock updates

New syscall numbers:
- Link (86), Symlink (88), Readlink (89)

New errno constants:
- EPERM (1), EBUSY (16), ENOTEMPTY (39)

All filesystem tests pass (96/98 boot stages, failures unrelated to fs).

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
- Add fs_directory_test.rs with 9 tests for mkdir/rmdir:
  - Create/verify directory, permission verification via fstat
  - EEXIST, ENOENT (missing parent), ENOTEMPTY error handling

- Add fs_link_test.rs with 11 tests for link/symlink/readlink:
  - Hard link creation, survives original deletion
  - Symlink creation, dangling symlinks, long targets (>60 bytes)
  - ENOENT, EEXIST, EPERM, EINVAL error handling

- Fix VirtIO block driver DMA buffer exhaustion:
  - Pre-allocate 3 DMA buffers during device init
  - Reuse buffers for all I/O operations
  - Prevents frame allocator exhaustion under heavy I/O

- Increase kernel heap from 16MB to 32MB:
  - Bump allocator only reclaims when ALL allocations freed
  - 43+ test processes accumulate memory across test suite

- Fix fs_large_file_test.rs:
  - Update stale seek positions to valid values within 512KB
  - Document triple indirect blocks limitation (requires >64MB file)

- Fix fs_rename_test.rs:
  - Strictly require EISDIR errno (was accepting any error)

- Convert ext2 Vec allocations to stack buffers:
  - free_indirect_block, free_double_indirect_block
  - create_directory, write_directory_data, read_symlink_target

Boot stages: 100/100 passing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@ryanbreen ryanbreen merged commit 4fd0413 into main Jan 5, 2026
1 check passed
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