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:
co-authored by
Claude Opus 5
parent
4cc6393f5b
commit
e4f4bae762
@@ -0,0 +1,30 @@
|
||||
CosmOS
|
||||
> > copied
|
||||
finished
|
||||
> 1
|
||||
> it says: from drive one
|
||||
finished
|
||||
> 1
|
||||
> > greet.sbx 211
|
||||
hello.sbx 53
|
||||
Life.sbx 1396
|
||||
Snake.sbx 2164
|
||||
Keys.sbx 664
|
||||
Say.sbx 156
|
||||
Break.sbx 149
|
||||
Grid.sbx 543
|
||||
notes.txt 21
|
||||
Apps <dir>
|
||||
hi.script 121
|
||||
bad.script 45
|
||||
plain.script 24
|
||||
cross.script 280
|
||||
nonl.script 38
|
||||
outer.script 376
|
||||
inner.script 44
|
||||
loop.script 35
|
||||
crossed.txt 560
|
||||
18 files, 1 directory
|
||||
> halted
|
||||
Execution halted.
|
||||
[exit 0]
|
||||
@@ -9,6 +9,7 @@ Say.sbx 156
|
||||
Break.sbx 149
|
||||
Grid.sbx 543
|
||||
notes.txt 21
|
||||
Apps <dir>
|
||||
hi.script 121
|
||||
bad.script 45
|
||||
plain.script 24
|
||||
@@ -17,11 +18,12 @@ nonl.script 38
|
||||
outer.script 376
|
||||
inner.script 44
|
||||
loop.script 35
|
||||
17 files
|
||||
17 files, 1 directory
|
||||
> > other.txt 28
|
||||
notes <dir>
|
||||
2things <dir>
|
||||
1 file, 2 directories
|
||||
twoblocks.txt 560
|
||||
2 files, 2 directories
|
||||
> /notes> > /notes> > /notes> drive: this machine has no such drive
|
||||
/notes> halted
|
||||
Execution halted.
|
||||
|
||||
@@ -13,6 +13,7 @@ Say.sbx 156
|
||||
Break.sbx 149
|
||||
Grid.sbx 543
|
||||
notes.txt 21
|
||||
Apps <dir>
|
||||
hi.script 121
|
||||
bad.script 45
|
||||
plain.script 24
|
||||
@@ -21,7 +22,7 @@ nonl.script 38
|
||||
outer.script 376
|
||||
inner.script 44
|
||||
loop.script 35
|
||||
17 files
|
||||
17 files, 1 directory
|
||||
> halted
|
||||
Execution halted.
|
||||
[exit 0]
|
||||
|
||||
@@ -9,6 +9,7 @@ Say.sbx 156
|
||||
Break.sbx 149
|
||||
Grid.sbx 543
|
||||
notes.txt 21
|
||||
Apps <dir>
|
||||
hi.script 121
|
||||
bad.script 45
|
||||
plain.script 24
|
||||
@@ -17,7 +18,7 @@ nonl.script 38
|
||||
outer.script 376
|
||||
inner.script 44
|
||||
loop.script 35
|
||||
17 files
|
||||
17 files, 1 directory
|
||||
> load what?
|
||||
> no such file
|
||||
> not a program
|
||||
|
||||
@@ -8,6 +8,7 @@ Say.sbx 156
|
||||
Break.sbx 149
|
||||
Grid.sbx 543
|
||||
notes.txt 21
|
||||
Apps <dir>
|
||||
hi.script 121
|
||||
bad.script 45
|
||||
plain.script 24
|
||||
@@ -16,7 +17,7 @@ nonl.script 38
|
||||
outer.script 376
|
||||
inner.script 44
|
||||
loop.script 35
|
||||
17 files
|
||||
17 files, 1 directory
|
||||
> loaded, starting at 4000
|
||||
> it says: the disk took its time
|
||||
finished
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
drive 1
|
||||
Copy 1:/twoblocks.txt 0:/crossed.txt
|
||||
drive
|
||||
Say from drive one
|
||||
drive
|
||||
cd 0:/
|
||||
dir
|
||||
exit
|
||||
@@ -127,6 +127,23 @@ printf 'this lives on the other disk' > other.txt
|
||||
# A name that begins with a digit, because a drive prefix is a digit and a colon and the
|
||||
# colon is the whole of what tells them apart. Without it this would be drive 2.
|
||||
"$TOOL" mkdir "$DISKS/other.img" /2things >/dev/null
|
||||
# A file of more than one block, because a cross-drive copy of a single block never looks
|
||||
# the path up twice and so never meets the cache that used to hand back the right blocks of
|
||||
# the wrong disk.
|
||||
python3 -c "open('twoblocks.txt','w').write('the second disk, at length. ' * 20)"
|
||||
"$TOOL" put "$DISKS/other.img" twoblocks.txt >/dev/null
|
||||
|
||||
# ---- And a /Apps on drive 0, because that is where a system keeps its programs ----
|
||||
#
|
||||
# The apps above sit at the root of this image, which is where they were put before there
|
||||
# were directories and is fine for finding a program on the disk you are standing on. The
|
||||
# THIRD place the shell looks is /Apps on drive 0, and nothing could exercise it while this
|
||||
# disk had no such place.
|
||||
"$TOOL" mkdir "$DISKS/cosmos.img" /Apps >/dev/null
|
||||
"$ROOT/Assembler" -I "$ROOT/Programs/Libraries" -I "$ROOT/Programs/CosmOS/Source" \
|
||||
"$ROOT/Programs/CosmOS/Apps/Copy.asm" -o "$WORK/Copy.sbx" >/dev/null
|
||||
"$TOOL" put "$DISKS/cosmos.img" "$WORK/Copy.sbx" /Apps/Copy.sbx >/dev/null
|
||||
"$TOOL" put "$DISKS/cosmos.img" "$WORK/Say.sbx" /Apps/Say.sbx >/dev/null
|
||||
|
||||
# ---- Scripts, including the ones that are meant to go wrong ----
|
||||
#
|
||||
|
||||
@@ -824,6 +824,20 @@ cosmosDrives | CosmOS/Source/cosmos.asm | run | cosmosDri
|
||||
# system arrives, so it works for anything that takes one. A name beginning with a digit is
|
||||
# still a name: the colon is the whole of what tells the two apart.
|
||||
cosmosDrivePath | CosmOS/Source/cosmos.asm | run | cosmosDrivePath.in | 60000000 | disks/cosmos.img+disks/other.img
|
||||
# ---- Working across two disks ----
|
||||
#
|
||||
# The two things anybody expects of a second disk: copying to it, and running a program that
|
||||
# lives on one disk over files that live on the other.
|
||||
#
|
||||
# THE FILE IS MORE THAN ONE BLOCK ON PURPOSE. A copy of a single block looks its source up
|
||||
# once and never meets the cache that skips the walk - and skipping the walk skipped the
|
||||
# drive, so block one of every cross-drive copy came off the destination. One block worked
|
||||
# and two did not.
|
||||
#
|
||||
# Say lives in /Apps on drive 0 and is run while standing on drive 1, which is the third
|
||||
# place the shell looks. The drive it says afterwards is the check that fetching a program
|
||||
# did not move the person who ran it.
|
||||
cosmosCrossDisk | CosmOS/Source/cosmos.asm | run | cosmosCrossDisk.in | 90000000 | disks/cosmos.img+disks/other.img
|
||||
printDecimalTest | testPrograms/printDecimalTest.asm | xfail | - | -
|
||||
printDigitTest | testPrograms/printDigitTest.asm | xfail | - | -
|
||||
printHexTest | testPrograms/printHexTest.asm | xfail | - | -
|
||||
|
||||
Reference in New Issue
Block a user