You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2021/09/13 00:56:15 UTC

[incubator-nuttx] branch master updated (7a68470 -> 2cfda2b)

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

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


    from 7a68470  mkromfsimg: Add optional rcS file path
     new 6df9d19  fs/ioctl: using FIOC_FILEPATH instead of FIOC_FILENAME.
     new 2cfda2b  binfmt: remove file_ioctl and get filename by strrchr

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:
 binfmt/builtin.c         | 18 +++++-------------
 fs/binfs/fs_binfs.c      | 20 +++++++++++++-------
 include/nuttx/fs/ioctl.h |  9 ++-------
 3 files changed, 20 insertions(+), 27 deletions(-)

[incubator-nuttx] 01/02: fs/ioctl: using FIOC_FILEPATH instead of FIOC_FILENAME.

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

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

commit 6df9d1907c55d66c77ca64806590c39ab5d55c5b
Author: Jiuzhu Dong <do...@xiaomi.com>
AuthorDate: Tue Aug 31 16:00:59 2021 +0800

    fs/ioctl: using FIOC_FILEPATH instead of FIOC_FILENAME.
    
    Signed-off-by: Jiuzhu Dong <do...@xiaomi.com>
---
 fs/binfs/fs_binfs.c      | 20 +++++++++++++-------
 include/nuttx/fs/ioctl.h |  9 ++-------
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/fs/binfs/fs_binfs.c b/fs/binfs/fs_binfs.c
index eaa49b2..9ccf992 100644
--- a/fs/binfs/fs_binfs.c
+++ b/fs/binfs/fs_binfs.c
@@ -42,6 +42,8 @@
 #include <nuttx/fs/ioctl.h>
 #include <nuttx/lib/builtin.h>
 
+#include "inode/inode.h"
+
 #if !defined(CONFIG_DISABLE_MOUNTPOINT) && defined(CONFIG_FS_BINFS)
 
 /****************************************************************************
@@ -196,22 +198,26 @@ static int binfs_ioctl(FAR struct file *filep, int cmd, unsigned long arg)
 
   /* Only one IOCTL command is supported */
 
-  if (cmd == FIOC_FILENAME)
+  if (cmd == FIOC_FILEPATH)
     {
-      /* IN:  FAR char const ** pointer
-       * OUT: Pointer to a persistent file name (Guaranteed to persist while
-       *      the file is open).
+      /* IN:  FAR char *(length >= PATH_MAX)
+       * OUT: The full file path
        */
 
-      FAR const char **ptr = (FAR const char **)((uintptr_t)arg);
+      FAR char *ptr = (FAR char *)((uintptr_t)arg);
       if (ptr == NULL)
         {
           ret = -EINVAL;
         }
       else
         {
-          *ptr = builtin_getname((int)((uintptr_t)filep->f_priv));
-          ret = OK;
+          ret = inode_getpath(filep->f_inode, ptr);
+          if (ret < 0)
+            {
+              return ret;
+            }
+
+          strcat(ptr, builtin_getname((int)((uintptr_t)filep->f_priv)));
         }
     }
   else
diff --git a/include/nuttx/fs/ioctl.h b/include/nuttx/fs/ioctl.h
index d02b6c9..1e84674 100644
--- a/include/nuttx/fs/ioctl.h
+++ b/include/nuttx/fs/ioctl.h
@@ -140,10 +140,8 @@
                                            *      (ignored on most file systems)
                                            * OUT: None
                                            */
-#define FIOC_FILENAME   _FIOC(0x0004)     /* IN:  FAR const char ** pointer
-                                           * OUT: Pointer to a persistent file name
-                                           *      (Guaranteed to persist while the
-                                           *      file is open).
+#define FIOC_FILEPATH   _FIOC(0x0004)     /* IN:  FAR char *(length >= PATH_MAX)
+                                           * OUT: The full file path
                                            */
 #define FIOC_INTEGRITY  _FIOC(0x0005)     /* Run a consistency check on the
                                            *      file system media.
@@ -181,9 +179,6 @@
 #define FIONCLEX        _FIOC(0x000e)     /* IN:  None
                                            * OUT: None
                                            */
-#define FIOC_FILEPATH   _FIOC(0x000f)     /* IN:  FAR char *(length >= PATH_MAX)
-                                           * OUT: The full file path
-                                           */
 
 /* NuttX file system ioctl definitions **************************************/
 

[incubator-nuttx] 02/02: binfmt: remove file_ioctl and get filename by strrchr

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

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

commit 2cfda2bffdde328bfb98d87cb4be90d96086007d
Author: Jiuzhu Dong <do...@xiaomi.com>
AuthorDate: Tue Aug 31 15:58:16 2021 +0800

    binfmt: remove file_ioctl and get filename by strrchr
    
    Signed-off-by: Jiuzhu Dong <do...@xiaomi.com>
---
 binfmt/builtin.c | 18 +++++-------------
 1 file changed, 5 insertions(+), 13 deletions(-)

diff --git a/binfmt/builtin.c b/binfmt/builtin.c
index d6d79c1..e226209 100644
--- a/binfmt/builtin.c
+++ b/binfmt/builtin.c
@@ -78,6 +78,7 @@ static int builtin_loadbinary(FAR struct binary_s *binp,
                               int nexports)
 {
   FAR const struct builtin_s *builtin;
+  FAR char *name;
   struct file file;
   int index;
   int ret;
@@ -93,22 +94,13 @@ static int builtin_loadbinary(FAR struct binary_s *binp,
       return ret;
     }
 
-  /* If this file is a BINFS file system, then we can recover the name of
-   * the file using the FIOC_FILENAME ioctl() call.
-   */
-
-  ret = file_ioctl(&file, FIOC_FILENAME,
-                   (unsigned long)((uintptr_t)&filename));
-  if (ret < 0)
+  name = strrchr(filename, '/');
+  if (name != NULL)
     {
-      berr("ERROR: FIOC_FILENAME ioctl failed: %d\n", ret);
-      file_close(&file);
-      return ret;
+      filename = name + 1;
     }
 
-  /* Other file systems may also support FIOC_FILENAME, so the real proof
-   * is that we can look up the index to this name in g_builtins[].
-   */
+  /* Looking up the index to this name in g_builtins[] */
 
   index = builtin_isavail(filename);
   if (index < 0)