Fix silent disk overwrite of unrecognized Artemis disks
The generic block subsystem (blk_format_or_load_disk) auto-reformatted any disk lacking its own low-level 'STFR' header at attach time, before Artemis's Forth-level BLANK/LithosAnanke/Unrecognized classification ever ran -- so ART-HALT-UNRECOG's "Disk preserved" message was false. Split detection from commit: an unrecognized/blank disk is now left PROVISIONAL (geometry computed in memory only, all writes refused) until explicitly confirmed via the new blk_subsys_confirm_format() / BLK-CONFIRM-FORMAT primitive. Artemis calls it from ART-FORMAT and ART-RESUME, never from ART-HALT-UNRECOG. Verified on amd64/aarch64/riscv64: parity intact (identical dict_hash), normal recognized-disk resume + persist-read unaffected, and a regenerated disk/artemis-unrecognized-test.img (the old copy had itself been silently corrupted by this exact bug) now stays byte-for-byte identical across a halted boot on amd64 and riscv64. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
cc6c8c43f3
commit
148c4aa12c
@@ -279,6 +279,17 @@ void block_word_update(VM *vm) {
|
||||
blk_update((uint32_t) blk);
|
||||
}
|
||||
|
||||
/* BLK-CONFIRM-FORMAT ( lbn -- ) : commit the low-level disk container
|
||||
* format for the slot owning lbn. Must be called by the disk's owner
|
||||
* (e.g. Artemis) only after classifying disk content as safe to touch —
|
||||
* never on the path that halts for unrecognized content. Until this is
|
||||
* called, all writes to that disk slot are refused by the block layer. */
|
||||
void block_word_confirm_format(VM *vm) {
|
||||
if (vm->dsp < 0) { vm->error = 1; return; }
|
||||
cell_t blk = vm_pop(vm);
|
||||
if (blk_subsys_confirm_format((uint32_t) blk) != BLK_OK) { vm->error = 1; return; }
|
||||
}
|
||||
|
||||
/* SAVE-BUFFERS ( -- ) : sync and write all dirty blocks */
|
||||
void block_word_save_buffers(VM *vm) {
|
||||
blk_vm_flush_all(vm);
|
||||
@@ -457,6 +468,7 @@ void register_block_words(VM *vm) {
|
||||
register_word(vm, "BLOCK", block_word_block);
|
||||
register_word(vm, "BUFFER", block_word_buffer);
|
||||
register_word(vm, "UPDATE", block_word_update);
|
||||
register_word(vm, "BLK-CONFIRM-FORMAT", block_word_confirm_format);
|
||||
register_word(vm, "SAVE-BUFFERS", block_word_save_buffers);
|
||||
register_word(vm, "EMPTY-BUFFERS", block_word_empty_buffers);
|
||||
register_word(vm, "FLUSH", block_word_flush);
|
||||
|
||||
Reference in New Issue
Block a user