core ctrl remount sd handling
This commit is contained in:
@ -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();
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user