[FEATURE] Add process-owned working directories and cwd adapters #44

Open
opened 2026-10-27 10:53:54 +01:00 by erikinkinen · 1 comment
Owner

Problem and motivation

Compatibility processes need an owned current directory for build tools which
change directories, retain directory fds and request their physical cwd name.
The mediator currently resolves cwd-relative paths through the initial native
scope selector. It has no process cwd owner or chdir/fchdir/getcwd interface.

Proposed behavior and scope

Implement process-owned cwd shared by threads, with an original cwd snapshot
for each pending relative operation. Add counted chdir and fchdir adapters with
fresh SEARCH checks, without adding a directory READ requirement. Closing or
replacing an fd must not revoke an admitted fchdir or pending pathname base.

Return fresh physical getcwd names rooted at the actual process ceiling,
including after rename. Support results larger than a native packet through a
retained immutable paged report and checked caller capacity, without PATH_MAX
as a policy limit. Too-small buffers return ERANGE and remain unchanged; no
malloc-return extension is included. An unavailable rooted name is an honest
error while its actual directory pin remains retained.

Scope includes the native/protocol contracts, counted producer storage, Posixd,
Cstd explicit-prefix adapters, real native consumer, provider controls and manuals.
Compatibility fork/exec remains its own unimplemented process feature; specify
its future ownership boundary and change only actual existing lifecycle hooks.

Authority, security and reliability

Retain original directory objects, scope and generation through all provider
work, cancellation, failed publication and terminal cleanup. Paths, PWD strings,
uid zero, numeric object IDs and report keys grant no authority. Absolute paths
and '..' cannot exceed the original root or inherited ceilings, including after
moves and detachment. Keep final and prefix search policy separate from content
READ rights.

Do not reinterpret consumed permission evidence as a stable namespace version.
Freeze a real revision/epoch strategy for concurrent rename before publishing
physical reports. Uncertain native work preserves its original owner, packet,
first cause and backing, with no ordinary replay or false unchanged-cwd error.
No callback runs under a process-global data gate across blocking I/O.

Acceptance criteria

  • Implement shared process cwd and retained operation snapshots; cover concurrent
    chdir, fchdir fd close/dup2, both relative namespace operands, generation limits
    and actual original retirement without capability widening.
  • Implement complete search-only chdir/fchdir success/error paths and deterministic
    physical getcwd after rename, mount traversal and detach, with root confinement.
  • Implement immutable counted reports beyond one packet, exact ERANGE/NUL/output
    semantics, wrong-origin/key/range refusal, cancellation, unwind and cleanup.
  • Migrate exact compatibility/arena/config codecs, errno domains, producers,
    native C/Rust adapters, headers and manuals; preserve existing contracts.
  • Supply meaningful unit, provider, transport and native guest controls for RAM,
    ext and FAT; report source, compiler and native acceptance separately. Full
    fork/exec and in-EriX build acceptance remain separate requirements.

Alternatives and tradeoffs

Cached PWD strings do not represent renamed or detached original objects. A
shared mutable native cwd selector can retarget already pending calls. Reopening
paths loses object identity, and READ-admitting a directory to implement SEARCH
widens rights. Reuse the existing native pin, mount-parent and counted-description
mechanisms, adding only the missing process ownership and reporting contracts.

Tracking and rollout

This completes a required part of mediated libc file operations tracked by
LibCstd file adapters.
Coordinate protocol/storage migration, native provider/reporting, mediator and
C/native adoption before selecting the new cohort. Follow file timestamp updates
and the mediator PR for the
related changes. Retire superseded cwd lookup only after
all actual pathname consumers use retained process snapshots.

## Problem and motivation Compatibility processes need an owned current directory for build tools which change directories, retain directory fds and request their physical cwd name. The mediator currently resolves cwd-relative paths through the initial native scope selector. It has no process cwd owner or chdir/fchdir/getcwd interface. ## Proposed behavior and scope Implement process-owned cwd shared by threads, with an original cwd snapshot for each pending relative operation. Add counted chdir and fchdir adapters with fresh SEARCH checks, without adding a directory READ requirement. Closing or replacing an fd must not revoke an admitted fchdir or pending pathname base. Return fresh physical getcwd names rooted at the actual process ceiling, including after rename. Support results larger than a native packet through a retained immutable paged report and checked caller capacity, without PATH_MAX as a policy limit. Too-small buffers return ERANGE and remain unchanged; no malloc-return extension is included. An unavailable rooted name is an honest error while its actual directory pin remains retained. Scope includes the native/protocol contracts, counted producer storage, Posixd, Cstd explicit-prefix adapters, real native consumer, provider controls and manuals. Compatibility fork/exec remains its own unimplemented process feature; specify its future ownership boundary and change only actual existing lifecycle hooks. ## Authority, security and reliability Retain original directory objects, scope and generation through all provider work, cancellation, failed publication and terminal cleanup. Paths, PWD strings, uid zero, numeric object IDs and report keys grant no authority. Absolute paths and '..' cannot exceed the original root or inherited ceilings, including after moves and detachment. Keep final and prefix search policy separate from content READ rights. Do not reinterpret consumed permission evidence as a stable namespace version. Freeze a real revision/epoch strategy for concurrent rename before publishing physical reports. Uncertain native work preserves its original owner, packet, first cause and backing, with no ordinary replay or false unchanged-cwd error. No callback runs under a process-global data gate across blocking I/O. ## Acceptance criteria - [ ] Implement shared process cwd and retained operation snapshots; cover concurrent chdir, fchdir fd close/dup2, both relative namespace operands, generation limits and actual original retirement without capability widening. - [ ] Implement complete search-only chdir/fchdir success/error paths and deterministic physical getcwd after rename, mount traversal and detach, with root confinement. - [ ] Implement immutable counted reports beyond one packet, exact ERANGE/NUL/output semantics, wrong-origin/key/range refusal, cancellation, unwind and cleanup. - [ ] Migrate exact compatibility/arena/config codecs, errno domains, producers, native C/Rust adapters, headers and manuals; preserve existing contracts. - [ ] Supply meaningful unit, provider, transport and native guest controls for RAM, ext and FAT; report source, compiler and native acceptance separately. Full fork/exec and in-EriX build acceptance remain separate requirements. ## Alternatives and tradeoffs Cached PWD strings do not represent renamed or detached original objects. A shared mutable native cwd selector can retarget already pending calls. Reopening paths loses object identity, and READ-admitting a directory to implement SEARCH widens rights. Reuse the existing native pin, mount-parent and counted-description mechanisms, adding only the missing process ownership and reporting contracts. ## Tracking and rollout This completes a required part of mediated libc file operations tracked by [LibCstd file adapters](https://git.erikinkinen.fi/erix/lib-cstd/issues/14). Coordinate protocol/storage migration, native provider/reporting, mediator and C/native adoption before selecting the new cohort. Follow [file timestamp updates](https://git.erikinkinen.fi/erix/posixd/issues/43) and [the mediator PR](https://git.erikinkinen.fi/erix/posixd/pulls/5) for the related changes. Retire superseded cwd lookup only after all actual pathname consumers use retained process snapshots.
Author
Owner

The C consumer now requests a 952-byte raw physical cwd across the existing reply boundary, checks a short buffer and two complete results, then removes the tree through retained parents. New adapter controls cover a successful first chunk followed by an error, unchanged caller bytes, original report release and a later fresh request. Implementation.

The C consumer now requests a 952-byte raw physical cwd across the existing reply boundary, checks a short buffer and two complete results, then removes the tree through retained parents. New adapter controls cover a successful first chunk followed by an error, unchanged caller bytes, original report release and a later fresh request. [Implementation](https://git.erikinkinen.fi/erix/posixd/commit/40aafe5900878e128325968cb62e8840bb79e62c).
erikinkinen added this to the Alpha 1 milestone 2026-10-30 09:35:08 +01:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
erix/posixd#44
No description provided.