Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/littlefs-project/littlefs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lfs.c
diff options
context:
space:
mode:
authorChristopher Haster <chaster@utexas.edu>2018-04-29 16:45:14 +0300
committerChristopher Haster <chaster@utexas.edu>2018-04-30 11:37:10 +0300
commitc5e2b335d618a78656a867c7874835db141fbad1 (patch)
tree476e5ec61617205d8af80180acf10973d9d41ab7 /lfs.c
parent015b86bc51fddbd9d0e7c68e02015f8fd12c5839 (diff)
Added error when opening multiple files with a statically allocated bufferv1.3
Opening multiple files simultaneously is not supported without dynamic memory, but the previous behaviour would just let the files overwrite each other, which could lead to bad errors down the line found by husigeza
Diffstat (limited to 'lfs.c')
-rw-r--r--lfs.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/lfs.c b/lfs.c
index 490a508..58fc737 100644
--- a/lfs.c
+++ b/lfs.c
@@ -1335,6 +1335,10 @@ int lfs_file_open(lfs_t *lfs, lfs_file_t *file,
// allocate buffer if needed
file->cache.block = 0xffffffff;
if (lfs->cfg->file_buffer) {
+ if (lfs->files) {
+ // already in use
+ return LFS_ERR_NOMEM;
+ }
file->cache.buffer = lfs->cfg->file_buffer;
} else if ((file->flags & 3) == LFS_O_RDONLY) {
file->cache.buffer = lfs_malloc(lfs->cfg->read_size);