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:16 UTC
[incubator-nuttx] 01/02: fs/ioctl: using FIOC_FILEPATH instead of
FIOC_FILENAME.
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 **************************************/