diff --git a/system/services/volume-manager/volume-manager.zig b/system/services/volume-manager/volume-manager.zig index 6d72f4e..c00dbe4 100644 --- a/system/services/volume-manager/volume-manager.zig +++ b/system/services/volume-manager/volume-manager.zig @@ -240,17 +240,21 @@ fn removeVolume() void { fs_failed = false; } -/// One poll tick: perform a due restart, else reconcile presence — mount a newly -/// present volume, unmount a departed one. +/// One poll tick. Removal is checked FIRST and supersedes a pending restart: if +/// the device is gone there is nothing to restart fat onto, and respawning it +/// against the dead channel would just churn until the crash cap. Only once the +/// device is confirmed present does a due restart fire. fn pollTick() void { - if (restart_pending and time.clock() >= restart_due_ns) { - restart_pending = false; - if (volume) |*v| spawnFilesystem(v); - return; - } if (volume) |v| { // Serving: watch for the specific device leaving (a pulled stick). - if (!isDevicePresent(v.storage_device_id)) removeVolume(); + if (!isDevicePresent(v.storage_device_id)) { + removeVolume(); + return; + } + if (restart_pending and time.clock() >= restart_due_ns) { + restart_pending = false; + spawnFilesystem(&volume.?); + } } else { // Idle: try to bring a present storage device up. bringUpVolume();