Generated v2 prefixes

This commit is contained in:
geky bot
2019-04-11 02:08:05 +00:00
parent 0907ba7813
commit 8d4fd46a4c
28 changed files with 6298 additions and 6298 deletions

View File

@@ -32,14 +32,14 @@ main runs. The program can be interrupted at any time without losing track
of how many times it has been booted and without corrupting the filesystem:
``` c
#include "lfs.h"
#include "lfs2.h"
// variables used by the filesystem
lfs_t lfs;
lfs_file_t file;
lfs2_t lfs2;
lfs2_file_t file;
// configuration of the filesystem is provided by this struct
const struct lfs_config cfg = {
const struct lfs2_config cfg = {
// block device operations
.read = user_provided_block_device_read,
.prog = user_provided_block_device_prog,
@@ -58,30 +58,30 @@ const struct lfs_config cfg = {
// entry point
int main(void) {
// mount the filesystem
int err = lfs_mount(&lfs, &cfg);
int err = lfs2_mount(&lfs2, &cfg);
// reformat if we can't mount the filesystem
// this should only happen on the first boot
if (err) {
lfs_format(&lfs, &cfg);
lfs_mount(&lfs, &cfg);
lfs2_format(&lfs2, &cfg);
lfs2_mount(&lfs2, &cfg);
}
// read current count
uint32_t boot_count = 0;
lfs_file_open(&lfs, &file, "boot_count", LFS_O_RDWR | LFS_O_CREAT);
lfs_file_read(&lfs, &file, &boot_count, sizeof(boot_count));
lfs2_file_open(&lfs2, &file, "boot_count", LFS2_O_RDWR | LFS2_O_CREAT);
lfs2_file_read(&lfs2, &file, &boot_count, sizeof(boot_count));
// update boot count
boot_count += 1;
lfs_file_rewind(&lfs, &file);
lfs_file_write(&lfs, &file, &boot_count, sizeof(boot_count));
lfs2_file_rewind(&lfs2, &file);
lfs2_file_write(&lfs2, &file, &boot_count, sizeof(boot_count));
// remember the storage is not updated until the file is closed successfully
lfs_file_close(&lfs, &file);
lfs2_file_close(&lfs2, &file);
// release any resources we were using
lfs_unmount(&lfs);
lfs2_unmount(&lfs2);
// print the boot count
printf("boot_count: %d\n", boot_count);
@@ -91,7 +91,7 @@ int main(void) {
## Usage
Detailed documentation (or at least as much detail as is currently available)
can be found in the comments in [lfs.h](lfs.h).
can be found in the comments in [lfs2.h](lfs2.h).
littlefs takes in a configuration structure that defines how the filesystem
operates. The configuration struct provides the filesystem with the block
@@ -99,9 +99,9 @@ device operations and dimensions, tweakable parameters that tradeoff memory
usage for performance, and optional static buffers if the user wants to avoid
dynamic memory.
The state of the littlefs is stored in the `lfs_t` type which is left up
The state of the littlefs is stored in the `lfs2_t` type which is left up
to the user to allocate, allowing multiple filesystems to be in use
simultaneously. With the `lfs_t` and configuration struct, a user can
simultaneously. With the `lfs2_t` and configuration struct, a user can
format a block device or mount the filesystem.
Once mounted, the littlefs provides a full set of POSIX-like file and
@@ -115,11 +115,11 @@ the filesystem until sync or close is called on the file.
## Other notes
All littlefs calls have the potential to return a negative error code. The
errors can be either one of those found in the `enum lfs_error` in
[lfs.h](lfs.h), or an error returned by the user's block device operations.
errors can be either one of those found in the `enum lfs2_error` in
[lfs2.h](lfs2.h), or an error returned by the user's block device operations.
In the configuration struct, the `prog` and `erase` function provided by the
user may return a `LFS_ERR_CORRUPT` error if the implementation already can
user may return a `LFS2_ERR_CORRUPT` error if the implementation already can
detect corrupt blocks. However, the wear leveling does not depend on the return
code of these functions, instead all data is read back and checked for
integrity.
@@ -188,7 +188,7 @@ More details on how littlefs works can be found in [DESIGN.md](DESIGN.md) and
## Testing
The littlefs comes with a test suite designed to run on a PC using the
[emulated block device](emubd/lfs_emubd.h) found in the emubd directory.
[emulated block device](emubd/lfs2_emubd.h) found in the emubd directory.
The tests assume a Linux environment and can be started with make:
``` bash