Changed fsinfo.minor_version -> fsinfo.disk_version

Version are now returned with major/minor packed into 32-bits,
so 0x00020001 is the current disk version, for example.

1. This needed to change to use a disk_* prefix for consistency with the
   defines that already exist for LFS_VERSION/LFS_DISK_VERSION.

2. Encoding the version this way has the nice side effect of making 0 an
   invalid value. This is useful for adding a similar config option
   that needs to have reasonable default behavior for backwards
   compatibility.

In theory this uses more space, but in practice most other config/status
is 32-bits in littlefs. We would be wasting this space for alignment
anyways.
This commit is contained in:
Christopher Haster
2023-06-06 21:52:04 -05:00
parent 8610f7c36b
commit c5fb3f181b
4 changed files with 20 additions and 20 deletions
+3 -3
View File
@@ -4424,7 +4424,7 @@ static int lfs_fs_rawstat(lfs_t *lfs, struct lfs_fsinfo *fsinfo) {
// if the superblock is up-to-date, we must be on the most recent
// minor version of littlefs
if (!lfs_gstate_needssuperblock(&lfs->gstate)) {
fsinfo->minor_version = LFS_DISK_VERSION_MINOR;
fsinfo->disk_version = LFS_DISK_VERSION;
// otherwise we need to read the minor version on disk
} else {
@@ -4444,8 +4444,8 @@ static int lfs_fs_rawstat(lfs_t *lfs, struct lfs_fsinfo *fsinfo) {
}
lfs_superblock_fromle32(&superblock);
// read the minor version
fsinfo->minor_version = (0xffff & (superblock.version >> 0));
// read the on-disk version
fsinfo->disk_version = superblock.version;
}
// find the current block usage