Skip to content

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

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

wan9chi wants to merge 6 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
New syscall wrappers and path resolution run in preload/signal-sensitive contexts; bump allocator inlining changes affect stack usage in constrained environments.

Overview
Adds no_std Unix filesystem and I/O building blocks for freestanding Linux and macOS preload: pread, faccessat, extended Error errno values, Stat::is_regular_file, Linux fcntl dup/close-on-exec helpers, and tighter BorrowedFd::try_borrow_raw (non-negative fds plus AT_FDCWD only).

fspy_nostd_alloc gains allocator-backed fd_path, resolve_path_at, and Linux format_proc_self_fd for joining paths relative to a dirfd; macOS getcwd now requires at least PATH_MAX. PageBump / PooledBump are concrete wrapper types with #[inline(never)] Allocator methods to avoid blowing signal/vfork stack depth.

Smaller fixes: public OwnedFd::from_raw_fd, IpcStr::as_bytes on Unix/none, safer Windows to_os_string on odd-length payloads, and fspy_shared dev-dependencies gated off target_os = "none".

Reviewed by Cursor Bugbot for commit 1d28e3d. 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  -0.39%  [ -5.96% ..  +5.70%]  overhead   +66.80%
dynamic/access             change  +0.79%  [ -9.57% ..  +8.02%]  overhead   +20.52%
dynamic/access-relative    change  -2.80%  [-13.85% ..  +3.57%]  overhead   +60.89%
dynamic/access-contended   change  -2.99%  [-12.51% ..  +6.39%]  overhead   +20.24%
static/launch              change  +0.72%  [ -4.40% ..  +6.87%]  overhead  +202.49%
static/access              change  -0.46%  [ -8.96% ..  +4.80%]  overhead +1298.17%
static/access-relative     change  +0.85%  [-12.44% .. +16.41%]  overhead +1780.84%
static/access-contended    change  -0.27%  [ -6.82% ..  +8.22%]  overhead +1240.22%

macos

dynamic/launch             change  -0.10%  [ -2.45% ..  +2.65%]  overhead  +227.02%
dynamic/access             change  -0.01%  [ -4.74% ..  +3.91%]  overhead    +3.99%
dynamic/access-relative    change  +0.22%  [ -3.18% ..  +3.31%]  overhead  +256.54%
dynamic/access-contended   change  +0.19%  [ -1.71% ..  +2.27%]  overhead    +4.73%

windows

dynamic/launch             change  +0.10%  [ -6.37% ..  +5.38%]  overhead   +26.88%
dynamic/access             change  +0.00%  [ -6.49% .. +12.16%]  overhead    +2.21%
dynamic/access-relative    change  +0.59%  [ -8.48% .. +29.23%]  overhead    +1.91%
dynamic/access-contended   change  -1.99%  [ -8.94% ..  +4.89%]  overhead    +1.58%

@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 5 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