Skip to content

FS/net/pipes layer: trait expansion, shutdown, UDP fixes, vfork-aware pipes#745

Open
wdcui wants to merge 2 commits intowdcui/stacked/pr4-fd-layerfrom
wdcui/stacked/pr5-fs-net-pipes
Open

FS/net/pipes layer: trait expansion, shutdown, UDP fixes, vfork-aware pipes#745
wdcui wants to merge 2 commits intowdcui/stacked/pr4-fd-layerfrom
wdcui/stacked/pr5-fs-net-pipes

Conversation

@wdcui
Copy link
Copy Markdown
Member

@wdcui wdcui commented Apr 3, 2026

Summary

Layer 2 (part 1 of 2) of the stacked PR series. Expands the core FS, network, and pipes subsystems with the interfaces and fixes needed by the process layer.

FileSystem trait expansion (~234 lines in fs/mod.rs)

  • ~15 new methods: open_at, stat_at, unlink_at, readlink_at, rename_at, mkdir_at, fd_path, rename, create_anonymous_file, symlink, link, PTY termios methods, etc.
  • All new methods have default Err(...) bodies so concrete implementations (in_mem, tar_ro, layered, devices) can be added in later PRs
  • New FileType::Symlink variant, FileStatus: Clone
  • PtyTermios type alias in fs/devices.rs

New error types (91 lines in fs/errors.rs, 10 in net/errors.rs)

  • CreateAnonymousFileError, RenameError, ReadLinkError, SymlinkError, LinkError, ShutdownError
  • Extended variants on OpenError, CloseError, ReadError, WriteError, UnlinkError, FileStatusError

Network fixes and additions (~160 lines in net/mod.rs + 16 in socket_channel.rs)

  • shutdown() method with NetworkProxy delegation to StreamSocketChannel
  • UDP local_port leak fix: track LocalPort allocation across bind/connect/sendto/close
  • INADDR_ANY listen fix: use None instead of Ipv4Address::new(0,0,0,0) for smoltcp wildcard
  • ip_listen_endpoint_v4 helper

Pipes enhancements (~156 lines)

  • Clone impl for Pipes
  • Vfork-aware read_vfork_aware() / read_inner() refactor with deadlock detection via fd_ref_count
  • readable_bytes() query method, Deadlock error variant
  • Manual FdEnabledSubsystemEntry impl replacing enable_fds_for_subsystem! macro, overriding on_dup()/on_close() to track writer FD reference counts
  • Release ordering on fd_ref_count mutations paired with Acquire loads

Match exhaustiveness (37 lines in layered.rs)

  • Cover new enum variants (FileType::Symlink, FileStatusError::NotADirectory/SymlinkLoop, OpenError::Interrupted/ClosedFd/NotADirectory, etc.) in existing layered FS match statements

Stacked on

Testing

  • Build: clean (zero warnings)
  • Clippy: clean (zero warnings)
  • Fmt: clean
  • Tests: 208 passed, 15 failed (all pre-existing TUN/EPERM), 34 skipped

… pipes

Expand the FileSystem trait with ~15 new methods (open_at, stat_at, unlink_at,
readlink_at, rename_at, mkdir_at, fd_path, rename, etc.) all with default
Err(...) bodies so concrete implementations can land in later PRs. Add new
error types (CreateAnonymousFileError, RenameError, ReadLinkError, SymlinkError,
LinkError, ShutdownError) and extend existing enums with variants needed by the
process layer (Interrupted, ClosedFd, NotADirectory, WouldBlock, SymlinkLoop).

Network: add shutdown() with NetworkProxy delegation, fix UDP local_port leak
(track allocation across bind/connect/sendto/close), fix TCP INADDR_ANY listen
(use None instead of 0.0.0.0 for smoltcp wildcard), add ip_listen_endpoint_v4
helper.

Pipes: implement Clone, add vfork-aware read with deadlock detection via
fd_ref_count tracking, replace enable_fds_for_subsystem! macro with manual
FdEnabledSubsystemEntry that overrides on_dup/on_close for ref counting,
add readable_bytes() and Deadlock error variant. Use Release ordering on
fd_ref_count mutations to pair with Acquire loads in the deadlock check.
- Backtick-escape Arc<WriteEnd> in pipes.rs doc comment (rustdoc
  invalid_html_tags error).
- Remove get/set_pty_termios and get/set_pty_foreground_pgrp from the
  FileSystem trait — these are PTY-device-specific and belong in the
  PTY subsystem layer, not the generic FS trait.
- Remove PtyTermios type alias from devices.rs (no remaining callers).
@wdcui wdcui force-pushed the wdcui/stacked/pr5-fs-net-pipes branch from 6448a31 to 046443d Compare April 4, 2026 00:18
@wdcui wdcui marked this pull request as ready for review April 4, 2026 00:39
@wdcui wdcui requested review from CvvT and jaybosamiya-ms April 4, 2026 00:39
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.

1 participant