This is an automated email from the ASF dual-hosted git repository.

xiaoxiang781216 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 7e4e6dfce13 fs/littlefs: upgrade littlefs to v2.11.2
7e4e6dfce13 is described below

commit 7e4e6dfce13b9c80f9af0667f19eead5c3a4372d
Author: v-liuchenxu3 <[email protected]>
AuthorDate: Fri Nov 20 16:53:32 2026 +0800

    fs/littlefs: upgrade littlefs to v2.11.2
    
    Bump the default CONFIG_FS_LITTLEFS_VERSION from v2.5.1 to v2.11.2 and
    regenerate the two local patches against it, so that
    CONFIG_FS_LITTLEFS_GETPATH and CONFIG_FS_LITTLEFS_ATTR_UPDATE keep
    working on the new version:
    
    - lfs_getpath.patch adds lfs_file_path(), taken from the
      "littlefs: add lfs_file_path for absolute path retrieval" commit by
      v-yanxingyu <[email protected]>.  The unused lfs_dir_path() of
      the old patch is dropped.
    - lfs_getsetattr.patch adds lfs_file_getattr()/lfs_file_setattr(),
      taken from the "littlefs: Add lfs_file_getattr and lfs_file_setattr"
      commit by zhouliang3 <[email protected]>.
    
    lfs_util.patch is removed: littlefs 2.10 added LFS_DEFINES, and
    lfs_nuttx_defines.h already maps LFS_MALLOC/LFS_FREE to fs_heap.
    FS_LITTLEFS_HAS_LFS_DEFINES therefore no longer depends on
    !FS_LITTLEFS_LOCAL_PATCHES.
    
    littlefs v2.11.2 writes on-disk version 2.1 instead of 2.0.  It still
    mounts 2.0 images, and FS_LITTLEFS_MULTI_VERSION with
    FS_LITTLEFS_DISK_VERSION=0x00020000 keeps writing 2.0.  This is
    described in Documentation/os/filesystem/littlefs.rst.
    
    Assisted-by: Kiro:claude-opus-5.5
    Signed-off-by: v-liuchenxu3 <[email protected]>
---
 .github/CODEOWNERS                       |   1 -
 Documentation/os/filesystem/littlefs.rst |  16 ++++
 fs/littlefs/CMakeLists.txt               |   2 -
 fs/littlefs/Kconfig                      |   9 +--
 fs/littlefs/Make.defs                    |   1 -
 fs/littlefs/lfs_getpath.patch            | 125 ++++++++++++-------------------
 fs/littlefs/lfs_getsetattr.patch         |  21 ++++--
 fs/littlefs/lfs_util.patch               |  29 -------
 8 files changed, 84 insertions(+), 120 deletions(-)

diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS
index ef717b332fa..fb8d83b78bb 100644
--- a/.github/CODEOWNERS
+++ b/.github/CODEOWNERS
@@ -13812,7 +13812,6 @@ fs/littlefs/Kconfig [email protected] 
[email protected] [email protected] li
 fs/littlefs/lfs_getpath.patch [email protected]
 fs/littlefs/lfs_getsetattr.patch [email protected] [email protected]
 fs/littlefs/lfs_nuttx_defines.h [email protected]
-fs/littlefs/lfs_util.patch [email protected] [email protected]
 fs/littlefs/lfs_vfs.c [email protected] [email protected] 
[email protected] [email protected] [email protected]
 fs/littlefs/lfs_vfs.h [email protected] [email protected]
 
diff --git a/Documentation/os/filesystem/littlefs.rst 
b/Documentation/os/filesystem/littlefs.rst
index 7eeb477012e..9c202952375 100644
--- a/Documentation/os/filesystem/littlefs.rst
+++ b/Documentation/os/filesystem/littlefs.rst
@@ -30,6 +30,22 @@ well as file operations (``fopen()``, ``fclose()``, etc).
    devices such as flash chips, SD cards and eMMC. Performance on SD cards and
    eMMC devices is worse than flash.
 
+Version and local patches
+=========================
+
+NuttX downloads littlefs ``CONFIG_FS_LITTLEFS_VERSION`` (default ``v2.11.2``)
+at build time. For this default version two NuttX patches are applied, which
+add ``lfs_file_path()`` (used by ``CONFIG_FS_LITTLEFS_GETPATH``) and
+``lfs_file_getattr()``/``lfs_file_setattr()`` (used by
+``CONFIG_FS_LITTLEFS_ATTR_UPDATE``). With any other version the patches are
+skipped and both options are unavailable.
+
+littlefs v2.11.2 writes on-disk version 2.1, while v2.5.1 and earlier wrote
+2.0. littlefs 2.1 mounts 2.0 images and upgrades the superblock on the first
+write. To keep writing 2.0 images, for example for older bootloaders, enable
+``CONFIG_FS_LITTLEFS_MULTI_VERSION`` and set
+``CONFIG_FS_LITTLEFS_DISK_VERSION`` to ``0x00020000``.
+
 User identity and permissions
 =============================
 
diff --git a/fs/littlefs/CMakeLists.txt b/fs/littlefs/CMakeLists.txt
index 9cac37ea337..1d8720042bc 100644
--- a/fs/littlefs/CMakeLists.txt
+++ b/fs/littlefs/CMakeLists.txt
@@ -32,8 +32,6 @@ if(CONFIG_FS_LITTLEFS)
             ${NUTTX_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)
diff --git a/fs/littlefs/Kconfig b/fs/littlefs/Kconfig
index bdb5302a58c..1831768ffab 100644
--- a/fs/littlefs/Kconfig
+++ b/fs/littlefs/Kconfig
@@ -144,7 +144,7 @@ config FS_LITTLEFS_ATTR_MAX
 
 config FS_LITTLEFS_LOCAL_PATCHES
        bool
-       depends on FS_LITTLEFS_VERSION = "v2.5.1"
+       depends on FS_LITTLEFS_VERSION = "v2.11.2"
        default y
        ---help---
                For the internal use to control the application of NuttX local
@@ -153,7 +153,6 @@ config FS_LITTLEFS_LOCAL_PATCHES
 
 config FS_LITTLEFS_HAS_LFS_DEFINES
        bool "Use LFS_DEFINES (available for littlefs >=2.10.0)"
-       depends on !FS_LITTLEFS_LOCAL_PATCHES
        default y
        ---help---
                Set this y if you are using littlefs versions which supports
@@ -172,7 +171,7 @@ config FS_LITTLEFS_ATTR_UPDATE
                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
+               modifications to LITTLEFS v2.11.2. The modifications might
                not be compatible with other versions of LITTLEFS.
 
 config FS_LITTLEFS_GETPATH
@@ -183,12 +182,12 @@ config FS_LITTLEFS_GETPATH
                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
+               modifications to LITTLEFS v2.11.2. The modifications might
                not be compatible with other versions of LITTLEFS.
 
 config FS_LITTLEFS_VERSION
        string "LITTLEFS version to use"
-       default "v2.5.1"
+       default "v2.11.2"
        ---help---
                The LITTLEFS version to use.
 
diff --git a/fs/littlefs/Make.defs b/fs/littlefs/Make.defs
index 32744c6ad8a..60f5316e701 100644
--- a/fs/littlefs/Make.defs
+++ b/fs/littlefs/Make.defs
@@ -68,7 +68,6 @@ $(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
diff --git a/fs/littlefs/lfs_getpath.patch b/fs/littlefs/lfs_getpath.patch
index 57be37a73a2..396b00a8444 100644
--- a/fs/littlefs/lfs_getpath.patch
+++ b/fs/littlefs/lfs_getpath.patch
@@ -1,147 +1,118 @@
-From 696dfa6ce29cb44d22e48bf66032e217383d8a2f Mon Sep 17 00:00:00 2001
-From: zhouliang3 <[email protected]>
-Date: Tue, 24 Aug 2021 12:48:22 +0800
-Subject: [PATCH] fs/littlefs: Add the function of obtaining absolute path
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: v-yanxingyu <[email protected]>
+Date: Mon, 11 May 2026 11:42:05 +0800
+Subject: [PATCH] littlefs: add lfs_file_path for absolute path retrieval
 
-Signed-off-by: zhouliang3 <[email protected]>
+Add lfs_file_path() to retrieve the absolute path of an open file
+handle. Required by NuttX VFS layer for FIOC_FILEPATH ioctl and
+fstat/fchstat (via libc path-based lfs_getattr/lfs_setattr APIs).
+
+The implementation adds:
+- Static helper lfs_dir_path_() placed in Directory operations
+  section, grouped with other lfs_dir_*_ helpers.
+- Public API lfs_file_path() that follows lfs_file_size() template
+  (LFS_LOCK/TRACE/ASSERT pattern, returns lfs_ssize_t).
+
+Signed-off-by: v-yanxingyu <[email protected]>
 ---
- lfs.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
- lfs.h |  8 ++++++
- 2 files changed, 87 insertions(+)
+ lfs.c | 58 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
+ lfs.h |  7 +++++++
+ 2 files changed, 65 insertions(+)
 
 --- ./littlefs/littlefs/lfs.c
 +++ ./littlefs/littlefs/lfs.c
-@@ -542,6 +542,8 @@ static uint16_t lfs_fs_disk_version_minor(lfs_t *lfs) {
- 
+@@ -588,6 +588,8 @@ static int lfs1_traverse(lfs_t *lfs,
+ #endif
  
- /// Internal operations predeclared here ///
-+static lfs_ssize_t lfs_dir_rawpath(lfs_t *lfs,
+ static int lfs_dir_rewind_(lfs_t *lfs, lfs_dir_t *dir);
++static lfs_ssize_t lfs_dir_path_(lfs_t *lfs,
 +        lfs_mdir_t *dir, uint16_t id, char *path, lfs_size_t size);
- #ifndef LFS_READONLY
- static int lfs_dir_commit(lfs_t *lfs, lfs_mdir_t *dir,
-         const struct lfs_mattr *attrs, int attrcount);
-@@ -3790,6 +3792,53 @@ static lfs_soff_t lfs_file_rawsize(lfs_t *lfs, 
lfs_file_t *file) {
-     return file->ctz.size;
+ 
+ static lfs_ssize_t lfs_file_flushedread(lfs_t *lfs, lfs_file_t *file,
+         void *buffer, lfs_size_t size);
+@@ -2868,6 +2870,46 @@ static int lfs_dir_rewind_(lfs_t *lfs, lfs_dir_t *dir) {
+     return 0;
  }
  
-+static lfs_ssize_t lfs_dir_rawpath(lfs_t *lfs,
-+         lfs_mdir_t *dir, uint16_t id, char *path, lfs_size_t size) {
++static lfs_ssize_t lfs_dir_path_(lfs_t *lfs,
++        lfs_mdir_t *dir, uint16_t id, char *path, lfs_size_t size) {
 +    struct lfs_info info;
 +    char *next = path;
 +    lfs_mdir_t parent;
 +    lfs_ssize_t len;
 +    lfs_stag_t tag;
 +    int err;
-+
 +    if (lfs_pair_cmp(lfs->root, dir->pair) != 0) {
 +        tag = lfs_fs_parent(lfs, dir->pair, &parent);
 +        if (tag < 0) {
 +            return tag;
 +        }
-+
-+        len = lfs_dir_rawpath(lfs, &parent, lfs_tag_id(tag), next, size);
++        len = lfs_dir_path_(lfs, &parent, lfs_tag_id(tag), next, size);
 +        if (len < 0) {
 +            return len;
 +        }
-+
 +        next += len;
 +        size -= len;
 +    }
-+
 +    err = lfs_dir_getinfo(lfs, dir, id, &info);
 +    if (err < 0) {
 +        return err;
 +    }
-+
 +    len = strlen(info.name);
-+    if (len >= size) {
++    if (len >= (lfs_ssize_t)size) {
 +        return LFS_ERR_INVAL;
 +    }
-+
 +    memcpy(next, info.name, len + 1);
 +    next += len;
-+
 +    if (info.type == LFS_TYPE_DIR) {
 +        *next++ = '/';
-+        if (++len >= size) {
++        if (++len >= (lfs_ssize_t)size) {
 +            return LFS_ERR_INVAL;
 +        }
 +        *next = '\0';
 +    }
-+
 +    return next - path;
 +}
++
  
- /// General fs operations ///
- static int lfs_rawstat(lfs_t *lfs, const char *path, struct lfs_info *info) {
-@@ -6042,6 +6091,22 @@ lfs_soff_t lfs_file_size(lfs_t *lfs, lfs_file_t *file) {
+ /// File index list operations ///
+ static int lfs_ctz_index(lfs_t *lfs, lfs_off_t *off) {
+@@ -6322,6 +6364,22 @@ lfs_soff_t lfs_file_size(lfs_t *lfs, lfs_file_t *file) {
      return res;
  }
  
-+int lfs_file_path(lfs_t *lfs, lfs_file_t *file, char *path, lfs_size_t size) {
++lfs_ssize_t lfs_file_path(lfs_t *lfs, lfs_file_t *file, char *path, 
lfs_size_t size) {
 +    int err = LFS_LOCK(lfs->cfg);
 +    if (err) {
 +        return err;
 +    }
-+
-+    LFS_TRACE("lfs_file_path(%p, %p)", (void*)lfs, (void*)file);
++    LFS_TRACE("lfs_file_path(%p, %p, %p, %"PRIu32")",
++            (void*)lfs, (void*)file, (void*)path, size);
 +    LFS_ASSERT(lfs_mlist_isopen(lfs->mlist, (struct lfs_mlist*)file));
 +
-+    err = lfs_dir_rawpath(lfs, &file->m, file->id, path, size);
++    lfs_ssize_t res = lfs_dir_path_(lfs, &file->m, file->id, path, size);
 +
-+    LFS_TRACE("lfs_file_path -> %d", err);
++    LFS_TRACE("lfs_file_path -> %"PRId32, res);
 +    LFS_UNLOCK(lfs->cfg);
-+    return err < 0 ? err : 0;
++    return res;
 +}
 +
  #ifndef LFS_READONLY
  int lfs_mkdir(lfs_t *lfs, const char *path) {
      int err = LFS_LOCK(lfs->cfg);
-@@ -6173,6 +6238,20 @@ lfs_ssize_t lfs_fs_size(lfs_t *lfs) {
-     return res;
- }
- 
-+int lfs_dir_path(lfs_t *lfs, lfs_dir_t *dir, char *path, lfs_size_t size) {
-+    int err = LFS_LOCK(lfs->cfg);
-+    if (err) {
-+        return err;
-+    }
-+
-+    LFS_TRACE("lfs_dir_path(%p, %p)", (void*)lfs, (void*)dir);
-+    err = lfs_dir_rawpath(lfs, &dir->m, dir->id, path, size);
-+
-+    LFS_TRACE("lfs_dir_path -> %d", err);
-+    LFS_UNLOCK(lfs->cfg);
-+    return err < 0 ? err : 0;
-+}
-+
- int lfs_fs_traverse(lfs_t *lfs, int (*cb)(void *, lfs_block_t), void *data) {
-     int err = LFS_LOCK(lfs->cfg);
-     if (err) {
 --- ./littlefs/littlefs/lfs.h
 +++ ./littlefs/littlefs/lfs.h
-@@ -629,6 +629,10 @@ int lfs_file_rewind(lfs_t *lfs, lfs_file_t *file);
+@@ -656,6 +656,13 @@ int lfs_file_rewind(lfs_t *lfs, lfs_file_t *file);
  // Returns the size of the file, or a negative error code on failure.
  lfs_soff_t lfs_file_size(lfs_t *lfs, lfs_file_t *file);
  
 +// Get the absolute path of the open file.
 +//
-+// Returns a negative error code on failure.
-+int lfs_file_path(lfs_t *lfs, lfs_file_t *file, char *path, lfs_size_t size);
++// Returns the length of the path written to the path buffer (not including
++// the null terminator), or a negative error code on failure.
++lfs_ssize_t lfs_file_path(lfs_t *lfs, lfs_file_t *file,
++        char *path, lfs_size_t size);
++
  
  /// Directory operations ///
  
-@@ -679,6 +683,10 @@ lfs_soff_t lfs_dir_tell(lfs_t *lfs, lfs_dir_t *dir);
- // Returns a negative error code on failure.
- int lfs_dir_rewind(lfs_t *lfs, lfs_dir_t *dir);
- 
-+// Get the absolute path of the directory
-+//
-+// Returns a negative error code on failure.
-+int lfs_dir_path(lfs_t *lfs, lfs_dir_t *dir, char *path, lfs_size_t size);
- 
- /// Filesystem-level filesystem operations
- 
--- 
-2.25.1
-
diff --git a/fs/littlefs/lfs_getsetattr.patch b/fs/littlefs/lfs_getsetattr.patch
index 1ac149f5d82..6a002ee0976 100644
--- a/fs/littlefs/lfs_getsetattr.patch
+++ b/fs/littlefs/lfs_getsetattr.patch
@@ -1,7 +1,18 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: zhouliang3 <[email protected]>
+Date: Thu, 9 Sep 2021 20:02:15 +0800
+Subject: [PATCH] littlefs: Add lfs_file_getattr and lfs_file_setattr
+
+Signed-off-by: zhouliang3 <[email protected]>
+---
+ lfs.c | 35 +++++++++++++++++++++++++++++++++++
+ lfs.h | 27 +++++++++++++++++++++++++++
+ 2 files changed, 62 insertions(+)
+
 --- ./littlefs/littlefs/lfs.c
 +++ ./littlefs/littlefs/lfs.c
-@@ -5717,6 +5717,41 @@ int lfs_file_path(lfs_t *lfs, lfs_file_t *file, char 
*path, lfs_size_t size) {
-     return err < 0 ? err : 0;
+@@ -6380,6 +6380,41 @@ lfs_ssize_t lfs_file_path(lfs_t *lfs, lfs_file_t *file, 
char *path, lfs_size_t s
+     return res;
  }
  
 +lfs_ssize_t lfs_file_getattr(lfs_t *lfs, lfs_file_t *file,
@@ -44,9 +55,9 @@
      int err = LFS_LOCK(lfs->cfg);
 --- ./littlefs/littlefs/lfs.h
 +++ ./littlefs/littlefs/lfs.h
-@@ -611,6 +611,33 @@ lfs_soff_t lfs_file_size(lfs_t *lfs, lfs_file_t *file);
- // Returns a negative error code on failure.
- int lfs_file_path(lfs_t *lfs, lfs_file_t *file, char *path, lfs_size_t size);
+@@ -664,6 +664,33 @@ lfs_ssize_t lfs_file_path(lfs_t *lfs, lfs_file_t *file,
+         char *path, lfs_size_t size);
+ 
  
 +// Get a custom attribute of file
 +//
diff --git a/fs/littlefs/lfs_util.patch b/fs/littlefs/lfs_util.patch
deleted file mode 100644
index a9052969de2..00000000000
--- a/fs/littlefs/lfs_util.patch
+++ /dev/null
@@ -1,29 +0,0 @@
---- ./littlefs/littlefs/lfs_util.h     2022-11-11 03:32:30.000000000 +1100
-+++ ./littlefs/littlefs/lfs_util.h     2023-04-21 12:25:27.987084276 +1000
-@@ -28,6 +28,8 @@
-
- #ifndef LFS_NO_MALLOC
- #include <stdlib.h>
-+#include <nuttx/mm/mm.h>
-+#include "fs_heap.h"
- #endif
- #ifndef LFS_NO_ASSERT
- #include <assert.h>
-@@ -218,7 +219,7 @@
- // Note, memory must be 64-bit aligned
- static inline void *lfs_malloc(size_t size) {
- #ifndef LFS_NO_MALLOC
--    return malloc(size);
-+    return fs_heap_malloc(size);
- #else
-     (void)size;
-     return NULL;
-@@ -228,7 +229,7 @@
- // Deallocate memory, only used if buffers are not provided to littlefs
- static inline void lfs_free(void *p) {
- #ifndef LFS_NO_MALLOC
--    free(p);
-+    fs_heap_free(p);
- #else
-     (void)p;
- #endif

Reply via email to