Core Controller Remount SD Handling #253
@ -141,6 +141,7 @@ ReturnValue_t CoreController::initializeAfterTaskCreation() {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
sdInfo.pref = sdcMan->getPreferredSdCard();
|
||||
sdcMan->setActiveSdCard(sdInfo.pref);
|
||||
currMntPrefix = sdcMan->getCurrentMountPrefix();
|
||||
if (BLOCKING_SD_INIT) {
|
||||
ReturnValue_t result = initSdCardBlocking();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK and result != SdCardManager::ALREADY_MOUNTED) {
|
||||
@ -1222,7 +1223,7 @@ void CoreController::performWatchdogControlOperation() {
|
||||
}
|
||||
|
||||
void CoreController::performMountedSdCardOperations() {
|
||||
auto mountedSdCardOp = [&](bool& mntSwitch, sd::SdCard sdCard, std::string mntPoint) {
|
||||
auto mountedSdCardOp = [&](bool &mntSwitch, sd::SdCard sdCard, std::string mntPoint) {
|
||||
if (mntSwitch) {
|
||||
bool sdCardMounted = sdcMan->isSdCardMounted(sdCard);
|
||||
if (sdCardMounted and not performOneShotSdCardOpsSwitch) {
|
||||
@ -1239,7 +1240,7 @@ void CoreController::performMountedSdCardOperations() {
|
||||
mntSwitch = false;
|
||||
}
|
||||
};
|
||||
if(sdInfo.pref == sd::SdCard::SLOT_1) {
|
||||
if (sdInfo.pref == sd::SdCard::SLOT_1) {
|
||||
mountedSdCardOp(sdInfo.mountSwitch.second, sd::SdCard::SLOT_1, SdCardManager::SD_1_MOUNT_POINT);
|
||||
mountedSdCardOp(sdInfo.mountSwitch.first, sd::SdCard::SLOT_0, SdCardManager::SD_0_MOUNT_POINT);
|
||||
} else {
|
||||
|
@ -487,9 +487,9 @@ bool SdCardManager::isSdCardMounted(sd::SdCard sdCard) {
|
||||
ReturnValue_t SdCardManager::isSdCardMountedReadOnly(sd::SdCard sdcard, bool& readOnly) {
|
||||
std::ostringstream command;
|
||||
if (sdcard == sd::SdCard::SLOT_0) {
|
||||
command << "grep -q \"" << SD_0_DEV_NAME << " vfat ro, \" /proc/mounts";
|
||||
command << "grep -q '" << SD_0_MOUNT_POINT << " vfat ro,' /proc/mounts";
|
||||
} else {
|
||||
command << "grep -q \"" << SD_1_DEV_NAME << " vfat ro, \" /proc/mounts";
|
||||
command << "grep -q '" << SD_1_MOUNT_POINT << " vfat ro,' /proc/mounts";
|
||||
}
|
||||
ReturnValue_t result = cmdExecutor.load(command.str(), true, false);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
@ -497,6 +497,11 @@ ReturnValue_t SdCardManager::isSdCardMountedReadOnly(sd::SdCard sdcard, bool& re
|
||||
}
|
||||
result = cmdExecutor.execute();
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
int exitStatus = cmdExecutor.getLastError();
|
||||
if (exitStatus == 1) {
|
||||
readOnly = false;
|
||||
return RETURN_OK;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
auto& readVec = cmdExecutor.getReadVector();
|
||||
@ -540,10 +545,6 @@ ReturnValue_t SdCardManager::performFsck(sd::SdCard sdcard, bool printOutput, in
|
||||
return result;
|
||||
}
|
||||
|
||||
void SdCardManager::setActiveSdCard(sd::SdCard sdCard) {
|
||||
sdInfo.active = sdCard;
|
||||
}
|
||||
void SdCardManager::setActiveSdCard(sd::SdCard sdCard) { sdInfo.active = sdCard; }
|
||||
|
||||
sd::SdCard SdCardManager::getActiveSdCard() const {
|
||||
return sdInfo.active;
|
||||
}
|
||||
sd::SdCard SdCardManager::getActiveSdCard() const { return sdInfo.active; }
|
||||
|
@ -13,6 +13,7 @@ class SdCardMountedIF {
|
||||
virtual sd::SdCard getPreferredSdCard() const = 0;
|
||||
virtual void setActiveSdCard(sd::SdCard sdCard) = 0;
|
||||
virtual sd::SdCard getActiveSdCard() const = 0;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user