summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/state/initial_state.hpp3
-rw-r--r--src/system.hpp28
2 files changed, 29 insertions, 2 deletions
diff --git a/src/state/initial_state.hpp b/src/state/initial_state.hpp
index 0529d9f..a1efeef 100644
--- a/src/state/initial_state.hpp
+++ b/src/state/initial_state.hpp
@@ -35,6 +35,9 @@ struct InitialState : public BasicStateT<InitialState>
addProcessInterface(event);
addServiceInterface(event, isLegacy);
+ // Workaround for HSD18020136609. Details in system.hpp.
+ UdevGadget::forceUdevChange();
+
return std::make_unique<ReadyState>(machine);
}
diff --git a/src/system.hpp b/src/system.hpp
index cd16802..22f9717 100644
--- a/src/system.hpp
+++ b/src/system.hpp
@@ -476,9 +476,9 @@ class Process : public std::enable_shared_from_this<Process>
const NBDDevice& dev;
};
-struct UsbGadget
+class FsHelper
{
- private:
+ protected:
static bool echoToFile(const fs::path& fname, const std::string& content)
{
std::ofstream fileWriter;
@@ -489,7 +489,11 @@ struct UsbGadget
LogMsg(Logger::Debug, "echo ", content, " > ", fname);
return true;
}
+};
+struct UsbGadget : private FsHelper
+{
+ private:
static const std::string getGadgetDirPrefix()
{
const std::string gadgetDirPrefix =
@@ -627,3 +631,23 @@ struct UsbGadget
return true;
}
};
+
+class UdevGadget : private FsHelper
+{
+ public:
+ // Workaround for HSD18020136609: Can not mount image using Virtual media
+ // and CIFS protocol
+ // This force-triggers udev change events for nbd[0-3] devices, which
+ // prevents from disconnection on first mount event after reboot. The actual
+ // rootcause is related with kernel changes that occured between 5.10.67 and
+ // 5.14.11. This lead will continue to be investigated in order to provide
+ // proper fix.
+ static void forceUdevChange()
+ {
+ std::string changeStr = "change";
+ echoToFile("/sys/block/nbd0/uevent", changeStr);
+ echoToFile("/sys/block/nbd1/uevent", changeStr);
+ echoToFile("/sys/block/nbd2/uevent", changeStr);
+ echoToFile("/sys/block/nbd3/uevent", changeStr);
+ }
+};