Commit Graph

839 Commits

Author SHA1 Message Date
Carles Cufí 408c16a909
Merge pull request #14 from de-nordic/update-to-v2.8.1
Update LittleFS to v2.8.1 from upstream.
2024-01-19 16:20:58 +01:00
Dominik Ermel 94c8ed6ecd Apply back changes reverted before merge
Bring in changes done in
ca583fd297
and removal of .github subdirectory.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-11-17 15:27:44 +00:00
Dominik Ermel 1cb5db6436 Merge tag v2.8.1 from upstream
Merge tag v2.8.1 in upstream repository
https://github.com/littlefs-project/littlefs

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-11-17 13:53:00 +00:00
Dominik Ermel 537ddc62c6 Remove changes done during evil-merge
Will bring them back after merge of v2.8.1.

Signed-off-by: Dominik Ermel <dominik.ermel@nordicsemi.no>
2023-11-17 13:52:32 +00:00
Christopher Haster c733d9ec57
Merge pull request #884 from DvdGiessen/static-functions
lfs_fs_raw* functions should be static
2023-10-31 13:26:35 -05:00
Christopher Haster 8f3f32d1f3 Added -Wmissing-prototypes
This warning is useful for catching the easy mistake of missing the
keyword static on functions intended to be internal-only.

Missing the static keyword risks symbol polution and misses potential
compiler optimizations.

This is an interesting warning, while useful for libraries such as
littlefs, it's perfectly valid C to not predeclare all functions, and
common in final application binaries.

Relatedly, this warning is re-disabled for the test/bench runner. There
may be a better way to organize the CFLAGS, maybe into separate
LIB/RUNNER CFLAGS, but I'll leave this to future work if our CFLAGS grow
more complicated.

This was motivated by non-static internal-only functions leaking into a
release. Found and fixed by DvdGiessen.
2023-10-24 12:04:54 -05:00
Daniël van de Giessen 92fc780f71
lfs_fs_raw* functions should be static 2023-10-23 13:35:34 +02:00
Christopher Haster f77214d1f0
Merge pull request #877 from littlefs-project/devel
Minor release: v2.8
2023-09-22 11:52:21 -05:00
Christopher Haster f91c5bd687 Bumped minor version to v2.8 2023-09-21 13:02:09 -05:00
Christopher Haster 0eb52a2df1
Merge pull request #875 from littlefs-project/fs-gc
Add lfs_fs_gc to enable proactive finding of free blocks
2023-09-21 13:01:19 -05:00
Christopher Haster 6b33ee5e34 Renamed lfs_fs_findfreeblocks -> lfs_fs_gc, tweaked documentation
The idea is in the future this function may be extended to support other
block janitorial work. In such a case calling this lfs_fs_gc provides a
more general name that can include other operations.

This is currently just wishful thinking, however.
2023-09-21 12:23:38 -05:00
Christopher Haster 63e4408f2a Extended alloc tests to test some properties of lfs_fs_findfreeblocks
- Test that the code actually runs.

- Test that lfs_fs_findfreeblocks does not break block allocations.

- Test that lfs_fs_findfreeblocks does not error when no space is
  available, it should only errors when the block is actually needed.
2023-09-21 12:23:38 -05:00
Christopher Haster dbe4598c12 Added API boilerplate for lfs_fs_findfreeblocks and consistent style
This adds the tracing and optional locking for the littlefs API.

Also updated to match the code style, and added LFS_READONLY guards
where necessary.
2023-09-21 12:23:36 -05:00
ondrap d85a0fe2e2 Move lookahead buffer offset at the first free block if such block doesn't exist move it for whole lookahead size. 2023-09-21 12:21:25 -05:00
ondrap b637379210 Update lfs_find_free_blocks to match the latest changes. 2023-09-21 12:18:55 -05:00
Christopher Haster 1ba4ed03f0
Merge pull request #872 from littlefs-project/fs-grow
Add lfs_fs_grow to enable limited resizing of the filesystem
2023-09-21 12:11:35 -05:00
Christopher Haster e4b7fa15c1
Merge pull request #866 from BrianPugh/optional-block-count
Infer block_count from superblock if not provided in config.
2023-09-21 12:07:00 -05:00
Christopher Haster 23505fa9fa Added lfs_fs_grow for growing the filesystem to a different block_count
The initial implementation for this was provided by kaetemi, originally
as a mount flag. However, it has been modified here to be self-contained
in an explicit runtime function that can be called after mount.

The reasons for an explicit function:

1. lfs_mount stays a strictly readonly operation, and avoids pulling in
   all of the write machinery.

2. filesystem-wide operations such as lfs_fs_grow can be a bit risky,
   and irreversable. The action of growing the filesystem should be very
   intentional.

---

One concern with this change is that this will be the first function
that changes metadata in the superblock. This might break tools that
expect the first valid superblock entry to contain the most recent
metadata, since only the last superblock in the superblock chain will
contain the updated metadata.
2023-09-12 01:32:09 -05:00
Christopher Haster 2c222af17d Tweaked lfs_fsinfo block_size/block_count fields
Mainly to match superblock ordering and emphasize these are logical
blocks.
2023-09-12 01:31:21 -05:00
Christopher Haster 127d84b681 Added a couple mixed/unknown block_count tests
These were cherry-picked from some previous work on a related feature.
2023-09-12 01:14:39 -05:00
Christopher Haster 027331b2f0 Adopted erase_size/erase_count config in test block-devices/runners
In separating the configuration of littlefs from the physical geometry
of the underlying device, we can no longer rely solely on lfs_config to
contain all of the information necessary for the simulated block devices
we use for testing.

This adds a new lfs_*bd_config struct for each of the block devices, and
new erase_size/erase_count fields. The erase_* name was chosen since
these reflect the (simulated) physical erase size and count of
erase-sized blocks, unlike the block_* variants which represent logical
block sizes used for littlefs's bookkeeping.

It may be worth adopting erase_size/erase_count in littlefs's config at
some point in the future, but at the moment doesn't seem necessary.

Changing the lfs_bd_config structs to be required is probably a good
idea anyways, as it moves us more towards separating the bds from
littlefs. Though we can't quite get rid of the lfs_config parameter
because of the block-device API in lfs_config. Eventually it would be
nice to get rid of it, but that would require API breakage.
2023-09-12 00:39:09 -05:00
Christopher Haster 9c23329dd7 Revert of refactor lfs_scan_* out of lfs_format
This would result in two passes through the superblock chain during
mount, when we can access everything we need to in one.
2023-09-03 13:19:03 -05:00
Christopher Haster 130790fa91
Merge pull request #863 from littlefs-project/fix-conversion-warning
Fix integer conversion warning from Code Composer Studio
2023-09-03 12:46:38 -05:00
Christopher Haster 531d5e5073
Merge pull request #855 from mdahamshi/mmd_fix
initlize struct lfs_diskoff disk = {0}
2023-09-03 12:46:28 -05:00
Christopher Haster e40d8f5410
Merge pull request #849 from littlefs-project/fix-ci-release-no-version
Fix release script breaking if there is no previous version
2023-09-03 12:46:18 -05:00
Brian Pugh 23089d5758 remove previous block_count detection from lfs_format 2023-08-20 14:10:12 -07:00
Brian Pugh d6098bd3ce Add block_count and block_size to fsinfo 2023-08-20 11:53:18 -07:00
Brian Pugh d6c0c6a786 linting 2023-08-20 11:33:29 -07:00
Brian Pugh 5caa83fb77 forgot to unmount lfs in test; leaking memory 2023-08-17 22:10:53 -07:00
Brian Pugh 7521e0a6b2 fix newly introduced missing cleanup when an invalid superblock is found. 2023-08-17 20:51:33 -07:00
Brian Pugh 2ebfec78c3 test for failure when interpretting block count when formatting without superblock 2023-08-17 15:20:46 -07:00
Brian Pugh 3d0bcf4066 Add test_superblocks_mount_unknown_block_count 2023-08-17 15:13:16 -07:00
Brian Pugh 6de3fc6ae8 fix corruption check 2023-08-17 15:07:19 -07:00
Brian Pugh df238ebac6 Add a unit test; currently hanging on final permutation.
Some block-device bound-checks are disabled during superblock search.
2023-08-16 23:07:55 -07:00
Brian Pugh be6812213d introduce lfs->block_count. If cfg->block_count is 0, autopopulate from superblock 2023-08-16 22:23:34 -07:00
Brian Pugh 6dae7038f9 remove redundant superblock check 2023-08-16 22:23:34 -07:00
Brian Pugh 73285278b9 refactor lfs_scan_for_state_updates and lfs_scan_for_superblock out of lfs_format 2023-08-16 22:23:34 -07:00
Mohammad Dahamshi 5a834b6fc1 initlize struct lfs_diskoff disk = {0}
so we don't use it uninitlized in first run
2023-08-03 11:21:58 -05:00
Christopher Haster d775b46e3d Fixed integer conversion warning from Code Composer Studio
Proposed by FiddlingBits
2023-08-03 11:16:40 -05:00
Christopher Haster 96fb8bec85 Fixed release script breaking if there is no previous version
This can't actually happen in the current state of the littlefs GitHub
repo, but could in theory cause problems if CI is enabled on a fork.

Found while enabling GitHub Actions on littlefs-fuse.
2023-07-03 12:27:17 -05:00
Christopher Haster 611c9b20db
Merge pull request #848 from littlefs-project/devel
Minor release: v2.7
2023-06-30 12:33:10 -05:00
Christopher Haster a942cdba66 Bumped minor version to v2.7 2023-06-30 00:28:10 -05:00
Christopher Haster 225fc31a17
Merge pull request #846 from littlefs-project/link-chan-fatfs
Add a link to ChaN's FatFS implementation
2023-06-30 00:26:43 -05:00
Christopher Haster 5db368c0a2
Merge pull request #839 from littlefs-project/configurable-disk-version
Add support for writing previous on-disk minor versions
2023-06-30 00:26:29 -05:00
Christopher Haster f09c6a4eb7
Merge pull request #838 from littlefs-project/fs-stat
Add lfs_fs_stat for access to filesystem status/configuration
2023-06-30 00:25:59 -05:00
Christopher Haster 79cc75d18f Added LFS_MULTIVERSION and testing of lfs2.0 to CI
- Added test-multiversion test job
- Added test-lfs2_0 test job
- Added mutliversion size measurement
2023-06-29 12:31:22 -05:00
Christopher Haster eb9af7abe5 Added LFS_MULTIVERSION, made lfs2.0 support a compile-time option
The code-cost wasn't that bad: 16556 B -> 16754 B (+1.2%)

But moving write support of older versions behind a compile-time flag
allows us to be a bit more liberal with what gets added to support older
versions, since the cost won't hit most users.
2023-06-29 12:31:22 -05:00
Christopher Haster b72c96d440 Added support for writing on-disk version lfs2.0
The intention is to help interop with older minor versions of littlefs.

Unfortunately, since lfs2.0 drivers cannot mount lfs2.1 images, there are
situations where it would be useful to write to write strictly lfs2.0
compatible images. The solution here adds a "disk_version" configuration
option which determines the behavior of lfs2.1 dependent features.

Normally you would expect this to only change write behavior. But since the
main change in lfs2.1 increased validation of erased data, we also need to
skip this extra validation (fcrc) or see terrible slowdowns when writing.
2023-06-29 12:31:22 -05:00
Christopher Haster 265692e709 Removed fsinfo.block_usage for now
In terms of ease-of-use, a user familiar with other filesystems expects
block_usage in fsinfo. But in terms of practicality, block_usage can be
expensive to find in littlefs, so if it's not needed in the resulting
fsinfo, that operation is wasteful.

It's not clear to me what the best course of action is, but since
block_usage can always be added to fsinfo later, but not removed without
breaking backwards compatibility, I'm leaving this out for now.

Block usage can still be found by explicitly calling lfs_fs_size.
2023-06-29 12:23:33 -05:00
Christopher Haster 08a132e048 Added a link to ChaN's FatFS implementation
ChaN's FAT implementation definitely deserves a mention here, since it
was one of the first open-source microcontroller-oriented filesystem
implementations that I'm aware of, and has a lot of good ideas at the
implementation level.

Honestly I didn't realize this wasn't already linked to from here. If
you're using FAT on a microcontroller, it's most likely this library.
2023-06-26 15:37:32 -05:00