fs/littlefs: add LFS_MULTIVERSION support

This commit is contained in:
YAMAMOTO Takashi 2024-11-26 16:41:02 +09:00 committed by Xiang Xiao
parent abd769dcb0
commit 610c72ccd0
4 changed files with 26 additions and 1 deletions

View file

@ -59,7 +59,8 @@ if(CONFIG_FS_LITTLEFS)
-DLFS_CONFIG=${CMAKE_CURRENT_LIST_DIR}/lfs_vfs.h
-DLFS_NAME_MAX=${CONFIG_FS_LITTLEFS_NAME_MAX}
-DLFS_FILE_MAX=${CONFIG_FS_LITTLEFS_FILE_MAX}
-DLFS_ATTR_MAX=${CONFIG_FS_LITTLEFS_ATTR_MAX})
-DLFS_ATTR_MAX=${CONFIG_FS_LITTLEFS_ATTR_MAX}
$<$<BOOL:${CONFIG_FS_LITTLEFS_MULTI_VERSION}>:-DLFS_MULTIVERSION>)
# Note: the littlefs upstream doesn't seems to care -Wshadow cf.
# https://github.com/littlefs-project/littlefs/pull/873

View file

@ -158,4 +158,21 @@ config FS_LITTLEFS_VERSION
---help---
The LITTLEFS version to use.
config FS_LITTLEFS_MULTI_VERSION
bool "Support multiple on-disk versions"
default n
---help---
Enable LFS_MULTIVERSION for LITTLEFS file system
config FS_LITTLEFS_DISK_VERSION
hex "LITTLEFS on-disk version"
default 0x0
depends on FS_LITTLEFS_MULTI_VERSION
---help---
The LITTLEFS disk version to use.
0 means to leave it to the default from the LITTLEFS.
0x00020000 means 2.0.
0x00020001 means 2.1.
endif

View file

@ -50,6 +50,9 @@ CFLAGS += -DLFS_CONFIG=../lfs_vfs.h
CFLAGS += -DLFS_NAME_MAX=$(CONFIG_FS_LITTLEFS_NAME_MAX)
CFLAGS += -DLFS_FILE_MAX=$(CONFIG_FS_LITTLEFS_FILE_MAX)
CFLAGS += -DLFS_ATTR_MAX=$(CONFIG_FS_LITTLEFS_ATTR_MAX)
ifeq ($(CONFIG_FS_LITTLEFS_MULTI_VERSION),y)
CFLAGS += -DLFS_MULTIVERSION
endif
LITTLEFS_TARBALL = $(CONFIG_FS_LITTLEFS_VERSION).tar.gz

View file

@ -1323,6 +1323,10 @@ static int littlefs_bind(FAR struct inode *driver, FAR const void *data,
fs->cfg.lookahead_size = CONFIG_FS_LITTLEFS_LOOKAHEAD_SIZE;
#endif
#ifdef CONFIG_FS_LITTLEFS_MULTI_VERSION
fs->cfg.disk_version = CONFIG_FS_LITTLEFS_DISK_VERSION;
#endif
/* Then get information about the littlefs filesystem on the devices
* managed by this driver.
*/