Renamed all prefixes to include the major version

This is needed to allow compilation of multiple versions in the same
binary. Also note that the FUSE testing was removed because of related
name issues.

./scripts/prefix.py lfs2
This commit is contained in:
Christopher Haster
2019-01-30 14:00:35 -06:00
parent 95c1a6339d
commit 97e21eb68e
27 changed files with 5573 additions and 5606 deletions

View File

@@ -30,14 +30,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,
@@ -56,30 +56,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);
@@ -89,7 +89,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).
As you may have noticed, littlefs takes in a configuration structure that
defines how the filesystem operates. The configuration struct provides the
@@ -97,9 +97,9 @@ filesystem with the block 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
@@ -113,11 +113,11 @@ filesystem until sync or close is called on the file.
## Other notes
All littlefs 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),
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.
@@ -140,7 +140,7 @@ with all the nitty-gritty details. Can be useful for developing tooling.
## 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