From f34c1bed330dab85d4a8f0dae22cb793634c5d68 Mon Sep 17 00:00:00 2001 From: Andrea Fiorencis Date: Thu, 19 Mar 2026 09:29:12 +0100 Subject: [PATCH 1/2] Aggiunto comando unplug base (non ancora funzionante) --- simulatore.html | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/simulatore.html b/simulatore.html index babad7e..5013661 100644 --- a/simulatore.html +++ b/simulatore.html @@ -3415,6 +3415,11 @@ $ rm /mnt/verifica.txt if((mdOp==="--stop-rebuild"&&mdArray==="/dev/md0")||(t[1]==="--stop-rebuild"&&t[2]==="/dev/md0")){if(!state.rebuild.active)return termPrint("mdadm: nessun rebuild attivo.","warn");stopRebuild(false);termPrint("mdadm: rebuild interrotto (didattica).","warn");if(state.scenario.name==="rebuild_interrupted"&&!state.scenario.checkpoints.stopped){state.scenario.checkpoints.stopped=true;addScore(6,"(scenario) rebuild interrotto.");}render();scenarioCheck();return;} return termPrint("mdadm: opzione non supportata. Digita 'help'.","err"); } + if(c0==="unplug"){ + let diskId=t[1]; + if(diskId&&diskId.state===DiskState.SPARE){diskId.state=DiskState.REMOVED; return;} + return termPrint("unplug: specifica il disco spare da rimuovere (simulazione). Esempio: unplug /dev/sdX","err"); + } if(c0==="lsblk"){termPrint(lsblk(),"dim");scenarioActionDiag();render();scenarioCheck();return;} if(c0==="fdisk"&&t[1]==="-l"){termPrint(fdiskL(),"dim");scenarioActionDiag();render();scenarioCheck();return;} if(c0==="blkid"){termPrint(blkid(),"dim");scenarioActionDiag();render();scenarioCheck();return;} -- 2.49.1 From 12f5790afcd42966907173e1aad9fcd1d675fcd1 Mon Sep 17 00:00:00 2001 From: Andrea Fiorencis Date: Thu, 19 Mar 2026 09:44:35 +0100 Subject: [PATCH 2/2] Fix comando unplug --- simulatore.html | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/simulatore.html b/simulatore.html index 5013661..0b8e90c 100644 --- a/simulatore.html +++ b/simulatore.html @@ -3416,9 +3416,22 @@ $ rm /mnt/verifica.txt return termPrint("mdadm: opzione non supportata. Digita 'help'.","err"); } if(c0==="unplug"){ - let diskId=t[1]; - if(diskId&&diskId.state===DiskState.SPARE){diskId.state=DiskState.REMOVED; return;} - return termPrint("unplug: specifica il disco spare da rimuovere (simulazione). Esempio: unplug /dev/sdX","err"); + const dev=t[1]; + if(!dev){ + return termPrint("unplug: specifica il disco spare da rimuovere (simulazione). Esempio: unplug /dev/sdX","err"); + } + const spareIndex=state.spares.findIndex(d=>d.dev===dev); + if(spareIndex===-1){ + return termPrint(`unplug: ${dev} non รจ uno spare o non esiste.`,`err`); + } + const spare=state.spares[spareIndex]; + spare.state=DiskState.REMOVED; + state.spares.splice(spareIndex,1); + pushDmesg("warn",`${dev}: unplugged dallo spare`); + termPrint(`unplug: ${dev} rimosso.`,`ok`); + render(); + scenarioCheck(); + return; } if(c0==="lsblk"){termPrint(lsblk(),"dim");scenarioActionDiag();render();scenarioCheck();return;} if(c0==="fdisk"&&t[1]==="-l"){termPrint(fdiskL(),"dim");scenarioActionDiag();render();scenarioCheck();return;} -- 2.49.1