Repository navigation
dos.library: OpenFromLock, ChangeMode (#159) - #162
Merged
Merged
Conversation
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). Co-Authored-By: Claude Sonnet 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01Godbk9UDW5obqYsdkXkyRR
This was referenced Oct 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Tier 2 of the dos.library LVO gap scan (#159; PR #161 did Tier 1). Both calls needed a small refactor first, which is why they weren't folded into #161 directly.
OpenFromLock:DosState::open's "resolve a name through theVfs" step and its "open a host path peraccess_modeand register a guestFileHandle" step are now split (the latter isopen_resolved), soOpenFromLockcan skip straight to the second step using a lock's already-resolved(host_path, amiga_path)fromdoslock::LockEntryinstead of re-resolving a name. Per the real autodoc ("the lock is (effectively) relinquished, and should not beUnLock()ed or used [again]... If the open fails, the lock is still usable"): a successful open calls the existingunlock()on the lock itself (same cleanup a realUnLock()does), and a failed open leaves the lock entirely untouched.Judgment call: the autodoc says the resulting handle's access mode "is of the same access mode as the lock you gave up -- shared is similar to
MODE_OLDFILE, exclusive is similar toMODE_NEWFILE." Taken literally that would mean create-and-truncate for an exclusive lock -- but the file necessarily already exists (that's how the lock came to exist at all), soMODE_NEWFILE's truncating semantics would destroy data for no real reason. This implementation always opens the existing file read+write (falling back read-only), the same asopen()'sMODE_OLDFILEbranch, for both lock access modes -- reading "NEWFILE-like" as describing the resulting handle's nominal label (which this runtime doesn't track per-handle at all), not a license to re-create an already-locked file.ChangeMode: this runtime models no real concurrency (single process, same posture as the existingInitSemaphore/ObtainSemaphorefamily andAddTask's unscheduled-task stub), so there's nothing for a mode change to actually enforce -- same as there's no real shared/exclusive enforcement forLockto begin with. Validates that the referenced lock (CHANGE_LOCK) or filehandle (CHANGE_FH) exists and reports success; the real autodoc's own "the handler may well reject this request" already tells callers not to rely on this unconditionally anyway.Judgment call: on the lock side,
newmodeis written intoLockEntry::access, mirroring that field's existing "recorded for debuggability only" convention. On the filehandle side there's no equivalent field onHostHandle::HostFile-- adding one purely to record a value nothing else in this runtime ever reads back would be exactly the kind of defensive bookkeeping the semaphore/task stubs already decline to do, so reporting success without persisting anything is the honest-enough answer there.Test plan
DosState::open_from_lock(success + lock relinquished, unknown lock ->ERROR_INVALID_LOCK, failed open leaves the lock usable) andDosState::change_mode(lock success + recorded access, unknown lock, filehandle success, unknown filehandle, invalidtype).Lock->OpenFromLock->Readround-trip;OpenFromLockon an unknown lock;Lock->ChangeMode(CHANGE_LOCK);ChangeModeon an unknown lock) -- proves the real LVO offsets (-378/-450) and register assignments, not just the underlying logic.cargo test --workspace(1080 tests, up from 1068) passes;cargo clippy --workspace --all-targetsandcargo fmt --checkclean.🤖 Generated with Claude Code
https://claude.ai/code/session_01Godbk9UDW5obqYsdkXkyRR