volume-manager: partition parser takes a SectorReader; identity is a tagged Identity (S1)

The identity ladder's flag-day — no behavior change. partition.firstVolume stops
taking one preloaded block-0 slice and takes a SectorReader (a read-one-sector
fn), so it can reach GPT metadata at LBA 1 and each partition's VBR on demand
(the next commits). The u64 identity becomes Identity{rung,key,label}: key is the
id (the mount path derives from it), label is display metadata (empty at rung 4).
Identity equality is id-only (rung+key) — the label never enters it. Only rung-4
(MBR sig+index / bare-FAT index 0) is produced, byte-identical to before; the
four host tests port to a RAM-disk reader, and fat-mount/volume-probe/
volume-removal stay green.
This commit is contained in:
Daniel Samson
2026-08-09 23:06:23 +01:00
parent 4f9196c03e
commit c81120ef0f
2 changed files with 125 additions and 38 deletions
@@ -40,7 +40,7 @@ const Volume = struct {
storage_device_id: u64, // the device-manager id this volume's provider serves
base_lba: u64,
block_count: u64,
identity: u64,
identity: partition.Identity,
id: u64,
filesystem_pid: u32 = 0,
};
@@ -169,7 +169,7 @@ fn spawnFilesystem(v: *Volume) void {
}
v.filesystem_pid = pid;
fs_spawn_ns = time.clock();
std.log.info("volume 0x{x} -> {s} (pid {d}), lba {d}, {d} blocks", .{ v.identity, filesystem_binary, pid, v.base_lba, v.block_count });
std.log.info("volume 0x{x} -> {s} (pid {d}), lba {d}, {d} blocks", .{ v.identity.key, filesystem_binary, pid, v.base_lba, v.block_count });
}
/// Schedule a fat restart after backoff; the poll loop performs it once due.
@@ -204,12 +204,19 @@ fn bringUpVolume() void {
_ = ipc.close(device.endpoint);
return;
};
if (!device.read(0, 1, bounce.physical)) {
_ = ipc.close(device.endpoint);
return;
}
const sector: [*]const u8 = @ptrFromInt(bounce.virtual);
const found = partition.firstVolume(sector[0..512], geometry.block_count) orelse {
const ProbeReader = struct {
device: block.Device,
fn readSector(context: *anyopaque, lba: u64, buffer: *[partition.sector_bytes]u8) bool {
const self: *@This() = @ptrCast(@alignCast(context));
if (!self.device.read(lba, 1, bounce.physical)) return false;
const src: [*]const u8 = @ptrFromInt(bounce.virtual);
@memcpy(buffer, src[0..partition.sector_bytes]);
return true;
}
};
var probe = ProbeReader{ .device = device };
const reader = partition.SectorReader{ .context = &probe, .readFn = ProbeReader.readSector };
const found = partition.firstVolume(reader, geometry.block_count) orelse {
if (!logged_no_volume) {
_ = logging.write("volume-manager: storage present but no recognizable volume\n");
logged_no_volume = true;