Merge pull request 'fixes for file system' (#57) from mueller/fs-fixes into develop

Reviewed-on: #57
Reviewed-by: Jakob.Meier <meierj@irs.uni-stuttgart.de>
This commit is contained in:
Jakob Meier 2021-07-23 18:27:23 +02:00
commit 7bab6e6c15
4 changed files with 29 additions and 8 deletions

View File

@ -6,6 +6,8 @@
#include "../memory/scratchApi.h" #include "../memory/scratchApi.h"
#include "../memory/SdCardManager.h" #include "../memory/SdCardManager.h"
#include <filesystem>
CoreController::CoreController(object_id_t objectId): CoreController::CoreController(object_id_t objectId):
ExtendedControllerBase(objectId, objects::NO_OBJECT, 5) { ExtendedControllerBase(objectId, objects::NO_OBJECT, 5) {
} }
@ -27,10 +29,18 @@ LocalPoolDataSetBase* CoreController::getDataSetHandle(sid_t sid) {
} }
ReturnValue_t CoreController::initialize() { ReturnValue_t CoreController::initialize() {
ReturnValue_t result = sdCardInit(); ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
if(result != HasReturnvaluesIF::RETURN_OK) { try {
sif::warning << "CoreController::initialize: SD card init failed" << std::endl; result = sdCardInit();
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "CoreController::initialize: SD card init failed" << std::endl;
}
} }
catch(const std::filesystem::filesystem_error& e) {
sif::error << "CoreController::initialize: sdCardInit failed with exception " << e.what()
<< std::endl;
}
result = scratch::writeNumber(scratch::ALLOC_FAILURE_COUNT, 0); result = scratch::writeNumber(scratch::ALLOC_FAILURE_COUNT, 0);
if(result != HasReturnvaluesIF::RETURN_OK) { if(result != HasReturnvaluesIF::RETURN_OK) {
sif::warning << "CoreController::initialize: Setting up alloc failure " sif::warning << "CoreController::initialize: Setting up alloc failure "
@ -103,9 +113,14 @@ ReturnValue_t CoreController::sdCardSetup(SdCardManager& sdcMan,
return sdcMan.mountSdCard(sdCard); return sdcMan.mountSdCard(sdCard);
} }
else { else {
sif::info << "SD card " << sdString << " already on and mounted at " << if(std::filesystem::exists(mountString)) {
mountString << std::endl; sif::info << "SD card " << sdString << " already on and mounted at " <<
return SdCardManager::ALREADY_MOUNTED; mountString << std::endl;
return SdCardManager::ALREADY_MOUNTED;
}
sif::error << "SD card mounted but expected mount point " << mountString << " not found!"
<< std::endl;
return SdCardManager::MOUNT_ERROR;
} }
} }

View File

@ -218,6 +218,11 @@ ReturnValue_t SdCardManager::unmountSdCard(sd::SdCard sdCard) {
else if(sdCard == sd::SdCard::SLOT_1) { else if(sdCard == sd::SdCard::SLOT_1) {
mountPoint = SD_1_MOUNT_POINT; mountPoint = SD_1_MOUNT_POINT;
} }
if(not filesystem::exists(mountPoint)) {
sif::error << "SdCardManager::unmountSdCard: Default mount point " << mountPoint <<
"does not exist" << std::endl;
return UNMOUNT_ERROR;
}
if(filesystem::is_empty(mountPoint)) { if(filesystem::is_empty(mountPoint)) {
// The mount point will always exist, but if it is empty, that is strong hint that // The mount point will always exist, but if it is empty, that is strong hint that
// the SD card was not mounted properly. Still proceed with operation. // the SD card was not mounted properly. Still proceed with operation.

@ -1 +0,0 @@
Subproject commit ecc445afa7b027f2c7f059e941862119bd6f3764

View File

@ -3,9 +3,11 @@
#include "utility.h" #include "utility.h"
#include "fsfw/serviceinterface/ServiceInterface.h" #include "fsfw/serviceinterface/ServiceInterface.h"
#include <cstring>
void utility::handleSystemError(int retcode, std::string function) { void utility::handleSystemError(int retcode, std::string function) {
#if OBSW_VERBOSE_LEVEL >= 1 #if OBSW_VERBOSE_LEVEL >= 1
sif::warning << function << ": System call failed with code " << retcode; sif::warning << function << ": System call failed with code " << retcode << ": " <<
strerror(retcode) << std::endl;
#endif #endif
} }