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 2022/08/09 15:30:07 UTC
[incubator-nuttx] 01/05: fcntl/O_CLOEXEC: add O_CLOEXEC map for hostfs
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 094e986bbd3514b29afe472b243b89bd4eedf7c9
Author: Jiuzhu Dong <do...@xiaomi.com>
AuthorDate: Fri Jul 29 22:30:31 2022 +0800
fcntl/O_CLOEXEC: add O_CLOEXEC map for hostfs
Signed-off-by: Jiuzhu Dong <do...@xiaomi.com>
---
arch/sim/src/sim/up_hostfs.c | 5 +++++
include/nuttx/fs/hostfs.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/arch/sim/src/sim/up_hostfs.c b/arch/sim/src/sim/up_hostfs.c
index 151799e58f..c3188c5946 100644
--- a/arch/sim/src/sim/up_hostfs.c
+++ b/arch/sim/src/sim/up_hostfs.c
@@ -181,6 +181,11 @@ int host_open(const char *pathname, int flags, nuttx_mode_t mode)
}
#endif
+ if (flags & NUTTX_O_CLOEXEC)
+ {
+ mapflags |= O_CLOEXEC;
+ }
+
int ret = open(pathname, mapflags, mode);
if (ret == -1)
{
diff --git a/include/nuttx/fs/hostfs.h b/include/nuttx/fs/hostfs.h
index 499565b4c6..6773512ef4 100644
--- a/include/nuttx/fs/hostfs.h
+++ b/include/nuttx/fs/hostfs.h
@@ -84,6 +84,7 @@
#define NUTTX_O_SYNC (1 << 7) /* Synchronize output on write */
#define NUTTX_O_BINARY (1 << 8) /* Open the file in binary mode. */
#define NUTTX_O_DIRECT (1 << 9) /* Avoid caching, write directly to hardware */
+#define NUTTX_O_CLOEXEC (1 << 10) /* Close on execute */
#define NUTTX_O_RDWR (NUTTX_O_RDONLY | NUTTX_O_WRONLY)