Skip to content

feat(fspy_nostd): add Unix filesystem, I/O, and path-resolution primitives - #1026

Open
wan9chi wants to merge 5 commits into
mainfrom
fspy-linux/1-nostd-primitives
Open

wan9chi wants to merge 5 commits into
mainfrom
fspy-linux/1-nostd-primitives

Conversation

@wan9chi

@wan9chi wan9chi commented Nov 27, 2026 •

Copy link
Copy Markdown
Member

Motivation

Replacing Linux LD_PRELOAD and seccomp_unotify with an in-process freestanding (target_os = "none") ELF/SIGSYS launcher requires no_std Unix filesystem, I/O, and allocator-backed path-resolution primitives shared between the freestanding Linux launcher and the macOS preload library.

Changes

  • fspy_nostd: add Error::ACCES (plus .typos.toml), pread, faccessat, stat/fstat, getcwd, readlinkat/fcntl_getpath, and OwnedFd::from_raw_fd, with unit tests.
  • fspy_nostd_alloc: add allocator-backed getcwd, fd_path, resolve_path_at, and PooledBump helpers, with unit tests.
  • vt_ipc_str: expose IpcStr::as_bytes for Unix and target_os = "none".
  • fspy_shared: gate host dev-dependencies on not(target_os = "none") for bare-metal builds.

Stack created with GitHub Stacks CLI • Give Feedback 💬


Note

Medium Risk
Touches low-level syscalls, fd borrowing rules, and allocation in constrained stack contexts; broad test coverage limits but regressions could affect path resolution in intercept code.

Overview
Adds no_std / syscall-level Unix primitives and allocator-backed path resolution so freestanding Linux and macOS preload code can inspect paths and fds without libc malloc.

In fspy_nostd, expands Error errno coverage (including ACCES), pread, faccessat / AccessFlags, Stat::is_regular_file, Linux fcntl dup/CLOEXEC helpers, and tightens BorrowedFd::try_borrow_raw to accept AT_FDCWD as well as non-negative fds. OwnedFd::from_raw_fd is now public. macOS getcwd requires a PATH_MAX buffer and drops the small-buffer fallback.

In fspy_nostd_alloc, adds fd_path, resolve_path_at, and Linux format_proc_self_fd, plus PageBump / PooledBump wrappers with #[inline(never)] allocator methods to keep bump allocation from bloating stack frames in signal/vfork-sensitive contexts.

Smaller follow-ons: IpcStr::as_bytes on Unix/none, safer Windows to_os_string for odd byte lengths, fspy_shared dev-deps gated off target_os = "none", and .typos.toml for ACCES.

Reviewed by Cursor Bugbot for commit 2c0d2ed. Bugbot is set up for automated code reviews on this repo. Configure here.

…tives

Add low-level `no_std` filesystem, I/O, and allocator-backed path
resolution primitives needed by the freestanding Linux ELF/SIGSYS
tracker and shared Unix exec resolver:

- `fspy_nostd`: `Error::ACCES`, `pread`, `faccessat`, `stat`/`fstat`,
  `getcwd`, `readlinkat`/`fcntl_getpath`, plus unit tests.
- `fspy_nostd_alloc`: allocator-backed `getcwd`, `fd_path`,
  `resolve_path_at`, and pooled bump allocator helpers, plus unit tests.
- `vt_ipc_str`: `IpcStr::as_bytes` for Unix and `target_os = "none"`.
- `fspy_shared`: gate host dev-dependencies on `not(target_os = "none")`.

Co-authored-by: Gemini 4 Neon <noreply@google.com>
@wan9chi
wan9chi added this pull request to stack #1030 November 27, 2026 00:33
@github-actions

github-actions Bot commented Nov 27, 2026 •

Copy link
Copy Markdown

fspy benchmark

linux

dynamic/launch             change  -1.08%  [ -5.35% ..  +4.05%]  overhead   +56.69%
dynamic/access             change  +4.21%  [ -5.23% .. +10.89%]  overhead   +22.57%
dynamic/access-relative    change  -2.07%  [ -8.69% .. +10.47%]  overhead   +73.13%
dynamic/access-contended   change  +1.75%  [ -7.28% ..  +5.41%]  overhead   +59.62%
static/launch              change  +0.62%  [ -5.33% ..  +7.93%]  overhead  +194.72%
static/access              change  -0.05%  [ -6.99% .. +11.58%]  overhead +1466.60%
static/access-relative     change  +1.39%  [ -4.06% .. +12.40%]  overhead +1914.95%
static/access-contended    change  -0.01%  [ -1.45% ..  +1.40%]  overhead +1869.59%

macos

dynamic/launch             change  -0.11%  [ -2.84% ..  +2.72%]  overhead  +225.49%
dynamic/access             change  +0.00%  [ -3.09% ..  +4.90%]  overhead   +11.94%
dynamic/access-relative    change  +0.58%  [ -3.41% ..  +3.26%]  overhead  +259.17%
dynamic/access-contended   change  +0.00%  [ -2.27% ..  +2.36%]  overhead    +3.67%

windows

dynamic/launch             change  +0.11%  [ -1.20% ..  +1.25%]  overhead   +26.05%
dynamic/access             change  +0.19%  [ -0.76% ..  +0.76%]  overhead    +0.78%
dynamic/access-relative    change  +0.19%  [ -0.74% ..  +0.92%]  overhead    +1.11%
dynamic/access-contended   change  +0.00%  [ -0.72% ..  +0.74%]  overhead    +1.11%

@wan9chi wan9chi changed the title fspy linux/1 nostd primitives feat(fspy_nostd): add Unix filesystem, I/O, and path-resolution primitives Nov 27, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 6730e4b. Configure here.

Comment thread crates/fspy_nostd_alloc/src/fs.rs Resolved
wan9chi and others added 4 commits November 27, 2026 08:45
Co-authored-by: Gemini 4 Neon <noreply@google.com>
…r decoding

- Wrap `PageBump` like `PooledBump` with unconditional `#[inline(never)]` on
  `allocate`/`deallocate`/`grow` and drop unused `allocate_zeroed`/
  `grow_zeroed`/`shrink` overrides
- Avoid panicking on odd byte lengths in Windows `IpcStr::to_os_string`
- Export `fspy_nostd_alloc::fs::format_proc_self_fd` for reuse
- Use `linux_raw_sys::general::{PATH_MAX, X_OK}` instead of literals in
  `fspy_nostd::fs::linux`
- Tighten `BorrowedFd::try_borrow_raw` to accept only `fd >= 0 || fd == CWD_RAW`
- Remove dead/unreachable code (`mac::getcwd_small`, `Error::NOSYS`,
  `AtFlags::REMOVEDIR`, and unreachable `OVERFLOW` fd conversions in Linux fs)

Co-authored-by: Gemini 4 Neon <noreply@google.com>
Co-authored-by: Gemini 4 Neon <noreply@google.com>

This branch has not been deployed

No deployments
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