core ctrl remount sd handling
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good
EIVE/eive-obsw/pipeline/pr-develop This commit looks good

This commit is contained in:
2022-05-11 17:02:57 +02:00
parent 625abcfd5b
commit 5a82fe93d9
5 changed files with 95 additions and 8 deletions

View File

@ -1235,18 +1235,42 @@ void CoreController::performWatchdogControlOperation() {
void CoreController::performMountedSdCardOperations() {
currMntPrefix = sdcMan->getCurrentMountPrefix();
if (doPerformMountedSdCardOps) {
if (performMountedSdCardOpsSwitch) {
bool sdCardMounted = false;
bool mountedReadOnly = false;
ReturnValue_t result = sdcMan->isSdCardMountedReadOnly(sdInfo.pref, mountedReadOnly);
if (result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "CoreController::performMountedSdCardOperations: Could not check "
"read-only mount state" << std::endl;
mountedReadOnly = true;
}
if (mountedReadOnly) {
int linuxErrno = 0;
result = sdcMan->performFsck(sdInfo.pref, true, linuxErrno);
if(result != HasReturnvaluesIF::RETURN_OK) {
sif::error << "CoreController::performMountedSdCardOperations: fsck command on SD Card "
<< sdInfo.prefChar << " failed with code " << linuxErrno << " | " << strerror(linuxErrno);
}
result = sdcMan->remountReadWrite(sdInfo.pref);
if(result == HasReturnvaluesIF::RETURN_OK) {
sif::warning << "CoreController::performMountedSdCardOperations: Remounted SD Card " <<
sdInfo.prefChar << " read-write";
} else {
sif::error << "CoreController::performMountedSdCardOperations: Remounting SD Card " <<
sdInfo.prefChar << " read-write failed";
}
}
sdCardMounted = sdcMan->isSdCardMounted(sdInfo.pref);
if (sdCardMounted) {
std::string path = currMntPrefix + "/" + CONF_FOLDER;
if (not std::filesystem::exists(path)) {
std::filesystem::create_directory(path);
if (sdCardMounted and not performOneShotSdCardOpsSwitch) {
std::ostringstream path;
path << currMntPrefix << "/" << CONF_FOLDER;
if (not std::filesystem::exists(path.str())) {
std::filesystem::create_directory(path.str());
}
initVersionFile();
initClockFromTimeFile();
performRebootFileHandling(false);
doPerformMountedSdCardOps = false;
performOneShotSdCardOpsSwitch = true;
}
}
timeFileHandler();

View File

@ -179,7 +179,8 @@ class CoreController : public ExtendedControllerBase {
} sdInfo;
RebootFile rebootFile = {};
std::string currMntPrefix;
bool doPerformMountedSdCardOps = true;
bool performOneShotSdCardOpsSwitch = true;
bool performMountedSdCardOpsSwitch = true;
/**
* Index 0: Chip 0 Copy 0