8000 Added possibility to open multiple files with LFS_NO_MALLOC enabled. · littlefs-project/littlefs@d77ed32 · GitHub
[go: up one dir, main page]

Skip to content

Commit d77ed32

Browse files
committed
Added possibility to open multiple files with LFS_NO_MALLOC enabled.
1 parent c5e2b33 commit d77ed32

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

lfs.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1276,7 +1276,7 @@ static int lfs_ctz_traverse(lfs_t *lfs,
12761276

12771277
/// Top level file operations ///
12781278
int lfs_file_open(lfs_t *lfs, lfs_file_t *file,
1279-
const char *path, int flags) {
1279+
const char *path, int flags, void *file_buffer) {
12801280
// deorphan if we haven't yet, needed at most once after poweron
12811281
if ((flags & 3) != LFS_O_RDONLY && !lfs->deorphaned) {
12821282
int err = lfs_deorphan(lfs);
@@ -1334,7 +1334,9 @@ int lfs_file_open(lfs_t *lfs, lfs_file_t *file,
13341334

13351335
// allocate buffer if needed
13361336
file->cache.block = 0xffffffff;
1337-
if (lfs->cfg->file_buffer) {
1337+
if (file_buffer) {
1338+
file->cache.buffer = file_buffer;
1339+
} else if (lfs->cfg->file_buffer) {
13381340
if (lfs->files) {
13391341
// already in use
13401342
return LFS_ERR_NOMEM;

lfs.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,7 @@ int lfs_stat(lfs_t *lfs, const char *path, struct lfs_info *info);
340340
//
341341
// Returns a negative error code on failure.
342342
int lfs_file_open(lfs_t *lfs, lfs_file_t *file,
343-
const char *path, int flags);
343+
const char *path, int flags, void *file_buffer);
344344

345345
// Close a file
346346
//

0 commit comments

Comments
 (0)
0