Adopted upstream test_compact, readded lfsr_fs_stat
test_compat has been very useful for testing compatibility on patch and
minor releases.
Though, in porting the tests, I've realized these are actually really
flimsy w.r.t. API changes... lfsp_config notably relies on compatible
struct layouts, which is _not_ guaranteed by littlefs's compatibility
rules.
For this reason I've restricted these tests to only run if LFS_VERSION
doesn't change, though this may be worth reinvestigating in the future.
test_compat on minor API releases would be quite valuable...
lfsr_fs_stat is also not quite up to date with upstream yet. It's really
just a small shim copying over static configs at the moment (except for
name_limit/file_limit). This is because we're still missing most of what
would actually be interesting here: variable block counts, minor
versions, etc.
And of course a minimal lfsr_fs_stat means minimal code changes:
code stack
before: 33642 2592
after: 33670 (+0.1%) 2592 (+0.0%)
This commit is contained in:
@@ -8255,6 +8255,13 @@ static int lfsr_data_readwcompat(lfs_t *lfs, lfsr_data_t *data,
|
|||||||
return lfsr_data_readrcompat(lfs, data, wcompat);
|
return lfsr_data_readrcompat(lfs, data, wcompat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define LFSR_DATA_OCOMPAT(_ocompat) LFSR_DATA_RCOMPAT(_ocompat)
|
||||||
|
|
||||||
|
static int lfsr_data_readocompat(lfs_t *lfs, lfsr_data_t *data,
|
||||||
|
lfsr_ocompat_t *ocompat) {
|
||||||
|
return lfsr_data_readrcompat(lfs, data, ocompat);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// disk geometry
|
// disk geometry
|
||||||
//
|
//
|
||||||
@@ -8908,7 +8915,16 @@ static int lfs_alloc(lfs_t *lfs, lfs_block_t *block, bool erase) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/// Other filesystem traversal things ///
|
/// Other filesystem things ///
|
||||||
|
|
||||||
|
int lfsr_fs_stat(lfs_t *lfs, struct lfs_fsinfo *fsinfo) {
|
||||||
|
fsinfo->disk_version = LFS_DISK_VERSION;
|
||||||
|
fsinfo->block_size = lfs->cfg->block_size;
|
||||||
|
fsinfo->block_count = lfs->cfg->block_count;
|
||||||
|
fsinfo->name_limit = lfs->name_limit;
|
||||||
|
fsinfo->file_limit = lfs->file_limit;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
lfs_ssize_t lfsr_fs_size(lfs_t *lfs) {
|
lfs_ssize_t lfsr_fs_size(lfs_t *lfs) {
|
||||||
lfs_size_t count = 0;
|
lfs_size_t count = 0;
|
||||||
|
|||||||
@@ -321,6 +321,26 @@ struct lfs_info {
|
|||||||
char name[LFS_NAME_MAX+1];
|
char name[LFS_NAME_MAX+1];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// Filesystem info structure
|
||||||
|
struct lfs_fsinfo {
|
||||||
|
// On-disk version
|
||||||
|
uint32_t disk_version;
|
||||||
|
|
||||||
|
// TODO should we add rcompat/wcompat flags here?
|
||||||
|
|
||||||
|
// Size of a logical block in bytes.
|
||||||
|
lfs_size_t block_size;
|
||||||
|
|
||||||
|
// Number of logical blocks in the filesystem.
|
||||||
|
lfs_size_t block_count;
|
||||||
|
|
||||||
|
// Upper limit on the length of file names in bytes.
|
||||||
|
lfs_size_t name_limit;
|
||||||
|
|
||||||
|
// Upper limit on the size of files in bytes.
|
||||||
|
lfs_size_t file_limit;
|
||||||
|
};
|
||||||
|
|
||||||
//// Custom attribute structure, used to describe custom attributes
|
//// Custom attribute structure, used to describe custom attributes
|
||||||
//// committed atomically during file writes.
|
//// committed atomically during file writes.
|
||||||
//struct lfs_attr {
|
//struct lfs_attr {
|
||||||
@@ -939,6 +959,12 @@ int lfsr_dir_rewind(lfs_t *lfs, lfsr_dir_t *dir);
|
|||||||
|
|
||||||
/// Filesystem-level filesystem operations
|
/// Filesystem-level filesystem operations
|
||||||
|
|
||||||
|
// Find on-disk info about the filesystem
|
||||||
|
//
|
||||||
|
// Fills out the fsinfo structure based on the filesystem found on-disk.
|
||||||
|
// 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 current size of the filesystem
|
||||||
//
|
//
|
||||||
// Note: Result is best effort. If files share COW structures, the returned
|
// Note: Result is best effort. If files share COW structures, the returned
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user