mirror of
				https://github.com/eledio-devices/thirdparty-littlefs.git
				synced 2025-10-31 08:42:40 +01:00 
			
		
		
		
	As an embedded library, littlefs's configuration straddles two worlds.
In most cases the configuration is usually constant at build time, but
when integrated into OSs, the configuration needs to be dynamically
configurable.
To help with this, littlefs has a separate lfs_config struct that can be
placed into ROM when possible.
But you know what's better than ROM configuration? Truely inlinable
static configuration known at compile-time. In addition to avoiding the
RAM cost, compile-time configuration allows for additional compiler
optimizations, such as constexpr-elimination and removal of unused
code-paths.
So how to enable static configuration?
1. define LFS_STATICCFG
2. implement callbacks as global functions:
   - lfs_read
   - lfs_prog
   - lfs_erase
   - lfs_sync
2. define the now-required constants that configure littlefs:
   - LFS_READ_SIZE
   - LFS_PROG_SIZE
   - LFS_BLOCK_SIZE
   - LFS_BLOCK_COUNT
   - LFS_BLOCK_CYCLES
   - LFS_CACHE_SIZE
   - LFS_LOOKAHEAD_SIZE
   - LFS_READ_BUFFER (optional)
   - LFS_PROG_BUFFER (optional)
   - LFS_LOOKAHEAD_BUFFER (optional)
   - LFS_NAME_MAX (optional)
   - LFS_FILE_MAX (optional)
   - LFS_ATTR_MAX (optional)
Note, there is a separate configuration for the file configuration, this
can be enabled/disabled independently of LFS_STATICCFG. You will likely
want to define this as well if you are looking for the smallest code
size.
In order to avoid a mess of #ifdefs, the internals of littlefs use a
simple macro that redirects to either the dynamic or static config at
compile time:
    #ifdef LFS_STATICCFG
    #define LFS_CFG_READ_SIZE(lfs) ((void)lfs, LFS_READ_SIZE)
    #else
    #define LFS_CFG_READ_SIZE(lfs) lfs->cfg->read_size
    #endif
Unfortunately it does look like there still may be a lot of issues
related to warnings of comparisons against constants... If only C had
a way to ignore warnings on individual statements...
Original idea by apmorton
		
	
		
			
				
	
	
		
			381 lines
		
	
	
		
			13 KiB
		
	
	
	
		
			TOML
		
	
	
	
	
	
			
		
		
	
	
			381 lines
		
	
	
		
			13 KiB
		
	
	
	
		
			TOML
		
	
	
	
	
	
| 
 | |
| [[case]] # simple file seek
 | |
| define = [
 | |
|     {COUNT=132, SKIP=4},
 | |
|     {COUNT=132, SKIP=128},
 | |
|     {COUNT=200, SKIP=10},
 | |
|     {COUNT=200, SKIP=100},
 | |
|     {COUNT=4,   SKIP=1},
 | |
|     {COUNT=4,   SKIP=2},
 | |
| ]
 | |
| code = '''
 | |
|     lfs_formatcfg(&lfs, &cfg) => 0;
 | |
|     lfs_mountcfg(&lfs, &cfg) => 0;
 | |
|     lfs_file_open(&lfs, &file, "kitty",
 | |
|             LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
 | |
|     size = strlen("kittycatcat");
 | |
|     memcpy(buffer, "kittycatcat", size);
 | |
|     for (int j = 0; j < COUNT; j++) {
 | |
|         lfs_file_write(&lfs, &file, buffer, size);
 | |
|     }
 | |
|     lfs_file_close(&lfs, &file) => 0;
 | |
|     lfs_unmount(&lfs) => 0;
 | |
| 
 | |
|     lfs_mountcfg(&lfs, &cfg) => 0;
 | |
|     lfs_file_open(&lfs, &file, "kitty", LFS_O_RDONLY) => 0;
 | |
| 
 | |
|     lfs_soff_t pos = -1;
 | |
|     size = strlen("kittycatcat");
 | |
|     for (int i = 0; i < SKIP; i++) {
 | |
|         lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|         memcmp(buffer, "kittycatcat", size) => 0;
 | |
|         pos = lfs_file_tell(&lfs, &file);
 | |
|     }
 | |
|     assert(pos >= 0);
 | |
| 
 | |
|     lfs_file_seek(&lfs, &file, pos, LFS_SEEK_SET) => pos;
 | |
|     lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|     memcmp(buffer, "kittycatcat", size) => 0;
 | |
| 
 | |
|     lfs_file_rewind(&lfs, &file) => 0;
 | |
|     lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|     memcmp(buffer, "kittycatcat", size) => 0;
 | |
| 
 | |
|     lfs_file_seek(&lfs, &file, 0, LFS_SEEK_CUR) => size;
 | |
|     lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|     memcmp(buffer, "kittycatcat", size) => 0;
 | |
| 
 | |
|     lfs_file_seek(&lfs, &file, size, LFS_SEEK_CUR) => 3*size;
 | |
|     lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|     memcmp(buffer, "kittycatcat", size) => 0;
 | |
| 
 | |
|     lfs_file_seek(&lfs, &file, pos, LFS_SEEK_SET) => pos;
 | |
|     lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|     memcmp(buffer, "kittycatcat", size) => 0;
 | |
| 
 | |
|     lfs_file_seek(&lfs, &file, -size, LFS_SEEK_CUR) => pos;
 | |
|     lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|     memcmp(buffer, "kittycatcat", size) => 0;
 | |
| 
 | |
|     lfs_file_seek(&lfs, &file, -size, LFS_SEEK_END) >= 0 => 1;
 | |
|     lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|     memcmp(buffer, "kittycatcat", size) => 0;
 | |
| 
 | |
|     size = lfs_file_size(&lfs, &file);
 | |
|     lfs_file_seek(&lfs, &file, 0, LFS_SEEK_CUR) => size;
 | |
| 
 | |
|     lfs_file_close(&lfs, &file) => 0;
 | |
|     lfs_unmount(&lfs) => 0;
 | |
| '''
 | |
| 
 | |
| [[case]] # simple file seek and write
 | |
| define = [
 | |
|     {COUNT=132, SKIP=4},
 | |
|     {COUNT=132, SKIP=128},
 | |
|     {COUNT=200, SKIP=10},
 | |
|     {COUNT=200, SKIP=100},
 | |
|     {COUNT=4,   SKIP=1},
 | |
|     {COUNT=4,   SKIP=2},
 | |
| ]
 | |
| code = '''
 | |
|     lfs_formatcfg(&lfs, &cfg) => 0;
 | |
|     lfs_mountcfg(&lfs, &cfg) => 0;
 | |
|     lfs_file_open(&lfs, &file, "kitty",
 | |
|             LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
 | |
|     size = strlen("kittycatcat");
 | |
|     memcpy(buffer, "kittycatcat", size);
 | |
|     for (int j = 0; j < COUNT; j++) {
 | |
|         lfs_file_write(&lfs, &file, buffer, size);
 | |
|     }
 | |
|     lfs_file_close(&lfs, &file) => 0;
 | |
|     lfs_unmount(&lfs) => 0;
 | |
| 
 | |
|     lfs_mountcfg(&lfs, &cfg) => 0;
 | |
|     lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0;
 | |
| 
 | |
|     lfs_soff_t pos = -1;
 | |
|     size = strlen("kittycatcat");
 | |
|     for (int i = 0; i < SKIP; i++) {
 | |
|         lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|         memcmp(buffer, "kittycatcat", size) => 0;
 | |
|         pos = lfs_file_tell(&lfs, &file);
 | |
|     }
 | |
|     assert(pos >= 0);
 | |
| 
 | |
|     memcpy(buffer, "doggodogdog", size);
 | |
|     lfs_file_seek(&lfs, &file, pos, LFS_SEEK_SET) => pos;
 | |
|     lfs_file_write(&lfs, &file, buffer, size) => size;
 | |
| 
 | |
|     lfs_file_seek(&lfs, &file, pos, LFS_SEEK_SET) => pos;
 | |
|     lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|     memcmp(buffer, "doggodogdog", size) => 0;
 | |
| 
 | |
|     lfs_file_rewind(&lfs, &file) => 0;
 | |
|     lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|     memcmp(buffer, "kittycatcat", size) => 0;
 | |
| 
 | |
|     lfs_file_seek(&lfs, &file, pos, LFS_SEEK_SET) => pos;
 | |
|     lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|     memcmp(buffer, "doggodogdog", size) => 0;
 | |
| 
 | |
|     lfs_file_seek(&lfs, &file, -size, LFS_SEEK_END) >= 0 => 1;
 | |
|     lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|     memcmp(buffer, "kittycatcat", size) => 0;
 | |
| 
 | |
|     size = lfs_file_size(&lfs, &file);
 | |
|     lfs_file_seek(&lfs, &file, 0, LFS_SEEK_CUR) => size;
 | |
| 
 | |
|     lfs_file_close(&lfs, &file) => 0;
 | |
|     lfs_unmount(&lfs) => 0;
 | |
| '''
 | |
| 
 | |
| [[case]] # boundary seek and writes
 | |
| define.COUNT = 132
 | |
| define.OFFSETS = '"{512, 1020, 513, 1021, 511, 1019, 1441}"'
 | |
| code = '''
 | |
|     lfs_formatcfg(&lfs, &cfg) => 0;
 | |
|     lfs_mountcfg(&lfs, &cfg) => 0;
 | |
|     lfs_file_open(&lfs, &file, "kitty",
 | |
|             LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
 | |
|     size = strlen("kittycatcat");
 | |
|     memcpy(buffer, "kittycatcat", size);
 | |
|     for (int j = 0; j < COUNT; j++) {
 | |
|         lfs_file_write(&lfs, &file, buffer, size);
 | |
|     }
 | |
|     lfs_file_close(&lfs, &file) => 0;
 | |
|     lfs_unmount(&lfs) => 0;
 | |
| 
 | |
|     lfs_mountcfg(&lfs, &cfg) => 0;
 | |
|     lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0;
 | |
| 
 | |
|     size = strlen("hedgehoghog");
 | |
|     const lfs_soff_t offsets[] = OFFSETS;
 | |
| 
 | |
|     for (unsigned i = 0; i < sizeof(offsets) / sizeof(offsets[0]); i++) {
 | |
|         lfs_soff_t off = offsets[i];
 | |
|         memcpy(buffer, "hedgehoghog", size);
 | |
|         lfs_file_seek(&lfs, &file, off, LFS_SEEK_SET) => off;
 | |
|         lfs_file_write(&lfs, &file, buffer, size) => size;
 | |
|         lfs_file_seek(&lfs, &file, off, LFS_SEEK_SET) => off;
 | |
|         lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|         memcmp(buffer, "hedgehoghog", size) => 0;
 | |
| 
 | |
|         lfs_file_seek(&lfs, &file, 0, LFS_SEEK_SET) => 0;
 | |
|         lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|         memcmp(buffer, "kittycatcat", size) => 0;
 | |
| 
 | |
|         lfs_file_seek(&lfs, &file, off, LFS_SEEK_SET) => off;
 | |
|         lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|         memcmp(buffer, "hedgehoghog", size) => 0;
 | |
| 
 | |
|         lfs_file_sync(&lfs, &file) => 0;
 | |
| 
 | |
|         lfs_file_seek(&lfs, &file, 0, LFS_SEEK_SET) => 0;
 | |
|         lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|         memcmp(buffer, "kittycatcat", size) => 0;
 | |
| 
 | |
|         lfs_file_seek(&lfs, &file, off, LFS_SEEK_SET) => off;
 | |
|         lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|         memcmp(buffer, "hedgehoghog", size) => 0;
 | |
|     }
 | |
| 
 | |
|     lfs_file_close(&lfs, &file) => 0;
 | |
|     lfs_unmount(&lfs) => 0;
 | |
| '''
 | |
| 
 | |
| [[case]] # out of bounds seek
 | |
| define = [
 | |
|     {COUNT=132, SKIP=4},
 | |
|     {COUNT=132, SKIP=128},
 | |
|     {COUNT=200, SKIP=10},
 | |
|     {COUNT=200, SKIP=100},
 | |
|     {COUNT=4,   SKIP=2},
 | |
|     {COUNT=4,   SKIP=3},
 | |
| ]
 | |
| code = '''
 | |
|     lfs_formatcfg(&lfs, &cfg) => 0;
 | |
|     lfs_mountcfg(&lfs, &cfg) => 0;
 | |
|     lfs_file_open(&lfs, &file, "kitty",
 | |
|             LFS_O_WRONLY | LFS_O_CREAT | LFS_O_APPEND) => 0;
 | |
|     size = strlen("kittycatcat");
 | |
|     memcpy(buffer, "kittycatcat", size);
 | |
|     for (int j = 0; j < COUNT; j++) {
 | |
|         lfs_file_write(&lfs, &file, buffer, size);
 | |
|     }
 | |
|     lfs_file_close(&lfs, &file) => 0;
 | |
|     lfs_unmount(&lfs) => 0;
 | |
|     lfs_mountcfg(&lfs, &cfg) => 0;
 | |
|     lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0;
 | |
| 
 | |
|     size = strlen("kittycatcat");
 | |
|     lfs_file_size(&lfs, &file) => COUNT*size;
 | |
|     lfs_file_seek(&lfs, &file, (COUNT+SKIP)*size,
 | |
|             LFS_SEEK_SET) => (COUNT+SKIP)*size;
 | |
|     lfs_file_read(&lfs, &file, buffer, size) => 0;
 | |
| 
 | |
|     memcpy(buffer, "porcupineee", size);
 | |
|     lfs_file_write(&lfs, &file, buffer, size) => size;
 | |
| 
 | |
|     lfs_file_seek(&lfs, &file, (COUNT+SKIP)*size,
 | |
|             LFS_SEEK_SET) => (COUNT+SKIP)*size;
 | |
|     lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|     memcmp(buffer, "porcupineee", size) => 0;
 | |
| 
 | |
|     lfs_file_seek(&lfs, &file, COUNT*size,
 | |
|             LFS_SEEK_SET) => COUNT*size;
 | |
|     lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|     memcmp(buffer, "\0\0\0\0\0\0\0\0\0\0\0", size) => 0;
 | |
| 
 | |
|     lfs_file_seek(&lfs, &file, -((COUNT+SKIP)*size),
 | |
|             LFS_SEEK_CUR) => LFS_ERR_INVAL;
 | |
|     lfs_file_tell(&lfs, &file) => (COUNT+1)*size;
 | |
| 
 | |
|     lfs_file_seek(&lfs, &file, -((COUNT+2*SKIP)*size),
 | |
|             LFS_SEEK_END) => LFS_ERR_INVAL;
 | |
|     lfs_file_tell(&lfs, &file) => (COUNT+1)*size;
 | |
| 
 | |
|     lfs_file_close(&lfs, &file) => 0;
 | |
|     lfs_unmount(&lfs) => 0;
 | |
| '''
 | |
| 
 | |
| [[case]] # inline write and seek
 | |
| define.SIZE = [2, 4, 128, 132]
 | |
| code = '''
 | |
|     lfs_formatcfg(&lfs, &cfg) => 0;
 | |
|     lfs_mountcfg(&lfs, &cfg) => 0;
 | |
|     lfs_file_open(&lfs, &file, "tinykitty",
 | |
|             LFS_O_RDWR | LFS_O_CREAT) => 0;
 | |
|     int j = 0;
 | |
|     int k = 0;
 | |
| 
 | |
|     memcpy(buffer, "abcdefghijklmnopqrstuvwxyz", 26);
 | |
|     for (unsigned i = 0; i < SIZE; i++) {
 | |
|         lfs_file_write(&lfs, &file, &buffer[j++ % 26], 1) => 1;
 | |
|         lfs_file_tell(&lfs, &file) => i+1;
 | |
|         lfs_file_size(&lfs, &file) => i+1;
 | |
|     }
 | |
| 
 | |
|     lfs_file_seek(&lfs, &file, 0, LFS_SEEK_SET) => 0;
 | |
|     lfs_file_tell(&lfs, &file) => 0;
 | |
|     lfs_file_size(&lfs, &file) => SIZE;
 | |
|     for (unsigned i = 0; i < SIZE; i++) {
 | |
|         uint8_t c;
 | |
|         lfs_file_read(&lfs, &file, &c, 1) => 1;
 | |
|         c => buffer[k++ % 26];
 | |
|     }
 | |
| 
 | |
|     lfs_file_sync(&lfs, &file) => 0;
 | |
|     lfs_file_tell(&lfs, &file) => SIZE;
 | |
|     lfs_file_size(&lfs, &file) => SIZE;
 | |
| 
 | |
|     lfs_file_seek(&lfs, &file, 0, LFS_SEEK_SET) => 0;
 | |
|     for (unsigned i = 0; i < SIZE; i++) {
 | |
|         lfs_file_write(&lfs, &file, &buffer[j++ % 26], 1) => 1;
 | |
|         lfs_file_tell(&lfs, &file) => i+1;
 | |
|         lfs_file_size(&lfs, &file) => SIZE;
 | |
|         lfs_file_sync(&lfs, &file) => 0;
 | |
|         lfs_file_tell(&lfs, &file) => i+1;
 | |
|         lfs_file_size(&lfs, &file) => SIZE;
 | |
|         if (i < SIZE-2) {
 | |
|             uint8_t c[3];
 | |
|             lfs_file_seek(&lfs, &file, -1, LFS_SEEK_CUR) => i;
 | |
|             lfs_file_read(&lfs, &file, &c, 3) => 3;
 | |
|             lfs_file_tell(&lfs, &file) => i+3;
 | |
|             lfs_file_size(&lfs, &file) => SIZE;
 | |
|             lfs_file_seek(&lfs, &file, i+1, LFS_SEEK_SET) => i+1;
 | |
|             lfs_file_tell(&lfs, &file) => i+1;
 | |
|             lfs_file_size(&lfs, &file) => SIZE;
 | |
|         }
 | |
|     }
 | |
| 
 | |
|     lfs_file_seek(&lfs, &file, 0, LFS_SEEK_SET) => 0;
 | |
|     lfs_file_tell(&lfs, &file) => 0;
 | |
|     lfs_file_size(&lfs, &file) => SIZE;
 | |
|     for (unsigned i = 0; i < SIZE; i++) {
 | |
|         uint8_t c;
 | |
|         lfs_file_read(&lfs, &file, &c, 1) => 1;
 | |
|         c => buffer[k++ % 26];
 | |
|     }
 | |
| 
 | |
|     lfs_file_sync(&lfs, &file) => 0;
 | |
|     lfs_file_tell(&lfs, &file) => SIZE;
 | |
|     lfs_file_size(&lfs, &file) => SIZE;
 | |
| 
 | |
|     lfs_file_close(&lfs, &file) => 0;
 | |
|     lfs_unmount(&lfs) => 0;
 | |
| '''
 | |
| 
 | |
| [[case]] # file seek and write with power-loss
 | |
| # must be power-of-2 for quadratic probing to be exhaustive
 | |
| define.COUNT = [4, 64, 128]
 | |
| reentrant = true
 | |
| code = '''
 | |
|     err = lfs_mountcfg(&lfs, &cfg);
 | |
|     if (err) {
 | |
|         lfs_formatcfg(&lfs, &cfg) => 0;
 | |
|         lfs_mountcfg(&lfs, &cfg) => 0;
 | |
|     }
 | |
|     err = lfs_file_open(&lfs, &file, "kitty", LFS_O_RDONLY);
 | |
|     assert(!err || err == LFS_ERR_NOENT);
 | |
|     if (!err) {
 | |
|         if (lfs_file_size(&lfs, &file) != 0) {
 | |
|             lfs_file_size(&lfs, &file) => 11*COUNT;
 | |
|             for (int j = 0; j < COUNT; j++) {
 | |
|                 memset(buffer, 0, 11+1);
 | |
|                 lfs_file_read(&lfs, &file, buffer, 11) => 11;
 | |
|                 assert(memcmp(buffer, "kittycatcat", 11) == 0 ||
 | |
|                        memcmp(buffer, "doggodogdog", 11) == 0);
 | |
|             }
 | |
|         }
 | |
|         lfs_file_close(&lfs, &file) => 0;
 | |
|     }
 | |
| 
 | |
|     lfs_file_open(&lfs, &file, "kitty", LFS_O_WRONLY | LFS_O_CREAT) => 0;
 | |
|     if (lfs_file_size(&lfs, &file) == 0) {
 | |
|         for (int j = 0; j < COUNT; j++) {
 | |
|             strcpy((char*)buffer, "kittycatcat");
 | |
|             size = strlen((char*)buffer);
 | |
|             lfs_file_write(&lfs, &file, buffer, size) => size;
 | |
|         }
 | |
|     }
 | |
|     lfs_file_close(&lfs, &file) => 0;
 | |
| 
 | |
|     strcpy((char*)buffer, "doggodogdog");
 | |
|     size = strlen((char*)buffer);
 | |
| 
 | |
|     lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0;
 | |
|     lfs_file_size(&lfs, &file) => COUNT*size;
 | |
|     // seek and write using quadratic probing to touch all
 | |
|     // 11-byte words in the file
 | |
|     lfs_off_t off = 0;
 | |
|     for (int j = 0; j < COUNT; j++) {
 | |
|         off = (5*off + 1) % COUNT;
 | |
|         lfs_file_seek(&lfs, &file, off*size, LFS_SEEK_SET) => off*size;
 | |
|         lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|         assert(memcmp(buffer, "kittycatcat", size) == 0 ||
 | |
|                memcmp(buffer, "doggodogdog", size) == 0);
 | |
|         if (memcmp(buffer, "doggodogdog", size) != 0) {
 | |
|             lfs_file_seek(&lfs, &file, off*size, LFS_SEEK_SET) => off*size;
 | |
|             strcpy((char*)buffer, "doggodogdog");
 | |
|             lfs_file_write(&lfs, &file, buffer, size) => size;
 | |
|             lfs_file_seek(&lfs, &file, off*size, LFS_SEEK_SET) => off*size;
 | |
|             lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|             assert(memcmp(buffer, "doggodogdog", size) == 0);
 | |
|             lfs_file_sync(&lfs, &file) => 0;
 | |
|             lfs_file_seek(&lfs, &file, off*size, LFS_SEEK_SET) => off*size;
 | |
|             lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|             assert(memcmp(buffer, "doggodogdog", size) == 0);
 | |
|         }
 | |
|     }
 | |
|     lfs_file_close(&lfs, &file) => 0;
 | |
| 
 | |
|     lfs_file_open(&lfs, &file, "kitty", LFS_O_RDWR) => 0;
 | |
|     lfs_file_size(&lfs, &file) => COUNT*size;
 | |
|     for (int j = 0; j < COUNT; j++) {
 | |
|         lfs_file_read(&lfs, &file, buffer, size) => size;
 | |
|         assert(memcmp(buffer, "doggodogdog", size) == 0);
 | |
|     }
 | |
|     lfs_file_close(&lfs, &file) => 0;
 | |
|     lfs_unmount(&lfs) => 0;
 | |
| '''
 |