Skip to content

feat(fs): open a host file by path, following links, decided on the handle - #110

Merged
christianparpart merged 1 commit into
masterfrom
feature/open-host-file
Nov 30, 2026
Merged

christianparpart merged 1 commit into
masterfrom
feature/open-host-file

Conversation

@christianparpart

Copy link
Copy Markdown
Member

Closes #109.

IDescriptorFileSystem::openHostFile(std::filesystem::path, OpenFlags) opens a file a tool's user named on the command line, the way any tool does. It is the one entry point that takes an ambient path; the capability-scoped API stays as it is.

  • Links: the system resolves the path and follows every link on it, an absolute target included, so Nix profile links and alternatives links open.
  • Directories on the way: only search access is needed, so a file under a 0711 home opens.
  • Never waits: POSIX opens O_NONBLOCK and clears it for a regular file only. A leased file is opened again through openAfterWouldBlock, whose path handle now follows a final link unless the flags say O_NOFOLLOW; openAt always says it, so openAt is unchanged. Windows opens with CreateFileW and READ|WRITE|DELETE sharing, a path open now shared with openPreopen.
  • Decisions stay with the caller: a directory, a FIFO or a device opens too, and the caller checks the type and size on the handle.
  • Flags: open is None or Directory; every other flag is Invalid, checked by the new checkHostOpenFlags().
  • In-memory model: it resolves the path from its root. Links are followed, an absolute target restarts at the root, and .. at the root stays there.
  • Tests: HostFile_test.cpp runs on both fixture kinds. POSIX adds a FIFO through a link and a file under a search-only parent; the lease test adds the followed link.

Consumer impact

Breaking: a new pure virtual on IDescriptorFileSystem. Anything implementing the interface must override it, and a decorator forwards it.

I grepped Contour, endo and fastcached for implementers of IDescriptorFileSystem, in the local checkouts and with gh search code on each repository. None implements it outside the vendored copy. Isoline's test decorator is the only one, and Isoline overrides it when it re-vendors.

Gates (local)

  • clang-debug build: clean; ctest 95/95 (the hygiene check needed a provenance row for the new test file).
  • gcc-release and clang-tidy: see the comment below.
  • scripts/clang-format.py --all --check: clean.
  • mkdocs build --strict: clean.
  • Windows: MSVC cl /W4 /Zs under wine on WindowsDescriptor.cpp is clean; CI runs the rest.

@christianparpart christianparpart added type/feature New capability, or a user-visible extension of one breaking-change A consumer must change code or build configuration labels Nov 30, 2026
@christianparpart

Copy link
Copy Markdown
Member Author

Local gates on eaad7ae: clang-debug 95/95, gcc-release 95/95, clang-tidy preset clean (two findings in the new code, fixed), clang-format --all --check clean, mkdocs --strict clean.

…andle

IDescriptorFileSystem::openHostFile(path, open) opens a file a tool's user
named, the way any tool does: the system resolves the path and follows every
link on it, absolute targets included, and needs only search access on the
way, so a file under a 0711 home opens. The open never waits: POSIX opens
O_NONBLOCK and clears the flag for a regular file only (a leased file is
opened again through the path handle, which now follows a final link unless
the open says O_NOFOLLOW); Windows opens with CreateFileW sharing read, write
and delete. Nothing else is decided: a directory or a FIFO opens too, and the
caller refuses it on the handle. Only None and Directory are accepted
(checkHostOpenFlags). The in-memory model resolves the path from its root.

Closes #109.

Signed-off-by: Christian Parpart <christian@parpart.family>
@christianparpart
christianparpart merged commit dc2a2a2 into master Nov 30, 2026
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change A consumer must change code or build configuration type/feature New capability, or a user-visible extension of one

Projects

None yet

Development

Successfully merging this pull request may close these issues.

core::fs: open a host file by path, following links, decided on the handle

1 participant