#pragma once #include "basic_state.hpp" struct ActivatingState : public BasicStateT { static std::string_view stateName() { return "ActivatingState"; } ActivatingState(interfaces::MountPointStateMachine& machine); std::unique_ptr onEnter() override; std::unique_ptr handleEvent(UdevStateChangeEvent event); std::unique_ptr handleEvent(SubprocessStoppedEvent event); template [[noreturn]] std::unique_ptr handleEvent(AnyEvent event) { LogMsg(Logger::Error, "Invalid event: ", event.eventName); throw sdbusplus::exception::SdBusError(EBUSY, "Resource is busy"); } private : std::unique_ptr activateProxyMode(); std::unique_ptr activateLegacyMode(); std::unique_ptr mountSmbShare(); std::unique_ptr mountHttpsShare(); static std::unique_ptr spawnNbdKit(interfaces::MountPointStateMachine& machine, std::unique_ptr&& secret, const std::vector& params); static std::unique_ptr spawnNbdKit(interfaces::MountPointStateMachine& machine, const fs::path& file); static std::unique_ptr spawnNbdKit(interfaces::MountPointStateMachine& machine, const std::string& url); static bool checkUrl(const std::string& urlScheme, const std::string& imageUrl); static bool getImagePathFromUrl(const std::string& urlScheme, const std::string& imageUrl, std::string* imagePath); static bool isHttpsUrl(const std::string& imageUrl); static bool getImagePathFromHttpsUrl(const std::string& imageUrl, std::string* imagePath); static bool isCifsUrl(const std::string& imageUrl); static bool getImagePathFromCifsUrl(const std::string& imageUrl, std::string* imagePath); static fs::path getImagePath(const std::string& imageUrl); std::unique_ptr process; std::unique_ptr gadget; };