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 ee456c2416d fs/9p: Skip printing long filenames and print only 
filenames that meet the length requirement.
ee456c2416d is described below

commit ee456c2416da06dc6db9d46e57e6bcb9aaa8d4a1
Author: wangmingrong1 <[email protected]>
AuthorDate: Mon Nov 2 18:59:11 2026 +0800

    fs/9p: Skip printing long filenames and print only filenames that meet the 
length requirement.
    
    VFS does not support printing this error, making it inconvenient to use.
    
    Signed-off-by: wangmingrong1 <[email protected]>
---
 fs/v9fs/client.c | 13 +++++++++----
 fs/v9fs/v9fs.c   |  3 ++-
 2 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/fs/v9fs/client.c b/fs/v9fs/client.c
index aae85210aea..3dff3d821c0 100644
--- a/fs/v9fs/client.c
+++ b/fs/v9fs/client.c
@@ -1233,15 +1233,20 @@ ssize_t v9fs_client_convertdir(FAR const uint8_t 
*buffer, size_t bufsize,
       return -EIO;
     }
 
-  /* Copy the file name to entry->d_name and null-terminate it */
+  /* Copy the file name to entry->d_name and null-terminate it.
+   * If the name exceeds NAME_MAX, skip this entry silently.
+   */
 
   if (name_len > NAME_MAX)
     {
-      return -ENAMETOOLONG;
+      entry->d_name[0] = '\0';
+    }
+  else
+    {
+      memcpy(entry->d_name, buffer + next, name_len);
+      entry->d_name[name_len] = '\0';
     }
 
-  memcpy(entry->d_name, buffer + next, name_len);
-  entry->d_name[name_len] = '\0';
   next += name_len;
   *offset = off;
 
diff --git a/fs/v9fs/v9fs.c b/fs/v9fs/v9fs.c
index dbebbadce97..633b0028f43 100644
--- a/fs/v9fs/v9fs.c
+++ b/fs/v9fs/v9fs.c
@@ -695,7 +695,8 @@ static int v9fs_vfs_readdir(FAR struct inode *mountpt,
 
       fsdir->head += ret;
       if (strcmp(entry->d_name, ".") != 0 &&
-          strcmp(entry->d_name, "..") != 0)
+          strcmp(entry->d_name, "..") != 0 &&
+          entry->d_name[0] != '\0')
         {
           break;
         }

Reply via email to