Skip to content

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

Closed
wdcui wants to merge 4 commits intowdcui/stacked/pr3-foundation-typesfrom
wdcui/stacked/pr4-fd-layer
Closed

File descriptor layer: dup/close hooks, fork support, WeakEntryHandle#744
wdcui wants to merge 4 commits 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 hardening #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 added 2 commits April 3, 2026 09:12
…yMap clone support

Layer 0 of the core litebox crate changes for multi-process support:

Platform traits:
- AddressSpaceProvider trait for per-process address spaces
- RawMessageProvider for direct guest-broker byte channels
- StdioProvider expansion (terminal attrs, window size, nonblocking
  stdin, cancel, host TTY device info)
- SendError::Io, ReceiveError::ProtocolError/Eof, StdioReadError::WouldBlock
- SystemInfoProvider::current_processor_number()
- Provider supertrait: + RawMessageProvider + AddressSpaceProvider

Event/sync:
- IOPollable::needs_host_poll(), should_block_read() defaults
- Observer::prune_dead_observers() to GC stale Weak refs on register
- Waker::ptr_eq() utility
- FutexManager wait/wake: address_space_id parameter for multi-process
- trace_fs feature gate for RawSyncPrimitivesProvider

Utilities:
- AnyMap: Clone bound on insert, type-erased Clone impl
- PageManagementProvider::allocate_pages: noreserve parameter
- copy_pages: fix chunk-length bug (was using old_range.len() per chunk)

Caller updates across all platform crates and litebox_shim_linux.
Add RawMessageProvider and AddressSpaceProvider implementations for
WindowsUserland, and add the _noreserve parameter to allocate_pages.
These are required by the Provider supertrait expansion and
PageManagementProvider signature change in the foundation types PR.
@wdcui wdcui force-pushed the wdcui/stacked/pr4-fd-layer branch from e3a4c2f to 152485f Compare April 3, 2026 21:20
wdcui added 2 commits April 3, 2026 14:51
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
@wdcui wdcui force-pushed the wdcui/stacked/pr3-foundation-types branch 4 times, most recently from 0bee7b2 to 6c425be Compare April 7, 2026 03:42
@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