D4: the machine makes directories too
mkdir and rmdir are the machine's own now, and a file goes where its path says rather than always in the root. A disk can be organised without the host tool touching it. Everything below the surface works in terms of a directory and a name rather than a path. sbfsWalkParent splits the last name off, walks the rest, and hands back the two - and the separator stays on the end of the head, which is what makes one rule cover every kind of path: "/x" leaves "/", which is the root; "x" leaves nothing, which is where the machine already is; and "A/x" leaves "A/", which is neither and needs no special case to say so. Saving works in those two as well, and had to. The careful order a save uses - make a temporary, write it, delete the original, rename the temporary - only works if the temporary is made in the SAME directory as the file, because the rename at the end changes a name and does not move anything. Renaming to a path naming a different directory is refused for that reason, rather than quietly being a lie the disk goes along with. Three things this cost, all found by running it: mkdir Apps/Deep made /Apps/Apps. The leaf was worked out into SbfsWanted and then the head was walked - and walking goes through sbfsPathNext, which puts every name it meets into SbfsWanted on the way past. The head's last name landed exactly where the leaf was. It has somewhere of its own now. rmdir took a directory with something still in it, which is the one failure the whole design is arranged to prevent. Looking for children clobbered DP2 and rebuilt it from the buffer and the entry count with the subtraction the wrong way round, so the pointer walked off the end of the block and found nothing. The comparison goes through a CALL now, like the two beside it, and DP2 comes back on the entry because a RET puts it there. SplitDisk's "in use but not reachable from the root" line is what caught it. Refusing a name longer than twenty two used to read the twenty third character of a shorter one, which is somebody else's string. It is measured now. Tests/agree.sh is new and is the gate this rung was for: the same disk built twice, once with SplitDisk and once with CosmOS, compared byte for byte. The two share no code and only a written specification, and every field one writes and the other only reads is checked there and nowhere else - which entry a thing lands in, which block, what a directory's unused fields hold, the version, the free count. It caught a wrong parent immediately when that was broken on purpose. 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
36ce9f6ccf
commit
da91a36d92
@@ -343,6 +343,21 @@ cosmosTree | CosmOS/Source/cosmos.asm | run | cosmosTre
|
||||
# hold no blocks and must therefore be in nobody's way when a run of free ones is wanted.
|
||||
# The listing afterwards says where it landed and how big it is.
|
||||
cosmosTreeWrite | CosmOS/Source/cosmos.asm | run | cosmosTreeWrite.in | - | disks/treewrite.img
|
||||
# The machine building its own tree. It starts with a blank version one disk and makes
|
||||
# every directory on it, which is the half of the filesystem the machine could only read
|
||||
# until now.
|
||||
#
|
||||
# The refusals are most of the test. rmdir will not take a file and delete will not take a
|
||||
# directory, so neither can be the one that removed more than was asked for; a directory
|
||||
# with anything in it is refused outright, because a parent is an entry INDEX and a freed
|
||||
# index goes to the next thing created - the children would turn up inside whatever took
|
||||
# its place, with nothing pointing downward to find them by. A name already taken in that
|
||||
# directory is refused, and the same name in a different directory is not, which is the
|
||||
# whole point of the exercise.
|
||||
#
|
||||
# The last dir is there to show the disk still adds up: every entry made and unmade, and
|
||||
# nothing left over.
|
||||
cosmosBuild | CosmOS/Source/cosmos.asm | run | cosmosBuild.in | - | disks/build.img
|
||||
# The working directory. cd moves the machine, the prompt says where it is once that is
|
||||
# not the root, and dir lists one directory rather than the whole disk.
|
||||
#
|
||||
|
||||
Reference in New Issue
Block a user