[PATCH 1/2] Support O_CLOEXEC open() flag
Sebastian Huber
sebastian.huber at embedded-brains.de
Thu Oct 18 10:42:58 UTC 2018
Make sure this flag is ignored and does not prevent a successful open.
Close #3547.
---
testsuites/psxtests/psxfile01/test.c | 32 ++++++++++++++++++++++++++++----
1 file changed, 28 insertions(+), 4 deletions(-)
diff --git a/testsuites/psxtests/psxfile01/test.c b/testsuites/psxtests/psxfile01/test.c
index dbdce86be8..129412d3ef 100644
--- a/testsuites/psxtests/psxfile01/test.c
+++ b/testsuites/psxtests/psxfile01/test.c
@@ -57,6 +57,8 @@ char test_write_buffer[ 1024 ];
rtems_filesystem_operations_table IMFS_ops_no_evalformake;
rtems_filesystem_operations_table IMFS_ops_no_rename;
+static const char somefile[] = "somefile";
+
/*
* File test support routines.
*/
@@ -132,11 +134,10 @@ void stat_a_file(
static void test_open_directory(void)
{
- static const char file[] = "somefile";
int status;
int fd;
- fd = open( file, O_CREAT, S_IRWXU );
+ fd = open( somefile, O_CREAT, S_IRWXU );
rtems_test_assert( fd >= 0 );
status = close( fd );
@@ -144,12 +145,34 @@ static void test_open_directory(void)
#ifdef O_DIRECTORY
errno = 0;
- fd = open( file, O_DIRECTORY, S_IRWXU );
+ fd = open( somefile, O_DIRECTORY, S_IRWXU );
rtems_test_assert( fd == -1 );
rtems_test_assert( errno == ENOTDIR );
#endif
- status = unlink( file );
+ status = unlink( somefile );
+ rtems_test_assert( status == 0 );
+}
+
+static void test_open_cloexec(void)
+{
+ int status;
+ int fd;
+ mode_t mode;
+
+ mode = O_CREAT;
+
+#ifdef O_CLOEXEC
+ mode |= O_CLOEXEC;
+#endif
+
+ fd = open( somefile, mode, S_IRWXU );
+ rtems_test_assert( fd >= 0 );
+
+ status = close( fd );
+ rtems_test_assert( status == 0 );
+
+ status = unlink( somefile );
rtems_test_assert( status == 0 );
}
@@ -185,6 +208,7 @@ int main(
TEST_BEGIN();
test_open_directory();
+ test_open_cloexec();
/*
* Grab the maximum size of an in-memory file.
--
2.16.4
More information about the devel
mailing list