I'm trying to make littlefs thread safe. I have 2 threads, Mcumgr and main that both try to write at the same time which sometimes leads to corrupted filesystem. What is the correct way to accomplish this. I'm thinking of copying the littlefs_fs.c from zephyr and adding the semaphores to this file.
Is this the best approach, I'm trying to avoid changing the zephyr codebase itself to make changing between nrf connect sdk versions possible. Can you suggest a better way to do this or possibly an existing implementation.