Work across two disks: copy between them, and run a program from one on

files from the other

Two things anybody expects of a second disk, and each needed something
different.

COPYING NEEDED TWO THINGS TO REMEMBER A DRIVE.

The write stream is the only thing here that lives across service calls, so
it is the only thing whose drive can change underneath it: every
osFileBlock names its source path again and goes back to the source drive,
and then osFileWrite has to come home. It records the drive it was opened
on and returns there.

And the file lookup CACHE. It keeps the last path resolved so a reader
walking a file does not re-walk the directory for every block - and
skipping the walk skipped the drive the path named, so block one of a
cross-drive copy read the source's block numbers off the DESTINATION disk.
It only showed on files of more than one block, because a file of one is
never looked up twice. One block worked and two did not, which is a
suspicious enough shape to have suspected sooner.

RUNNING A PROGRAM FROM ELSEWHERE NEEDED A THIRD PLACE TO LOOK, and two
restorations.

The shell tried where you are and /Apps on the disk you are on. It now
tries /Apps on drive 0 as well, which is what makes the system's programs
work from a disk of your own - one with your files on it and no system,
which is most of the point of having a second disk.

The drive goes back after the load, because by then the program is in
memory and the blocks it came from mean nothing; and again when it exits,
because a program that copies between disks moves the drive as its own
paths need to and being left wherever it finished is not what was asked
for. Copy 1:/a 0:/b now leaves you exactly where you were.

The fixture disk grew an /Apps, because it kept its programs at the root
and so could not exercise the third place at all.

Two hours of the debugging above were spent on a stale disk image. The
machine boots the system that is ON the image, so a rebuilt cosmos.bin
means nothing until the image is rebuilt too - and the trace said my new
code never ran, which was true. Third time this project has been misled by
one.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01E2JrLzFvuFX9fgi1LDRjrW
This commit is contained in:
Anachronaut
2026-08-31 16:14:53 -04:00
co-authored by Claude Opus 5
parent 4cc6393f5b
commit e4f4bae762
12 changed files with 223 additions and 21 deletions
+22
View File
@@ -2932,6 +2932,16 @@ sbfsStreamNoTemp:
SETD.2 SbfsFileStart
CALL sbfsSetWord
; ---- And which disk all of that is on ----
;
; A write stream is the one thing here that lives across service calls, so it is the one
; thing that can have the drive changed underneath it. Copying between two disks is exactly
; that: every osFileBlock re-resolves the SOURCE path and goes to its drive, and then
; osFileWrite has to come back here. The path was walked above, so the drive is right now.
INA 0x24
SETD.0 SbfsStreamDrive
STA.0
INIA 0x01
SETD.0 SbfsStreamOpen
STA.0
@@ -2941,6 +2951,13 @@ sbfsStreamNoTemp:
ADD
RET
; Back to the disk the open stream belongs to, whatever has been read in between.
sbfsStreamHere:
SETD.0 SbfsStreamDrive
LDA.0
CALL sbfsUse
RET
sbfsStreamNo:
RSTA
INIB 0d1
@@ -2954,6 +2971,7 @@ sbfsStreamWrite:
SETD.0 SbfsStreamOpen
LDA.0
BRA sbfsStreamNo
CALL sbfsStreamHere
; Where the file is and how big it is, said again rather than looked up: all three were
; settled when the temporary was made, and everything since has been describing whatever
@@ -2980,6 +2998,7 @@ sbfsStreamFetch:
SETD.0 SbfsStreamOpen
LDA.0
BRA sbfsStreamNo
CALL sbfsStreamHere
SETD.0 SbfsStreamTo
STD.1.0
@@ -3016,6 +3035,7 @@ sbfsStreamDone:
SETD.0 SbfsStreamOpen
LDA.0
BRA sbfsStreamNo
CALL sbfsStreamHere
; What it really came to, put aside before anything walks the disk.
SETD.0 SbfsStreamNewBlocks
@@ -3639,6 +3659,8 @@ SbfsTempName:
"sbfs.part"
; ---- What a file being written a block at a time keeps ----
SbfsStreamDrive:
0x00
SbfsStreamOpen:
0x00
SbfsStreamPath: