Reading the disk
You can read files from a run’s disk without touching the run.
machine fs reads the filesystem on the disk as a
checkpoint saved it, so it never changes how the machine executes.
1 | machine fs ls app /var/log --at ^done |
Every read names its checkpoint with --at, as a point: ^booted for a
checkpoint by name, or '#4200' for the checkpoint at an entry. There is no
default, because machine fs does not show the running machine, and a
listing that did not say which checkpoint it came from would look as if it
did.
1 | machine fs ls app /tmp |
A point with no checkpoint at it is refused, and the refusal names the checkpoint before it.
Unsynced writes
Data the machine has not synced to its disk is not visible. A file a program wrote a moment before the checkpoint can be missing, short or empty, because the machine still holds it in memory.
To read the files as they are, sync in the machine, take a checkpoint, and read
at now:
1 | machine exec app run -- sync |
now names the checkpoint at the run’s current point. It names that
checkpoint only until the machine runs again; after that, name the checkpoint
itself.
A run created with --fs-sync writes every change of a file to the disk as it
is made, and one created with --fs-dirsync does so for every change of a
directory. Both are options of machine create
and are off by default.
To read the files of the machine as it runs, execute a command in it:
machine exec app run -- ls /tmp. The command reads
the files as they are now, synced or not, and the run records it.
At the control prompt the command is
/fs, and the point follows the word at:
1 | /fs ls /var/log at ^done |
From Python, run.fs.ls("/var/log", at="^done") lists a directory,
run.fs.cat("/var/log/app.log", at="^done") returns a file’s bytes, and
run.fs.cp("/var/log", "./logs", at="^done", recursive=True) copies the directory out.