filesys: write support for host directory mounts#188
Open
codewiz wants to merge 5 commits into
Open
Conversation
5376f5f to
786532e
Compare
HOSTFS volumes were read-only: every mutating packet failed with "disk is
write protected", which on a booting Workbench means requesters nobody asked
for. Implement the write half of the handler -- FINDOUTPUT/FINDUPDATE, WRITE,
SET_FILE_SIZE, CREATE_DIR, DELETE_OBJECT, RENAME_OBJECT, SET_DATE -- and report
the volume as validated.
A created leaf is taken literally so it lands under the name the guest chose,
which makes the guest the one picking a host path: names that would escape the
mount ("..", separators) or shadow our .uaem sidecars are refused.
[[filesys]] readonly = true keeps the old behaviour for a mount that should not
change.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
match_component returns the caller's spelling when the host path already exists, so the canonical case of a resolved parent depends on whether the host filesystem folds case. Assert the case-folded path instead of an exact spelling. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Host directory entries were shipped to the guest as raw UTF-8 and guest names were decoded as UTF-8, so any non-ASCII filename (Locale/Catalogs/ francais, espanol, ...) rendered garbled. Convert Latin-1<->UTF-8 at the packet boundary, matching amiberry: names with no Latin-1 spelling are hidden from directory listings rather than mangled. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
786532e to
d366fd5
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
Adds write support to HOSTFS directory mounts so AmigaOS can boot and operate against a writable host-backed “volume”, while introducing a [[filesys]] readonly option to preserve the old “write-protected disk” behavior when desired.
Changes:
- Implemented mutating DOS packets for HOSTFS (open-for-write, write, truncate, mkdir, delete, rename, set-date) plus improved host error mapping and filename encoding handling.
- Added
readonlyto config/serialization and updated example config docs. - Added/updated tests around create-path safety, Latin-1/UTF-8 mapping, and readonly refusal behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| src/video/launcher.rs | Emits GUI-managed [[filesys]] mounts into raw config (currently drops readonly on round-trip). |
| src/filesys.rs | Core HOSTFS write-path implementation, readonly enforcement, host error mapping, and new tests/helpers. |
| src/config.rs | Adds readonly to raw config schema and maps it into MountSpec. |
| src/amigaos/dos.rs | Adds additional AmigaDOS error constants used by new write paths. |
| copperline.example.toml | Updates documentation to describe writable mounts and the readonly option. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| let _ = std::fs::remove_file(uaem_path(&path)); | ||
| (DOSTRUE, 0) | ||
| } | ||
| Err(e) => (DOSFALSE, host_error(&e)), |
Comment on lines
+977
to
+978
| // Not in the GUI yet: mounts it exports stay writable. | ||
| readonly: None, |
Comment on lines
+402
to
+413
| match match_component(&dir, &comp) { | ||
| Some(existing) => rel.push(existing), | ||
| // The leaf may legitimately not exist yet, but a name the host | ||
| // would read as a path (or as "here"/"up") never becomes one. | ||
| None if create_leaf && i == last && is_creatable_name(&comp) => { | ||
| if !dir.is_dir() { | ||
| return None; | ||
| } | ||
| rel.push(&comp); | ||
| } | ||
| None => return None, | ||
| } |
Comment on lines
+1312
to
+1316
| let secs = AMIGA_EPOCH_OFFSET | ||
| + u64::from(days) * 86_400 | ||
| + u64::from(mins) * 60 | ||
| + u64::from(ticks) / 50; | ||
| let time = std::time::UNIX_EPOCH + std::time::Duration::from_secs(secs); |
SET_PROTECT/SET_COMMENT were accepted and discarded, so a DOpus copy onto a host mount silently lost the script bit and other non-default attributes. Write them to the .uaem sidecar in amiberry's exact format (deleting the sidecar when attributes return to default), and keep an existing sidecar's datestamp in step on SET_DATE. SET_PROTECT now also refuses on read-only mounts. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Delete ALL examines a directory and unlinks each entry as it goes. Our EXAMINE_NEXT indexed a freshly re-read, re-sorted host listing by position, so every unlink shifted the list and the entry that slid into the used slot was skipped. The guest never saw the whole directory, left stragglers, and then could not remove the non-empty directory. Track the cursor by the last name returned instead: the listing is sorted, so "the first name after the last one" is stable even as entries vanish. Cursor state is per directory lock, reset by EXAMINE_OBJECT and freed with the lock. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
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.
HOSTFS volumes were read-only: every mutating packet failed with "disk is write
protected". On a machine that boots from a
[[filesys]]mount (the A3000 andA4000 profiles have no other disk), that means Workbench throws write-protect
requesters during startup - which are invisible on a headless run and block the
shell with no feedback.
This implements the write half of the handler:
.uaem sidecar along)
SET_COMMENT and SET_PROTECT still accept and drop: the host has nowhere to keep
them. TODO to persist both to the .uaem sidecar we already read back.
Creating a file is the first time the guest picks a host path, so the leaf of a
create is taken literally (the file lands under the spelling the guest asked
for) and nothing else about it is allowed: "..", ".", path separators, NULs, and
any name ending in .uaem (which would shadow another file's attributes and
disappear from listings) are all refused. A test enumerates the escapes.
[[filesys]] readonly = truekeeps the old behaviour for a mount that shouldnot change.
How it was tested:
C:Delete ALLdirectory, with the host directory matching what the guest did at each step
Still untested:
🤖 Generated with Claude Code - ...and then hand edited