fs/littlefs: stop applying local patches for unknown versions of littlefs

Because they are not expected to apply cleanly.
In that case, disable all features which require the local patches.

Note: lfs_util.patch is actually necessary regardless of
the littlefs version. It should be ok to drop it for the simplest
flat memory model configurations with a single heap though. I plan
to fix it once littlefs 2.9.4 is released.

Tested with esp32s3-devkitc:toywasm + CONFIG_FS_LITTLEFS_VERSION="v2.9.3".
This commit is contained in:
YAMAMOTO Takashi 2024-11-26 20:21:33 +09:00 committed by Xiang Xiao
parent 0157118ead
commit f7e2e23f12
4 changed files with 57 additions and 14 deletions

View file

@ -22,20 +22,30 @@
if(CONFIG_FS_LITTLEFS)
if(NOT EXISTS ${CMAKE_CURRENT_LIST_DIR}/littlefs)
FetchContent_Declare(
littlefs
URL https://github.com/ARMmbed/littlefs/archive/${CONFIG_FS_LITTLEFS_VERSION}.tar.gz
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/littlefs
BINARY_DIR
${CMAKE_BINARY_DIR}/fs/littlefs/littlefs
PATCH_COMMAND
patch -p2 -d ${CMAKE_CURRENT_LIST_DIR} <
${CMAKE_CURRENT_LIST_DIR}/lfs_util.patch && patch -p2 -d
${CMAKE_CURRENT_LIST_DIR} < ${CMAKE_CURRENT_LIST_DIR}/lfs_getpath.patch
&& patch -p2 -d ${CMAKE_CURRENT_LIST_DIR} <
${CMAKE_CURRENT_LIST_DIR}/lfs_getsetattr.patch)
if(CONFIG_FS_LITTLEFS_LOCAL_PATCHES)
FetchContent_Declare(
littlefs
URL https://github.com/ARMmbed/littlefs/archive/${CONFIG_FS_LITTLEFS_VERSION}.tar.gz
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/littlefs
BINARY_DIR
${CMAKE_BINARY_DIR}/fs/littlefs/littlefs
PATCH_COMMAND
patch -p2 -d ${CMAKE_CURRENT_LIST_DIR} <
${CMAKE_CURRENT_LIST_DIR}/lfs_util.patch && patch -p2 -d
${CMAKE_CURRENT_LIST_DIR} <
${CMAKE_CURRENT_LIST_DIR}/lfs_getpath.patch && patch -p2 -d
${CMAKE_CURRENT_LIST_DIR} <
${CMAKE_CURRENT_LIST_DIR}/lfs_getsetattr.patch)
else()
FetchContent_Declare(
littlefs
URL https://github.com/ARMmbed/littlefs/archive/${CONFIG_FS_LITTLEFS_VERSION}.tar.gz
SOURCE_DIR
${CMAKE_CURRENT_LIST_DIR}/littlefs
BINARY_DIR
${CMAKE_BINARY_DIR}/fs/littlefs/littlefs)
endif()
FetchContent_MakeAvailable(littlefs)
endif()

View file

@ -120,13 +120,38 @@ config FS_LITTLEFS_ATTR_MAX
Note: Many of tools to generate LITTLEFS images use 1022
for this by default.
config FS_LITTLEFS_LOCAL_PATCHES
bool
depends on FS_LITTLEFS_VERSION = "v2.5.1"
default y
---help---
For the internal use to control the application of NuttX local
patches for LITTLEFS.
This is NOT expected to be tweaked directly by users.
config FS_LITTLEFS_ATTR_UPDATE
bool "LITTLEFS update attributes"
depends on FS_LITTLEFS_ATTR_MAX > 0
depends on FS_LITTLEFS_LOCAL_PATCHES
default y
---help---
Enable support for attributes when create a file.
CAVEAT: This feature is implemented with NuttX specific
modifications to LITTLEFS v2.5.1. The modifications might
not be compatible with other versions of LITTLEFS.
config FS_LITTLEFS_GETPATH
bool "LITTLEFS FIOC_FILEPATH ioctl support"
depends on FS_LITTLEFS_LOCAL_PATCHES
default y
---help---
FIOC_FILEPATH ioctl support for LITTLEFS file system.
CAVEAT: This feature is implemented with NuttX specific
modifications to LITTLEFS v2.5.1. The modifications might
not be compatible with other versions of LITTLEFS.
config FS_LITTLEFS_VERSION
string "LITTLEFS version to use"
default "v2.5.1"

View file

@ -55,9 +55,11 @@ $(LITTLEFS_TARBALL):
.littlefsunpack: $(LITTLEFS_TARBALL)
$(Q) tar zxf littlefs/$(LITTLEFS_TARBALL) -C littlefs
$(Q) mv littlefs/littlefs-* littlefs/littlefs
ifeq ($(CONFIG_FS_LITTLEFS_LOCAL_PATCHES),y)
$(Q) git apply littlefs/lfs_util.patch
$(Q) git apply littlefs/lfs_getpath.patch
$(Q) git apply littlefs/lfs_getsetattr.patch
endif
$(Q) touch littlefs/.littlefsunpack
# Download and unpack tarball if no git repo found

View file

@ -598,14 +598,18 @@ static off_t littlefs_seek(FAR struct file *filep, off_t offset, int whence)
static int littlefs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
{
FAR struct littlefs_mountpt_s *fs;
#ifdef CONFIG_FS_LITTLEFS_GETPATH
FAR struct littlefs_file_s *priv;
#endif
FAR struct inode *inode;
FAR struct inode *drv;
int ret;
/* Recover our private data from the struct file instance */
#ifdef CONFIG_FS_LITTLEFS_GETPATH
priv = filep->f_priv;
#endif
inode = filep->f_inode;
fs = inode->i_private;
drv = fs->drv;
@ -618,6 +622,7 @@ static int littlefs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
switch (cmd)
{
#ifdef CONFIG_FS_LITTLEFS_GETPATH
case FIOC_FILEPATH:
{
FAR char *path = (FAR char *)(uintptr_t)arg;
@ -637,6 +642,7 @@ static int littlefs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
}
}
break;
#endif
default:
{