From 3f0d70cc4c88c35dd2ca9e11f8d4112a46fac825 Mon Sep 17 00:00:00 2001 From: Maschell Date: Fri, 7 Oct 2022 14:20:26 +0200 Subject: [PATCH] Only unmounts devices if they were mounted before --- src/main.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e90b0af..656f563 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -27,8 +27,9 @@ BackgroundThread *thread = nullptr; #define FTPIIU_ENABLED_STRING "enabled" #define SYSTEM_FILES_ALLOWED_STRING "systemFilesAllowed" -bool gFTPServerEnabled = true; -bool gSystemFilesAllowed = false; +bool gFTPServerEnabled = true; +bool gSystemFilesAllowed = false; +bool gMochaPathsWereMounted = false; MochaUtilsStatus MountWrapper(const char *mount, const char *dev, const char *mountTo) { auto res = Mocha_MountFS(mount, dev, mountTo); @@ -107,6 +108,7 @@ void startServer() { MountWrapper("storage_slc", "/dev/slc01", "/vol/storage_slc01"); Mocha_MountFS("storage_mlc", nullptr, "/vol/storage_mlc01"); Mocha_MountFS("storage_usb", nullptr, "/vol/storage_usb01"); + gMochaPathsWereMounted = true; } else { DEBUG_FUNCTION_LINE_ERR("Failed to init libmocha: %s [%d]", Mocha_GetStatusStr(res), res); } @@ -122,7 +124,7 @@ void startServer() { void stopServer() { BackgroundThread::destroyInstance(); - if (gSystemFilesAllowed) { + if (gMochaPathsWereMounted) { Mocha_UnmountFS("slccmpt01"); Mocha_UnmountFS("storage_odd_tickets"); Mocha_UnmountFS("storage_odd_updates"); @@ -131,6 +133,7 @@ void stopServer() { Mocha_UnmountFS("storage_slc"); Mocha_UnmountFS("storage_mlc"); Mocha_UnmountFS("storage_usb"); + gMochaPathsWereMounted = false; } DEBUG_FUNCTION_LINE("Unmount virtual paths");