Repository navigation
dos.library: MakeLink, ReadLink, LockRecord family (#160) - #163
Merged
Merged
Conversation
MakeLink/ReadLink map onto real host hard links/symlinks (symlink creation gated #[cfg(unix)], a clean IoErr on other platforms rather than a panic or an attempted but likely-failing Windows symlink). LockRecord/UnLockRecord validate the filehandle exists; LockRecords/ UnLockRecords are unconditional-success stubs, matching this runtime's existing no-real-concurrency posture (InitSemaphore/ObtainSemaphore, AddTask, ChangeMode). Deliberately out of scope (documented in doslock.rs's module docs and the PR body): the real ERROR_IS_SOFT_LINK retry protocol in Lock/Open/Examine, and ST_SOFTLINK detection in Examine/ExNext/ExAll for a host symlink entry.
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
Issue #160's "Tier 3" follow-up to #159/#161/#162's dos.library gap scan.
MakeLink/ReadLink: real AmigaOS soft-link semantics map naturally onto a host symlink, hard-link onto a host hard link.MakeLink(name, dest, soft)(doslock.rs):soft == FALSEcreates a realstd::fs::hard_linkfromdest's lock;soft != FALSEcreates a real symlink (#[cfg(unix)]viastd::os::unix::fs::symlink) pointing atdest's Amiga path, resolved viaResolveMode::ParentMustExistso the target need not exist yet (soft-link targets are "resolved lazily", per the NDK autodoc).nameitself also usesParentMustExistand fails withERROR_OBJECT_EXISTSif something's already there, matchingCreateDir's own convention.ReadLink(port, lock, path, buffer, size)(doslock.rs): resolveslock's directory + relativepath, callsstd::fs::read_linkon a real host symlink, and writes the raw target string back (not a re-derived Amiga path -- see the doc comment onDosState::read_linkfor why that's the most faithful thing to report).LockRecord/LockRecords/UnLockRecord/UnLockRecords(dosfile.rs): cheap stubs matching this runtime's existing no-real-concurrency posture (InitSemaphore/ObtainSemaphore,AddTask,ChangeMode).LockRecord/UnLockRecordvalidate the filehandle is currently open;LockRecords/UnLockRecordsalways report success (there's no single real-AmigaOS struct layout forrecArrayto validate against, and nothing to enforce either way).Judgment calls
Soft-link target resolve mode:
MakeLink'sdestAmiga path (for a soft link) is resolved viaResolveMode::ParentMustExist-- the closest existing primitive that turns an Amiga path into a host path without requiring the target to already exist, matching real AmigaOS's documented "resolved lazily" soft-link semantics.ST_SOFTLINKdetection inExamine/ExNext/ExAll-- deliberately cut.fill_fib(doslock.rs) anddosexall.rs's equivalent scan usestd::fs::metadata, which follows symlinks, so a soft link currently lists as whatever it resolves to (or fails to list at all if dangling). Detecting it would needsymlink_metadata+is_symlink()at everyfill_fibcall site -- cut for scope rather than touching that shared, already-tested machinery. Documented explicitly indoslock.rs's module docs.Windows symlink creation: gated
#[cfg(unix)]; on any other target,MakeLink(soft)reports a cleanERROR_ACTION_NOT_KNOWN(never a panic/hang) without attempting the host call at all, since Windows symlink creation needs elevated privileges/Developer Mode that can't be known in advance, and there's no dedicated real-AmigaOS error code for "this filesystem doesn't support soft links".ReadLink'sportargument: read (so the real register convention holds) but otherwise unused. RealReadLinkis normally called by DOS itself after a filesystem handler process's packet reply comes backERROR_IS_SOFT_LINK, andportidentifies that handler for a real multi-process AmigaOS to route back to. This runtime has no real per-filesystem handler process for ordinary volumes (same posture asdosdevproc.rs/dospkt.rs), andread_linkresolves everything directly fromself.locks+ the host filesystem -- so there's no handler forportto identify, and ignoring it changes nothing observable.Also not implemented (out of scope per the issue): the real AmigaOS "filesystem returns
ERROR_IS_SOFT_LINK, DOS callsReadLink, retries" protocol insideLock/Open/Examine. Host symlinks already transparently resolve via ordinary host filesystem calls, soLock/Open/Examine"just work" on a soft link without any extra code here.Test plan
DosStatemethod (doslock.rs/dosfile.rs): success paths, every documented failure path (ERROR_OBJECT_EXISTS,ERROR_INVALID_LOCK,ERROR_OBJECT_WRONG_TYPE, mapped I/O errors), plus#[cfg(unix)]/#[cfg(not(unix))]-gated symlink-specific cases.MakeLink-444,ReadLink-438,LockRecord-270,LockRecords-276,UnLockRecord-282,UnLockRecords-288).cargo test --workspace(1102 tests, up from 1080) passes;cargo clippy --all-targets -- -D warningsandcargo fmt --all --checkclean.Closing
Addresses #160. Fully implements
MakeLink/ReadLink/LockRecord/LockRecords/UnLockRecord/UnLockRecordsas scoped by the issue. Deliberately deferred (see judgment call #2 above):ST_SOFTLINKreporting inExamine/ExNext/ExAllfor a host symlink entry -- not implemented, documented indoslock.rs's module docs as a scope cut, not a bug.🤖 Generated with Claude Code