From 8617e5cee0bcbe3deed278bb871278c1fc8dc7fa Mon Sep 17 00:00:00 2001
From: Norman Feske <norman.feske@genode-labs.com>
Date: Mon, 26 Apr 2021 16:50:19 +0200
Subject: [PATCH] Sculpt: un-inspect failed USB storage

With this patch, the user is able to re-gain access to the inspect view
by toggling the inspect button of a file system unrelated to the failed
USB storage device.

Fixes #4090
---
 .../app/sculpt_manager/model/usb_storage_device.h   | 13 ++++++++++++-
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/repos/gems/src/app/sculpt_manager/model/usb_storage_device.h b/repos/gems/src/app/sculpt_manager/model/usb_storage_device.h
index 54829ee974..a8b860b3e1 100644
--- a/repos/gems/src/app/sculpt_manager/model/usb_storage_device.h
+++ b/repos/gems/src/app/sculpt_manager/model/usb_storage_device.h
@@ -87,7 +87,18 @@ struct Sculpt::Usb_storage_device : List_model<Usb_storage_device>::Element,
 	 * This method is called as response to a failed USB-block-driver
 	 * initialization.
 	 */
-	void discard_usb_block_drv() { Storage_device::state = FAILED; }
+	void discard_usb_block_drv()
+	{
+		Storage_device::state = FAILED;
+
+		/*
+		 * Exclude device from set of inspected file systems. This is needed
+		 * whenever the USB block driver fails sometime after an inspect button
+		 * is activated.
+		 */
+		for_each_partition([&] (Partition &partition) {
+			partition.file_system.inspected = false; });
+	}
 
 	bool discarded() const { return Storage_device::state == FAILED; }