Skip to content

File descriptor layer: dup/close hooks, fork support, WeakEntryHandle#744

Open
wdcui wants to merge 1 commit intowdcui/stacked/pr3-foundation-typesfrom
wdcui/stacked/pr4-fd-layer
Open

File descriptor layer: dup/close hooks, fork support, WeakEntryHandle#744
wdcui wants to merge 1 commit intowdcui/stacked/pr3-foundation-typesfrom
wdcui/stacked/pr4-fd-layer

Conversation

@wdcui
Copy link
Copy Markdown
Member

@wdcui wdcui commented Apr 3, 2026

Summary

Layer 1 of the core litebox crate changes. Refactors fd/mod.rs to support process-level operations (fork, dup, fd passing) needed by the upcoming process registry.

Part of the stacked PR series — base: PR #743 (foundation types)

Changes

fd/mod.rs (~396 insertions, ~153 deletions)

  • on_dup() / on_close() hooks: Default-empty trait methods on FdEnabledSubsystemEntry for ref-counting subsystems (e.g., pipes, PTYs)
  • close_and_remove: Replaces close_and_duplicate_if_shared with simpler always-remove semantics (Released variant replaces Duplicated)
  • duplicate_raw_fd: Fork-time entry duplication by raw OwnedFd
  • WeakEntryHandle + EntryHandle::downgrade(): Weak references to descriptor entries
  • PassedFd / duplicate_for_passing / insert_passed_fd: SCM_RIGHTS-style fd passing between processes
  • clone_for_fork on RawDescriptorStorage: Deep-clone descriptor table for fork
  • entry_handles: Iterator over all alive entries of a subsystem
  • EntryHandle: Restructured to named fields with Clone support, adds object_id() and identity_addr()

fd/tests.rs

  • New tests for DescriptorObjectId preservation across duplicate and clone_for_fork
  • Object ID assertions added to existing tests

net/mod.rs (minimal caller updates)

  • close_and_duplicate_if_sharedclose_and_remove
  • CloseResult::DuplicatedCloseResult::Released
  • Removed queued_for_closure field and attempt_to_close_queued() (no longer needed)

PR Stack

  1. ✅ PR Syscall rewriter: interface changes, no_std support, and bug fixes #738 — Syscall rewriter interface (wdcui/stacked/pr1c-rewriter-interface)
  2. ✅ PR Runtime ELF patching, trampoline format changes, and rtld_audit removal #739 — Runtime ELF patching + trampoline format (wdcui/stacked/pr1b-trampoline-format)
  3. ✅ PR Cross-platform packager: OCI symlink resolution, rewrite-include, rtld_audit removal #741 — Cross-platform packager (wdcui/stacked/pr2-packager-crossplatform)
  4. ✅ PR Foundation types: platform traits, event extensions, sync changes, AnyMap clone #743 — Foundation types (wdcui/stacked/pr3-foundation-types)
  5. → This PR — File descriptor layer (wdcui/stacked/pr4-fd-layer)
  6. 🔜 Layer 2: fs traits, mm ranges, net simplification, pipes

@wdcui wdcui force-pushed the wdcui/stacked/pr4-fd-layer branch from e3a4c2f to 152485f Compare April 3, 2026 21:20
Refactor the Descriptors table to support dup/close lifecycle hooks,
close_and_remove semantics, fork-aware cloning, and WeakEntryHandle.
Remove DescriptorObjectId in favor of identity_addr() (Arc pointer identity).
@wdcui wdcui force-pushed the wdcui/stacked/pr4-fd-layer branch from 152485f to 2480a40 Compare April 3, 2026 22:02
@wdcui wdcui changed the title File descriptor layer: DescriptorObjectId, dup/close hooks, fork support, WeakEntryHandle File descriptor layer: dup/close hooks, fork support, WeakEntryHandle Apr 3, 2026
@wdcui wdcui requested a review from jaybosamiya-ms April 3, 2026 23:26
@wdcui wdcui marked this pull request as ready for review April 3, 2026 23:27
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