Skip to content

dos.library: ExamineFH, DupLockFromFH, ParentOfFH, GetCurrentDirName, SetFileSize, SplitName, SetProgramName - #161

Merged
sidick merged 1 commit into
mainfrom
dos-tier1-cheap-file-ops
Oct 18, 2026
Merged

sidick merged 1 commit into
mainfrom
dos-tier1-cheap-file-ops

Conversation

@sidick

@sidick sidick commented Oct 18, 2026 •

Copy link
Copy Markdown
Owner

Summary

codewiz's newlib-porting feedback: volamos 0.10 aborts the program on ExamineFH/MakeLink/GetCurrentDirName/DupLockFromFH/ReadLink/ParentOfFH, so fstat() falls back to Seek and getcwd() to Lock("")+NameFromLock, and link()/symlink()/fchdir() are implemented but excluded from CI pending a real-AmigaOS run.

Scanned the rest of the dos.library LVO table for other gaps while at it, especially around file operations, and sorted what's missing into tiers by how much new work each needs (see #159/#160 for the other two). This PR is "Tier 1": calls that are genuinely cheap because they reuse infrastructure that already exists, not new capability -- six from codewiz's own list (all but MakeLink/ReadLink, which need real host symlink/hardlink support and are tracked in #160), plus two more found in the same scan.

  • ExamineFH/DupLockFromFH/ParentOfFH: every open FileHandle already carries its resolved Amiga path (HostHandle::HostFile, for NameFromFH); this PR adds the host path alongside it (same "carry both paths" convention doslock::LockEntry already uses for a real Lock) and calls straight into Examine/Lock's own fill_fib/new_lock helpers. Genuinely thin wrappers.
  • GetCurrentDirName: a thin wrapper around Vfs::cwd(), the same state CurrentDir() already maintains.
  • SetFileSize: a few lines of std::fs::File::set_len, with the same offset-mode resolution Seek already does.
  • SplitName: a pure string function (no Vfs/host I/O at all), same tier as the AddPart/FilePart/PathPart already in dospath.rs.
  • SetProgramName: the inverse of the already-implemented GetProgramName -- replaces the cli_CommandName BSTR with a freshly-sized one.

Not in this PR: MakeLink/ReadLink (real symlinks, more work) and OpenFromLock/ChangeMode (cheap but need a small refactor first) -- tracked in #160 and #159 respectively for later.

Test plan

  • Unit tests for every new DosState method (doslock.rs/dosfile.rs): success paths, unknown-handle/lock failures, and the file-info edge cases (volume-root parent, truncate-vs-extend seek-position handling).
  • Real end-to-end tests driving actual A-line trap dispatch for every one of the seven calls (ExamineFH, DupLockFromFH, ParentOfFH, GetCurrentDirName, SplitName, SetProgramName round-tripped through GetProgramName) -- proves the real LVO offsets/register assignments, not just the underlying logic.
  • cargo test --workspace (1068 tests, up from 1041) passes; cargo clippy --workspace --all-targets and cargo fmt --check clean.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Godbk9UDW5obqYsdkXkyRR

… SetFileSize, SplitName, SetProgramName

Follow-up to codewiz's newlib-porting feedback that volamos 0.10 aborts
on ExamineFH/MakeLink/GetCurrentDirName/DupLockFromFH/ReadLink/
ParentOfFH. Implements the six genuinely cheap ones from that report
(all but MakeLink/ReadLink, tracked separately in #160 along with the
other, more involved gaps found while scanning the rest of the LVO
table), plus two more from that same scan: SetFileSize and
SplitName/SetProgramName, which needed only a small refactor
(OpenFromLock/ChangeMode, tracked in #159) or none at all.

Each reuses existing infrastructure rather than adding new capability:

- ExamineFH/DupLockFromFH/ParentOfFH read the host path every open
  FileHandle already carries (a new third field on HostHandle::
  HostFile, alongside the amiga_path NameFromFH already used) and
  call straight into Examine/Lock's own fill_fib/new_lock -- the same
  data a LockEntry already carries for a real Lock, just sourced from
  an open file instead.
- GetCurrentDirName is a thin wrapper around Vfs::cwd(), the same
  state CurrentDir() already maintains.
- SetFileSize is a few lines of std::fs::File::set_len.
- SplitName is a pure string function, no different in kind from the
  AddPart/FilePart/PathPart already in dospath.rs.
- SetProgramName is the inverse of the already-implemented
  GetProgramName, replacing the cli_CommandName BSTR.
@sidick
sidick merged commit ede6779 into main Oct 18, 2026
9 checks passed
@sidick
sidick deleted the dos-tier1-cheap-file-ops branch October 18, 2026 11:13
@sidick sidick mentioned this pull request Oct 18, 2026
3 tasks done
sidick added a commit that referenced this pull request Oct 18, 2026
Tier 2 of the dos.library LVO gap scan from #156/PR #161: cheap but
needing a small refactor first, as tracked by #159.

- OpenFromLock: splits DosState::open's "resolve a name through the Vfs"
  half from its "open a host path per access_mode and register a
  FileHandle" half (now open_resolved), so OpenFromLock can skip
  straight to the latter using a lock's already-resolved
  (host_path, amiga_path) from doslock::LockEntry. On a successful
  open the lock is relinquished via the existing unlock() path (matching
  the autodoc's "should not be UnLock()ed or used again"); a failed
  open leaves it untouched. Always opens the existing file read+write
  (MODE_OLDFILE-style) regardless of the lock's shared/exclusive access
  -- treating an exclusive lock's "NEWFILE-like" wording as a license to
  truncate would destroy a file that necessarily already exists.
- ChangeMode: this runtime has no real concurrency to enforce (same
  posture as the semaphore/AddTask stubs), so it just validates the
  referenced lock or filehandle exists (per CHANGE_LOCK/CHANGE_FH) and
  reports success, updating LockEntry::access for debuggability on the
  lock side (there's no equivalent field on HostHandle::HostFile worth
  adding for the filehandle side).


Claude-Session: https://claude.ai/code/session_01Godbk9UDW5obqYsdkXkyRR

Co-authored-by: Claude Sonnet 5 <[email protected]>
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