Skip to content

Stream file transfers on mounted paths through exec (#27) - #32

Merged
wouterdebie merged 1 commit into
mainfrom
fix/27-copy-on-mounts
Oct 27, 2026
Merged

wouterdebie merged 1 commit into
mainfrom
fix/27-copy-on-mounts

Conversation

@wouterdebie

Copy link
Copy Markdown
Owner

Fixes #27.

Problem

apple/container's copy resolves paths against the container's rootfs from outside the container, beneath its mounts (apple/container#1873, still open, reproduced on 1.5.0 upstream). Reproduced here on 1.3.1 with the plain CLI:

container cp davit-repro:/data/inside.txt out.txt
Error: ... copy: path not found '/run/container/davit-repro/rootfs/data/inside.txt'
container cp in.txt davit-repro:/data/in.txt     # exit 0
container exec davit-repro ls /data              # inside.txt  lost+found   <- in.txt is not there

So in Davit:

  • Downloads from a mounted path fail (the report).
  • Uploads to a mounted path report success, but the file lands in the rootfs under the mountpoint and the container never sees it.
  • The volume browser mounts the volume at /volume in a helper container. Every download from it fails. Every upload is lost when the sheet closes, because the helper is deleted.

Fix

Paths under one of the container's mounts are streamed through exec instead. Everything else still uses the platform's copy.

  • Download: cat < "$1" writes to a pipe that is drained into the host file. The download counts as done at the pipe's EOF, not at process exit, because the daemon can still be relaying output after wait() returns. A failed download removes the partial file.
  • Upload: the host file is fed to cat > "$1" over a pipe in 1 MiB chunks. It isn't passed straight in as stdin because the daemon reads stdin with availableData, which would pull a whole plain file into its memory at once. If the script fails, it still reads stdin to EOF, so the feed can't block on a full pipe. F_SETNOSIGPIPE turns a vanished reader into EPIPE instead of a SIGPIPE that would kill the app.
  • Both run as root, like the platform copy does.

Verification

  • New selftest step "file browser on a mounted volume: upload -> download (File download fails for paths on mounted volumes (“copy: path not found” in rootfs) #27)". It round-trips 3 MiB + 123 bytes of random data through a mounted volume. It checks the container itself sees the upload (wc -c via exec, not just a listing), that the download matches byte for byte, and that a failed download leaves no partial file.
  • The full selftest passes against a live 1.3.1 platform.

🤖 Generated with Claude Code

apple/container's copy resolves paths against the container's rootfs from
outside the container, beneath its mounts (apple/container#1873). Copying out
of a mounted path fails with "path not found"; copying in reports success
while the file lands in the rootfs under the mountpoint, where the container
never sees it. In Davit that broke downloads from volumes and, worse, lost
uploads silently, including every upload in the volume browser, whose helper
container is deleted when the sheet closes.

Paths on a mount now go through exec instead: downloads `cat` the file to a
pipe drained into the host file (done at the pipe's EOF, not the exit), and
uploads feed the host file to `cat` in chunks over a pipe. Everything else
keeps using the platform's copy. Transfers run as root, like the copy does.

The selftest round-trips a multi-chunk random file through a mounted volume,
checks the container itself sees the upload, and checks a failed download
leaves no partial file.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@wouterdebie
wouterdebie merged commit f792455 into main Oct 27, 2026
1 check passed
@wouterdebie
wouterdebie deleted the fix/27-copy-on-mounts branch October 27, 2026 19:33
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.

File download fails for paths on mounted volumes (“copy: path not found” in rootfs)

1 participant