Skip to content

Conversation

@ryanbreen
Copy link
Owner

Summary

  • Implements virtual device filesystem (devfs) with standard POSIX device nodes
  • Adds /dev/null, /dev/zero, /dev/console, and /dev/tty support
  • Integrates with existing VFS infrastructure (FdKind, poll, fstat)

Device Behavior

Device Read Write
/dev/null Returns 0 (EOF) Discards, returns byte count
/dev/zero Returns zeros Discards, returns byte count
/dev/console EAGAIN (no input) Outputs to serial
/dev/tty EAGAIN (no input) Outputs to serial

Test plan

  • devfs_test verifies all device operations
  • All 133 boot stages pass
  • Devices accessible via standard open/read/write/close syscalls

🤖 Generated with Claude Code

Add devfs support with virtual device nodes:
- /dev/null: write discards data, read returns EOF
- /dev/zero: read returns zeros, write discards data
- /dev/console: write outputs to serial port
- /dev/tty: write outputs to serial port

Implementation:
- New kernel/src/fs/devfs/ module with DeviceType enum
- FdKind::Device variant for device file descriptors
- FdKind::DevfsDirectory variant for /dev directory listing
- sys_open routes /dev/* paths to devfs handler
- sys_open handles /dev as a listable directory
- sys_getdents64 returns virtual entries for /dev directory
- sys_read/sys_write handle device operations
- sys_fstat returns proper S_IFCHR/S_IFDIR mode and st_rdev
- sys_access handles /dev and /dev/* paths
- Poll support for device files

Interactive features:
- `ls /dev` works (directory listing)
- `devtest` shell command for interactive device testing
- Includes userspace test (devfs_test) verifying all behaviors

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ryanbreen ryanbreen merged commit fddc04f into main Jan 9, 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