Skip to content

filesys: write support for host directory mounts#188

Open
codewiz wants to merge 5 commits into
LinuxJedi:mainfrom
codewiz:feat/filesys-write
Open

filesys: write support for host directory mounts#188
codewiz wants to merge 5 commits into
LinuxJedi:mainfrom
codewiz:feat/filesys-write

Conversation

@codewiz

@codewiz codewiz commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

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 and
A4000 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:

  • ACTION_FINDOUTPUT / ACTION_FINDUPDATE - create/truncate, and open for update
  • ACTION_WRITE, ACTION_SET_FILE_SIZE (clamping the file position on truncate)
  • ACTION_CREATE_DIR, ACTION_DELETE_OBJECT, ACTION_RENAME_OBJECT (both carry the
    .uaem sidecar along)
  • ACTION_SET_DATE - stamps the host mtime
  • InfoData reports the volume validated, so C:Info says Read/Write

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 = true keeps the old behaviour for a mount that should
not change.

How it was tested:

  • Boot my OS 3.x Workbench
  • Copy the whole partition to a second HOSTFS mount
  • Compare the old and new dir
  • Delete the copy recursively with C:Delete ALL
  • Various shell commands: Makedir, Copy, Rename, Delete, Delete ALL on a
    directory, with the host directory matching what the guest did at each step
  • Check that readonly mount refuses writes while reporting Read Only.

Still untested:

  • Error paths against a real host failure (permission denied, disk full)
  • SET_FILE_SIZE from an application rather than a synthetic call

🤖 Generated with Claude Code - ...and then hand edited

@codewiz codewiz force-pushed the feat/filesys-write branch from 5376f5f to 786532e Compare July 15, 2026 01:14
codewiz and others added 3 commits July 15, 2026 19:25
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>
@codewiz codewiz force-pushed the feat/filesys-write branch from 786532e to d366fd5 Compare July 15, 2026 10:32
@LinuxJedi LinuxJedi requested a review from Copilot July 15, 2026 10:43
@codewiz codewiz marked this pull request as ready for review July 15, 2026 10:43

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 readonly to 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.

Comment thread src/filesys.rs
let _ = std::fs::remove_file(uaem_path(&path));
(DOSTRUE, 0)
}
Err(e) => (DOSFALSE, host_error(&e)),
Comment thread src/video/launcher.rs
Comment on lines +977 to +978
// Not in the GUI yet: mounts it exports stay writable.
readonly: None,
Comment thread src/filesys.rs
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 thread src/filesys.rs
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);
codewiz and others added 2 commits July 15, 2026 21:51
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>
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.

2 participants