You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by ag...@apache.org on 2020/09/22 22:05:20 UTC

[incubator-nuttx] branch master updated (5ffb1c6 -> de45e86)

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

aguettouche pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git.


    from 5ffb1c6  Fix Cygwin build broken by commit 34b34e2d451
     new 8567637  fs/fat: Handle the tail '/' correctly
     new de45e86  Revert "s/dirent:  Corrects a problem with opendir() noted by Petteri Aimonen in Bitbucket Issue 132: "opendir() fails for FAT filesystem with trailing slash in path":"

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 fs/dirent/fs_opendir.c  | 64 +------------------------------------------------
 fs/fat/fs_fat32dirent.c |  5 ++++
 2 files changed, 6 insertions(+), 63 deletions(-)


[incubator-nuttx] 02/02: Revert "s/dirent: Corrects a problem with opendir() noted by Petteri Aimonen in Bitbucket Issue 132: "opendir() fails for FAT filesystem with trailing slash in path":"

Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit de45e8647a68f5ba7afac563658a6cd297ce1b93
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Tue Sep 22 14:54:59 2020 +0800

    Revert "s/dirent:  Corrects a problem with opendir() noted by Petteri Aimonen in Bitbucket Issue 132: "opendir() fails for FAT filesystem with trailing slash in path":"
    
    because:
    1.The name of directory may terminated by the whitespace
    2.inode_search can handle the trailing '/' correctly
    3.Let fix the issue in FAT filesystem instead
    
    This reverts commit 97b0235d77ff4ee7c8eb5288b2a001a1d12bf707.
---
 fs/dirent/fs_opendir.c | 64 +-------------------------------------------------
 1 file changed, 1 insertion(+), 63 deletions(-)

diff --git a/fs/dirent/fs_opendir.c b/fs/dirent/fs_opendir.c
index 9082aa4..687cc12 100644
--- a/fs/dirent/fs_opendir.c
+++ b/fs/dirent/fs_opendir.c
@@ -26,7 +26,6 @@
 
 #include <stdbool.h>
 #include <string.h>
-#include <ctype.h>
 #include <dirent.h>
 #include <assert.h>
 #include <errno.h>
@@ -217,52 +216,8 @@ FAR DIR *opendir(FAR const char *path)
 #ifndef CONFIG_DISABLE_MOUNTPOINT
   FAR const char *relpath = NULL;
 #endif
-  FAR char *alloc = NULL;
-  int len;
   int ret;
 
-  /* Strip off any trailing whitespace or '/' characters.  In this case we
-   * must make a copy of the user string so we can chop off bytes on the
-   * 'right' without modifying the user's const string.
-   */
-
-  if (path != NULL)
-    {
-      /* Length of the string excludes NUL terminator */
-
-      len = strlen(path);
-
-      /* Check for whitespace or a dangling '/' at the end of the string.
-       * But don't muck with the string any further if it has been reduced
-       * to "/"
-       */
-
-      while (len > 0 && strcmp(path, "/") != 0 &&
-             (isspace(path[len - 1]) || path[len - 1] == '/'))
-        {
-          /* Have we already allocated memory for the modified string? */
-
-          if (alloc == NULL)
-            {
-              alloc = strdup(path); /* Allocates one too many bytes */
-              if (alloc == NULL)
-                {
-                  ret = ENOMEM;
-                  goto errout;
-                }
-
-              /* Use the cloned, writable string instead of the user string */
-
-              path = alloc;
-            }
-
-          /* Chop off the final character */
-
-          len--;
-          alloc[len] = '\0';
-        }
-    }
-
   /* If we are given 'nothing' then we will interpret this as
    * request for the root inode.
    */
@@ -273,7 +228,7 @@ FAR DIR *opendir(FAR const char *path)
   if (ret < 0)
     {
       ret = -ret;
-      goto errout_with_alloc;
+      goto errout;
     }
 
   /* We don't know what to do with relative paths */
@@ -375,14 +330,6 @@ FAR DIR *opendir(FAR const char *path)
 
   RELEASE_SEARCH(&desc);
   inode_semgive();
-
-  /* Free any allocated string memory */
-
-  if (alloc != NULL)
-    {
-      kmm_free(alloc);
-    }
-
   return ((FAR DIR *)dir);
 
   /* Nasty goto's make error handling simpler */
@@ -394,15 +341,6 @@ errout_with_semaphore:
   RELEASE_SEARCH(&desc);
   inode_semgive();
 
-errout_with_alloc:
-
-  /* Free any allocated string memory */
-
-  if (alloc != NULL)
-    {
-      kmm_free(alloc);
-    }
-
 errout:
   set_errno(ret);
   return NULL;


[incubator-nuttx] 01/02: fs/fat: Handle the tail '/' correctly

Posted by ag...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 856763737813c864aab5738eb2482dc4331c0b0f
Author: Xiang Xiao <xi...@xiaomi.com>
AuthorDate: Tue Sep 22 14:44:41 2020 +0800

    fs/fat: Handle the tail '/' correctly
    
    Signed-off-by: Xiang Xiao <xi...@xiaomi.com>
    Change-Id: I72c4d018c174d094d777941d0679ad792a1f5527
---
 fs/fat/fs_fat32dirent.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/fs/fat/fs_fat32dirent.c b/fs/fat/fs_fat32dirent.c
index bf85f80..8ba2aae 100644
--- a/fs/fat/fs_fat32dirent.c
+++ b/fs/fat/fs_fat32dirent.c
@@ -2656,6 +2656,11 @@ int fat_finddirentry(FAR struct fat_mountpt_s *fs,
           return -ENOTDIR;
         }
 
+      if (*path == '\0')
+        {
+          return OK;
+        }
+
       /* Get the cluster number of this directory */
 
       cluster =