Skip to content

vfs: add robust split_parent_and_name and refactor path parsing/creation#6

Draft
AMDRIP wants to merge 6 commits intoPOSIX-Implementationfrom
codex/analyze-repository-and-documentation
Draft

vfs: add robust split_parent_and_name and refactor path parsing/creation#6
AMDRIP wants to merge 6 commits intoPOSIX-Implementationfrom
codex/analyze-repository-and-documentation

Conversation

@AMDRIP
Copy link
Owner

@AMDRIP AMDRIP commented Mar 1, 2026

Motivation

  • Consolidate repeated path-splitting logic into a single robust helper that trims trailing slashes and correctly handles root and edge cases.
  • Fix O_CREAT handling in vfs_open to create files in the resolved parent directory rather than trying to create with the full path on the root vnode.
  • Reduce duplicated code and improve error handling (release vnodes on failure) across multiple VFS operations.

Description

  • Added a new split_parent_and_name helper that returns bool and properly trims trailing slashes, preserves root semantics, and splits a path into dir_out and name_out.
  • Updated vfs_open to resolve the parent directory via vfs_resolve_path and call parent->ops->create(parent, filename, ...) when O_CREAT is set, and to release the parent vnode on all paths; also release the opened vnode if open fails.
  • Replaced manual inline path parsing in vfs_stat, vfs_unlink, vfs_write_file, vfs_mkdir, and vfs_rename with calls to the new split_parent_and_name and added validation for its return value.
  • Removed the old duplicated split_parent_and_name implementation and updated callers to handle failure cases consistently.

Testing

  • Built the project with make to validate compilation, which completed successfully.
  • Executed the VFS unit test suite via make test-vfs, which passed.
  • Ran filesystem integration tests (make test-fs) to exercise create, write, stat, readdir, unlink, mkdir, and rename flows, which also passed.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant