diff --git a/fs/littlefs/CMakeLists.txt b/fs/littlefs/CMakeLists.txt index b81e07405e6..4ce674d781a 100644 --- a/fs/littlefs/CMakeLists.txt +++ b/fs/littlefs/CMakeLists.txt @@ -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() diff --git a/fs/littlefs/Kconfig b/fs/littlefs/Kconfig index 517d500ef06..af8af03fe38 100644 --- a/fs/littlefs/Kconfig +++ b/fs/littlefs/Kconfig @@ -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" diff --git a/fs/littlefs/Make.defs b/fs/littlefs/Make.defs index afabeb94079..ae73a36f076 100644 --- a/fs/littlefs/Make.defs +++ b/fs/littlefs/Make.defs @@ -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 diff --git a/fs/littlefs/lfs_vfs.c b/fs/littlefs/lfs_vfs.c index 55f127314c1..09601421348 100644 --- a/fs/littlefs/lfs_vfs.c +++ b/fs/littlefs/lfs_vfs.c @@ -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: {