LittleFileSystem2, a little file system.
More...
#include <LittleFileSystem2.h>
|
| LittleFileSystem2 (const char *name=NULL, mbed::BlockDevice *bd=NULL, lfs2_size_t block_size=MBED_LFS2_BLOCK_SIZE, uint32_t block_cycles=MBED_LFS2_BLOCK_CYCLES, lfs2_size_t cache_size=MBED_LFS2_CACHE_SIZE, lfs2_size_t lookahead=MBED_LFS2_LOOKAHEAD_SIZE) |
| Lifetime of the LittleFileSystem2. More...
|
|
virtual int | mount (mbed::BlockDevice *bd) |
| Mount a file system to a block device. More...
|
|
virtual int | unmount () |
| Unmount a file system from the underlying block device. More...
|
|
virtual int | reformat (mbed::BlockDevice *bd) |
| Reformat a file system. More...
|
|
virtual int | remove (const char *path) |
| Remove a file from the file system. More...
|
|
virtual int | rename (const char *path, const char *newpath) |
| Rename a file in the file system. More...
|
|
virtual int | stat (const char *path, struct stat *st) |
| Store information about the file in a stat structure. More...
|
|
virtual int | mkdir (const char *path, mode_t mode) |
| Create a directory in the file system. More...
|
|
virtual int | statvfs (const char *path, struct statvfs *buf) |
| Store information about the mounted file system in a statvfs structure. More...
|
|
LittleFileSystem2, a little file system.
Synchronization level: Thread safe
Definition at line 36 of file LittleFileSystem2.h.
◆ LittleFileSystem2()
LittleFileSystem2 |
( |
const char * |
name = NULL , |
|
|
mbed::BlockDevice * |
bd = NULL , |
|
|
lfs2_size_t |
block_size = MBED_LFS2_BLOCK_SIZE , |
|
|
uint32_t |
block_cycles = MBED_LFS2_BLOCK_CYCLES , |
|
|
lfs2_size_t |
cache_size = MBED_LFS2_CACHE_SIZE , |
|
|
lfs2_size_t |
lookahead = MBED_LFS2_LOOKAHEAD_SIZE |
|
) |
| |
Lifetime of the LittleFileSystem2.
- Parameters
-
name | Name of the file system in the tree. |
bd | Block device to mount. Mounted immediately if not NULL. |
block_size | Size of a logical block. This does not impact ram consumption and may be larger than the physical erase block. If the physical erase block is larger, littlefs will use that instead. Larger values will be faster but waste more storage when files are not aligned to a block size. |
block_cycles | Number of erase cycles before a block is forcefully evicted. Larger values are more efficient but cause less even wear distribution. 0 disables dynamic wear-leveling. |
cache_size | Size of read/program caches. Each file uses 1 cache, and littlefs allocates 2 caches for internal operations. Larger values should be faster but uses more RAM. |
lookahead | Size of the lookahead buffer. A larger lookahead reduces the allocation scans and results in a faster filesystem but uses more RAM. |
◆ format()
static int format |
( |
mbed::BlockDevice * |
bd, |
|
|
lfs2_size_t |
block_size = MBED_LFS2_BLOCK_SIZE , |
|
|
uint32_t |
block_cycles = MBED_LFS2_BLOCK_CYCLES , |
|
|
lfs2_size_t |
cache_size = MBED_LFS2_CACHE_SIZE , |
|
|
lfs2_size_t |
lookahead_size = MBED_LFS2_LOOKAHEAD_SIZE |
|
) |
| |
|
static |
Format a block device with the LittleFileSystem2.
The block device to format should be mounted when this function is called.
- Parameters
-
bd | This is the block device that will be formatted. |
block_size | Size of a logical block. This does not impact ram consumption and may be larger than the physical erase block. If the physical erase block is larger, littlefs will use that instead. Larger values will be faster but waste more storage when files are not aligned to a block size. |
block_cycles | Number of erase cycles before a block is forcefully evicted. Larger values are more efficient but cause less even wear distribution. 0 disables dynamic wear-leveling. |
cache_size | Size of read/program caches. Each file uses 1 cache, and littlefs allocates 2 caches for internal operations. Larger values should be faster but uses more RAM. |
lookahead_size | Size of the lookahead buffer. A larger lookahead reduces the allocation scans and results in a faster filesystem but uses more RAM. |
◆ mount()
Mount a file system to a block device.
- Parameters
-
bd | Block device to mount to. |
- Returns
- 0 on success, negative error code on failure.
Implements FileSystem.
◆ unmount()
Unmount a file system from the underlying block device.
- Returns
- 0 on success, negative error code on failure
Implements FileSystem.
◆ reformat()
Reformat a file system.
Results in an empty and mounted file system.
- Parameters
-
bd | Block device to reformat and mount. If NULL, the mounted Block device is used. Note: If mount fails, bd must be provided. Default: NULL |
- Returns
- 0 on success, negative error code on failure
Reimplemented from FileSystem.
◆ remove()
virtual int remove |
( |
const char * |
path | ) |
|
|
virtual |
Remove a file from the file system.
- Parameters
-
path | The name of the file to remove. |
- Returns
- 0 on success, negative error code on failure
Reimplemented from FileSystem.
◆ rename()
virtual int rename |
( |
const char * |
path, |
|
|
const char * |
newpath |
|
) |
| |
|
virtual |
Rename a file in the file system.
- Parameters
-
path | The name of the file to rename. |
newpath | The name to rename it to. |
- Returns
- 0 on success, negative error code on failure
Reimplemented from FileSystem.
◆ stat()
virtual int stat |
( |
const char * |
path, |
|
|
struct stat * |
st |
|
) |
| |
|
virtual |
Store information about the file in a stat structure.
- Parameters
-
path | The name of the file to find information about. |
st | The stat buffer to write to. |
- Returns
- 0 on success, negative error code on failure
Reimplemented from FileSystem.
◆ mkdir()
virtual int mkdir |
( |
const char * |
path, |
|
|
mode_t |
mode |
|
) |
| |
|
virtual |
Create a directory in the file system.
- Parameters
-
path | The name of the directory to create. |
mode | The permissions with which to create the directory. |
- Returns
- 0 on success, negative error code on failure
Reimplemented from FileSystem.
◆ statvfs()
Store information about the mounted file system in a statvfs structure.
- Parameters
-
path | The name of the file to find information about. |
buf | The stat buffer to write to. |
- Returns
- 0 on success, negative error code on failure
Reimplemented from FileSystem.
◆ get_default_instance()
Return the default file system.
Returns the default file system based on the default block device configuration. Use the components in target.json or application config to change the default block device and affect the default filesystem. SD block device => FAT filesystem QSPIF, SPIF, DATAFLASH or FLAHIAP block device => LITTLE filesystem
An application can override all target settings by implementing FileSystem::get_default_instance() - the default definition is weak, and calls get_target_default_instance().
◆ open() [1/2]
virtual int open |
( |
FileHandle ** |
file, |
|
|
const char * |
path, |
|
|
int |
flags |
|
) |
| |
|
protectedvirtualinherited |
◆ open() [2/2]
virtual int open |
( |
DirHandle ** |
dir, |
|
|
const char * |
path |
|
) |
| |
|
protectedvirtualinherited |
Open a directory on the filesystem.
- Parameters
-
dir | Destination for the handle to the directory |
path | Name of the directory to open |
- Returns
- 0 on success, negative error code on failure
Reimplemented from FileSystemHandle.