Little File System, Can the LFS open multiple files simultaneously?

30 Jan 2019

Dear Everyone,

I am new to the Little Filesystem and have a question: Does the LFS open multiple files simultaneously? When I open a second file to write I got the LFS_ERR_NOMEM return error. I can open one file at a time to write and read.

Please advice how to fix the issue? Regards, Dennis

31 Jan 2019

Dear Everyone, I stepped through the lfs.c module after I tried to open a second file to write (the first file was opened for read). At line #1359, it returned LFS_ERR_NOMEM, because there was read file opened

     } else if (lfs->cfg->file_buffer) {
        if (lfs->files) {
            // already in use
            return LFS_ERR_NOMEM;
        }
    ....
    }

What should I do to be able to open multiple files simultaneously? Thanks, Dennis

31 Jan 2019

Issue resolved, I found the note:

struct lfs_config {
....
    // Optional, statically allocated buffer for files. Must be program sized.
    // If enabled, only one file may be opened at a time.
    void *file_buffer;
...
}

I configured the file_buffer size.

    .file_buffer = (char *)file_buffer,

should be

    .file_buffer = NULL,

Cheer! Dennis