You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/09/12 03:44:56 UTC

[GitHub] [incubator-nuttx] xiaoxiang781216 commented on a change in pull request #4514: fs/ioctl: using FIOC_FILEPATH instead of FIOC_FILENAME

xiaoxiang781216 commented on a change in pull request #4514:
URL: https://github.com/apache/incubator-nuttx/pull/4514#discussion_r706740295



##########
File path: fs/binfs/fs_binfs.c
##########
@@ -196,22 +198,27 @@ 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, "/");

Review comment:
       inode_getpath already add the tail slash?




-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org