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.
This commit is contained in:
Christopher Haster
2023-09-12 00:06:04 -05:00
parent 63e4408f2a
commit 6b33ee5e34
3 changed files with 26 additions and 21 deletions

15
lfs.h
View File

@@ -712,12 +712,17 @@ lfs_ssize_t lfs_fs_size(lfs_t *lfs);
// Returns a negative error code on failure.
int lfs_fs_traverse(lfs_t *lfs, int (*cb)(void*, lfs_block_t), void *data);
// Use Traverse function and try to find free blocks. LittleFS free blocks
// search is unpredictable.
// Attempt to proactively find free blocks
//
// Search is costly operation which may delay write. In realtime write
// scenarios can be better to find them before a write.
int lfs_fs_findfreeblocks(lfs_t *lfs);
// Calling this function is not required, but may allowing the offloading of
// the expensive block allocation scan to a less time-critical code path.
//
// Note: littlefs currently does not persist any found free blocks to disk.
// This may change in the future.
//
// Returns a negative error code on failure. Finding no free blocks is
// not an error.
int lfs_fs_gc(lfs_t *lfs);
#ifndef LFS_READONLY
// Attempt to make the filesystem consistent and ready for writing