From 9f2f0b92e93e8d9c0b433bd477cb71fef7b6353b Mon Sep 17 00:00:00 2001 From: Christopher Haster Date: Thu, 1 May 2025 00:37:07 -0500 Subject: [PATCH] Renamed lfsr_fs_size -> lfsr_fs_usage This better matches how other filesystems refer to the number of in-use blocks. Which makes sense when you consider that "size" could also refer to the configured block_count. The term "usage" avoids this ambiguity. --- lfs.c | 2 +- lfs.h | 6 +++--- tests/test_grow.toml | 16 ++++++++-------- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/lfs.c b/lfs.c index 527390d6..bbb9c60b 100644 --- a/lfs.c +++ b/lfs.c @@ -14406,7 +14406,7 @@ int lfsr_fs_stat(lfs_t *lfs, struct lfs_fsinfo *fsinfo) { return 0; } -lfs_ssize_t lfsr_fs_size(lfs_t *lfs) { +lfs_ssize_t lfsr_fs_usage(lfs_t *lfs) { lfs_size_t count = 0; lfsr_traversal_t t; lfsr_traversal_init(&t, 0); diff --git a/lfs.h b/lfs.h index 6489627d..c77ada5f 100644 --- a/lfs.h +++ b/lfs.h @@ -1261,14 +1261,14 @@ int lfsr_traversal_rewind(lfs_t *lfs, lfsr_traversal_t *t); // Returns a negative error code on failure. int lfsr_fs_stat(lfs_t *lfs, struct lfs_fsinfo *fsinfo); -// Finds the current size of the filesystem +// Finds the number of blocks in use by the filesystem // // Note: Result is best effort. If files share COW structures, the returned -// size may be larger than the filesystem actually is. +// usage may be larger than the filesystem actually is. // // Returns the number of allocated blocks, or a negative error code on failure. //lfs_ssize_t lfs_fs_size(lfs_t *lfs); -lfs_ssize_t lfsr_fs_size(lfs_t *lfs); +lfs_ssize_t lfsr_fs_usage(lfs_t *lfs); // Traverse through all blocks in use by the filesystem // diff --git a/tests/test_grow.toml b/tests/test_grow.toml index 48faba57..fa2f1b99 100644 --- a/tests/test_grow.toml +++ b/tests/test_grow.toml @@ -472,7 +472,7 @@ code = ''' lfsr_fs_stat(&lfs, &fsinfo) => 0; assert(fsinfo.block_count >= INIT_BLOCK_COUNT); assert(fsinfo.block_count <= BLOCK_COUNT); - lfs_ssize_t used = lfsr_fs_size(&lfs); + lfs_ssize_t used = lfsr_fs_usage(&lfs); assert(used >= 0); // we may need to grow multiple blocks before the system gets unstuck @@ -708,7 +708,7 @@ code = ''' lfsr_fs_stat(&lfs, &fsinfo) => 0; assert(fsinfo.block_count >= INIT_BLOCK_COUNT); assert(fsinfo.block_count <= BLOCK_COUNT); - lfs_ssize_t used = lfsr_fs_size(&lfs); + lfs_ssize_t used = lfsr_fs_usage(&lfs); assert(used >= 0); // we may need to grow multiple blocks before the system gets unstuck @@ -868,7 +868,7 @@ code = ''' lfsr_fs_stat(&lfs, &fsinfo) => 0; assert(fsinfo.block_count >= INIT_BLOCK_COUNT); assert(fsinfo.block_count <= BLOCK_COUNT); - lfs_ssize_t used = lfsr_fs_size(&lfs); + lfs_ssize_t used = lfsr_fs_usage(&lfs); assert(used >= 0); // we may need to grow multiple blocks before the system gets unstuck @@ -1134,7 +1134,7 @@ code = ''' lfsr_fs_stat(&lfs, &fsinfo) => 0; assert(fsinfo.block_count >= INIT_BLOCK_COUNT); assert(fsinfo.block_count <= BLOCK_COUNT); - lfs_ssize_t used = lfsr_fs_size(&lfs); + lfs_ssize_t used = lfsr_fs_usage(&lfs); assert(used >= 0); // we may need to grow multiple blocks before the system gets unstuck @@ -1615,7 +1615,7 @@ code = ''' lfsr_fs_stat(&lfs, &fsinfo) => 0; assert(fsinfo.block_count >= INIT_BLOCK_COUNT); assert(fsinfo.block_count <= BLOCK_COUNT); - lfs_ssize_t used = lfsr_fs_size(&lfs); + lfs_ssize_t used = lfsr_fs_usage(&lfs); assert(used >= 0); // we may need to grow multiple blocks before the system gets unstuck @@ -2199,7 +2199,7 @@ code = ''' lfsr_fs_stat(&lfs, &fsinfo) => 0; assert(fsinfo.block_count >= INIT_BLOCK_COUNT); assert(fsinfo.block_count <= BLOCK_COUNT); - lfs_ssize_t used = lfsr_fs_size(&lfs); + lfs_ssize_t used = lfsr_fs_usage(&lfs); assert(used >= 0); // we may need to grow multiple blocks before the system gets unstuck @@ -2562,7 +2562,7 @@ code = ''' lfsr_fs_stat(&lfs, &fsinfo) => 0; assert(fsinfo.block_count >= INIT_BLOCK_COUNT); assert(fsinfo.block_count <= BLOCK_COUNT); - lfs_ssize_t used = lfsr_fs_size(&lfs); + lfs_ssize_t used = lfsr_fs_usage(&lfs); assert(used >= 0); // we may need to grow multiple blocks before the system gets unstuck @@ -3002,7 +3002,7 @@ code = ''' lfsr_fs_stat(&lfs, &fsinfo) => 0; assert(fsinfo.block_count >= INIT_BLOCK_COUNT); assert(fsinfo.block_count <= BLOCK_COUNT); - lfs_ssize_t used = lfsr_fs_size(&lfs); + lfs_ssize_t used = lfsr_fs_usage(&lfs); assert(used >= 0); // we may need to grow multiple blocks before the system gets unstuck