Skip to content

fs/devices — PTY subsystem, separate stdio nodes, nonblocking stdin#747

Closed
wdcui wants to merge 1 commit intowdcui/stacked/pr6-mm-address-spacefrom
wdcui/stacked/pr7-devices
Closed

fs/devices — PTY subsystem, separate stdio nodes, nonblocking stdin#747
wdcui wants to merge 1 commit intowdcui/stacked/pr6-mm-address-spacefrom
wdcui/stacked/pr7-devices

Conversation

@wdcui
Copy link
Copy Markdown
Member

@wdcui wdcui commented Apr 4, 2026

Summary

Full device filesystem overhaul adding pseudo-terminal (PTY) support and improving existing device handling.

Stacked PR 7 of N — targets wdcui/stacked/pr6-mm-address-space (PR #746).

Key changes

  • PTY subsystem: PtyManager, PtyPair shared state with master↔slave ring buffers, line discipline (ICRNL, ECHO, ONLCR), reference-counted open FDs with HUP notifications
  • Separate stdio NodeInfo: stdin/stdout/stderr now have distinct inode numbers (9/10/11) instead of sharing one
  • /dev/tty: Controlling terminal device that reads from stdin, writes to stdout
  • Nonblocking stdin: Reads respect O_NONBLOCK via read_from_stdin_nonblocking
  • Pollable wrappers: StdinPollable, PtyMasterPollable, PtySlavePollable for epoll/poll/select
  • DeviceStatusFlags: Per-entry status flag tracking (O_NONBLOCK etc.)
  • Manual FdEnabledSubsystemEntry: Custom on_dup/on_close for PTY refcount management across dup/fork
  • *_at stubs: All fd-relative methods return NotADirectory (devices aren't directories)
  • Directory stat: /dev and /dev/pts paths return directory-style FileStatus
  • Error handling: Proper error returns in open() and read() instead of unimplemented!()

Design decisions

  • PTY-specific methods (get_pty_termios, set_pty_termios, get_pty_foreground_pgrp, set_pty_foreground_pgrp) are inherent methods on devices::FileSystem, not on the FileSystem trait — they're too device-specific for the generic trait interface
  • PTY trait-level interface (for layered.rs delegation) is deferred to PR 8 where the first generic caller is introduced

Stats

1 file changed, 872 insertions(+), 86 deletions(-)

@wdcui wdcui force-pushed the wdcui/stacked/pr6-mm-address-space branch from 4722328 to 2a84033 Compare April 4, 2026 03:37
…n, and device status flags

Add full pseudo-terminal (PTY) support with PtyManager, PtyPair shared
state, master/slave ring buffers, and line discipline processing (ICRNL,
ECHO, ONLCR). PTY operations (get/set termios, foreground pgrp) are
inherent methods on devices::FileSystem rather than trait methods, since
they are too device-specific for the generic FileSystem trait.

Other changes:
- Separate NodeInfo constants for stdin/stdout/stderr (distinct ino)
- Add /dev/tty (controlling terminal) routing reads to stdin, writes to stdout
- Nonblocking stdin support via platform read_from_stdin_nonblocking
- StdinPollable, PtyMasterPollable, PtySlavePollable for epoll/poll/select
- DeviceStatusFlags for per-entry O_NONBLOCK tracking
- Manual FdEnabledSubsystemEntry with on_dup/on_close for PTY refcounting
- Implement *_at stubs (NotADirectory), fd_path, rename, set_open_status_flags
- /dev and /dev/pts directory stat support
- Proper error returns instead of unimplemented!() in open() and read()
- Zero-length read/write guards for PTY paths
@wdcui wdcui force-pushed the wdcui/stacked/pr7-devices branch from 51b46e1 to 4fcc29b Compare April 4, 2026 03:39
@wdcui wdcui changed the title PR 7: fs/devices — PTY subsystem, separate stdio nodes, nonblocking stdin fs/devices — PTY subsystem, separate stdio nodes, nonblocking stdin Apr 4, 2026
@wdcui wdcui marked this pull request as ready for review April 4, 2026 04:07
@wdcui wdcui requested review from CvvT and jaybosamiya-ms April 4, 2026 04:07
@wdcui wdcui closed this Apr 7, 2026
@jaybosamiya-ms jaybosamiya-ms added the expmt:shadow-kiln Tag to quickly find the different PRs as part of the "shadow kiln" experiment. label Apr 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

expmt:shadow-kiln Tag to quickly find the different PRs as part of the "shadow kiln" experiment.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants