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:17 UTC

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

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)