M module-vfs/board/cross/free_rtos_custom/portable/vfs.cpp => module-vfs/board/cross/free_rtos_custom/portable/vfs.cpp +3 -2
@@ 25,6 25,9 @@ void vfs::Init()
bootConfig.os_root_path = purefs::dir::getRootDiskPath();
+ chnNotifier.onFileSystemInitialized();
+ initDone = true;
+
if (loadBootConfig(getCurrentBootJSON())) {
LOG_INFO("vfs::Init osType %s root:%s", bootConfig.os_type.c_str(), bootConfig.os_root_path.c_str());
if (ff_chdir(bootConfig.os_root_path.c_str()) != 0) {
@@ 48,6 51,4 @@ void vfs::Init()
else {
LOG_INFO("vfs::Init looks like %s exists", userDiskPath.c_str());
}
- chnNotifier.onFileSystemInitialized();
- initDone = true;
}
M module-vfs/include/user/deprecated/vfs.hpp => module-vfs/include/user/deprecated/vfs.hpp +3 -3
@@ 46,7 46,7 @@ namespace purefs
inline constexpr auto os_image = "imagename";
inline constexpr auto os_version = "version";
inline constexpr auto version_major = "major";
- inline constexpr auto version_inor = "minor";
+ inline constexpr auto version_minor = "minor";
inline constexpr auto version_patch = "patch";
inline constexpr auto version_string = "string";
inline constexpr auto timestamp = "timestamp";
@@ 61,8 61,8 @@ namespace purefs
struct BootConfig
{
- std::string os_image;
- std::string os_type;
+ std::string os_image = "boot.bin";
+ std::string os_type = "current";
std::string os_version;
std::string bootloader_verion;
std::string timestamp;
M module-vfs/src/deprecated/vfs-utils.cpp => module-vfs/src/deprecated/vfs-utils.cpp +4 -1
@@ 113,7 113,7 @@ std::string vfs::loadFileAsString(const fs::path &fileToLoad)
bool vfs::replaceWithString(const fs::path &fileToModify, const std::string &stringToWrite)
{
auto lamb = [](vfs::FILE *stream) { ::vfs.fclose(stream); };
- std::unique_ptr<vfs::FILE, decltype(lamb)> fp(fopen(fileToModify.c_str(), "w"), lamb);
+ std::unique_ptr<vfs::FILE, decltype(lamb)> fp(::vfs.fopen(fileToModify.c_str(), "w"), lamb);
if (fp.get() != nullptr) {
size_t dataWritten = fprintf(fp.get(), stringToWrite.c_str());
@@ 131,6 131,9 @@ const fs::path vfs::getCurrentBootJSON()
}
LOG_INFO("vfs::getCurrentBootJSON crc check failed on %s", purefs::file::boot_json);
+ // replace broken .boot.json with a default one
+ replaceWithString(purefs::dir::getRootDiskPath() / purefs::file::boot_json, bootConfig.to_json().dump());
+
return relativeToRoot(purefs::file::boot_json);
}