Skip to content

Conversation

@ryanbreen
Copy link
Owner

Summary

  • Implement FIFOs (named pipes) with mkfifo() syscall for path-based IPC
  • Add FIFO registry for managing named pipes in the filesystem namespace
  • Support blocking semantics: readers block until writer opens (and vice versa)
  • Support O_NONBLOCK with proper EAGAIN/ENXIO error handling
  • Reuse existing PipeBuffer for efficient data transfer
  • Add poll support for FIFO file descriptors

Implementation Details

  • kernel/src/ipc/fifo.rs - FIFO registry and entry management (333 lines)
  • kernel/src/syscall/fifo.rs - sys_mkfifo syscall handler
  • kernel/src/syscall/fs.rs - handle_fifo_open() for FIFO-aware open
  • FdKind::FifoRead / FdKind::FifoWrite variants for proper fd tracking
  • Comprehensive test suite covering 6 phases of FIFO behavior

Test Coverage

  • Phase 1: Basic FIFO create/open/close
  • Phase 2: EEXIST on duplicate mkfifo
  • Phase 3: ENOENT on open of non-existent FIFO
  • Phase 4: O_NONBLOCK write without reader (ENXIO)
  • Phase 5: O_NONBLOCK read from empty FIFO (EAGAIN)
  • Phase 6: Multiple writes and reads

Test plan

  • Build succeeds with zero warnings
  • FIFO test passes phases 1-5 consistently
  • Phase 6 works but may be preempted under heavy load (50+ concurrent tests)
  • No regressions in existing pipe tests

🤖 Generated with Claude Code

ryanbreen and others added 2 commits January 24, 2026 11:22
Add FIFO (named pipe) support to Breenix, enabling unrelated processes
to communicate through filesystem paths.

Key features:
- mkfifo syscall (mknod with S_IFIFO mode) creates named pipes
- FIFO registry tracks active named pipes by path
- Open semantics follow POSIX: readers block until writer opens (and vice versa)
- O_NONBLOCK support for non-blocking opens (EAGAIN/ENXIO)
- FIFOs reuse the existing PipeBuffer for data transfer
- Proper cleanup when file descriptors are closed

Implementation:
- kernel/src/ipc/fifo.rs: FIFO registry and FifoEntry management
- kernel/src/syscall/fifo.rs: sys_mkfifo syscall handler
- kernel/src/syscall/fs.rs: handle_fifo_open() for open() on FIFOs
- FdKind::FifoRead/FifoWrite variants for FIFO file descriptors
- Poll support for FIFO read/write ends
- libbreenix::fs::mkfifo() userspace wrapper

Test coverage (fifo_test.rs):
- Phase 1: Basic create/open/close/write/read
- Phase 2: EEXIST on duplicate mkfifo
- Phase 3: ENOENT on opening non-existent FIFO
- Phase 4: ENXIO on O_NONBLOCK write without reader
- Phase 5: EAGAIN on O_NONBLOCK read from empty FIFO
- Phase 6: Multiple writes and reads
- Phase 7: Unlink while FIFO is open

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Address validation review feedback:
- Phase 7: Blocking read test using fork - parent blocks on open until
  child opens writer, verifying blocking semantics work correctly
- Phase 8: EOF test - reader gets 0 when all writers close
- Phase 9: EPIPE test - write fails when all readers close
- Phase 10: Unlink while open (renumbered from Phase 7)

These tests cover the critical POSIX semantics that were previously
untested due to all tests using O_NONBLOCK.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@ryanbreen
Copy link
Owner Author

Superseded by PR #123 which includes the same FIFO implementation plus the critical blocking fix that resolves CI failures.

@ryanbreen ryanbreen closed this Jan 24, 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