Skip to content

Commit

Permalink
fix: remount warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
nullptr authored and LynnL4 committed Apr 18, 2024
1 parent 9f0b9a8 commit d717626
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 12 additions & 2 deletions porting/himax/we2/el_extfs_we2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,16 @@ static Status STATUS_FROM_FRESULT(FRESULT res) {
}
}

FileWE2::~FileWE2() { close(); }
FileWE2::~FileWE2() {}

void FileWE2::close() {
if (_file != nullptr) {
f_close(static_cast<FIL*>(_file));
delete static_cast<FIL*>(_file);
_file = nullptr;
}
_fs_mount_times = 0;
_mounted = false;
}

Status FileWE2::write(const uint8_t* data, size_t size, size_t* written) {
Expand All @@ -115,7 +117,8 @@ FileWE2::FileWE2(const void* f) {
*static_cast<FIL*>(_file) = *static_cast<const FIL*>(f);
}

int ExtfsWE2::_fs_mount_times = 0;
int ExtfsWE2::_fs_mount_times = 0;
bool ExtfsWE2::_mounted = false;

ExtfsWE2::ExtfsWE2() { _fs = new (std::nothrow) FATFS{}; }

Expand All @@ -127,6 +130,9 @@ ExtfsWE2::~ExtfsWE2() {
}

Status ExtfsWE2::mount(const char* path) {
if (_mounted) {
return {true, ""};
}
if (_fs_mount_times > CONFIG_FS_MAX_MOUNT_TIMES) {
return {false, "Filesystem mount times exceed the limit"};
}
Expand Down Expand Up @@ -181,6 +187,10 @@ Status ExtfsWE2::mount(const char* path) {
curdir = nullptr;
}

if (res == FR_OK) {
_mounted = true;
}

return STATUS_FROM_FRESULT(res);
}

Expand Down
2 changes: 2 additions & 0 deletions porting/himax/we2/el_extfs_we2.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class ExtfsWE2 final : public Extfs {
private:
static int _fs_mount_times;
void* _fs;

static bool _mounted;
};

} // namespace edgelab
Expand Down

0 comments on commit d717626

Please sign in to comment.