[rtems commit] PR2160: imfs: Use ENOSYS for unsupported nodes

Sebastian Huber sebh at rtems.org
Wed Dec 11 08:51:20 UTC 2013


Module:    rtems
Branch:    master
Commit:    98e5c954bdb40d0e66d33eedcdd157fcbecbb114
Changeset: http://git.rtems.org/rtems/commit/?id=98e5c954bdb40d0e66d33eedcdd157fcbecbb114

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Dec 11 09:39:09 2013 +0100

PR2160: imfs: Use ENOSYS for unsupported nodes

Return an error status with errno set to ENOSYS during node creation for
nodes not available in the current configuration.

---

 cpukit/libfs/src/imfs/imfs.h          |    2 +-
 cpukit/libfs/src/imfs/imfs_init.c     |    2 +-
 cpukit/libfs/src/imfs/imfs_initsupp.c |   15 +++++++++++++--
 cpukit/libfs/src/imfs/miniimfs_init.c |    6 +++---
 testsuites/sptests/spfifo01/init.c    |   19 ++++---------------
 5 files changed, 22 insertions(+), 22 deletions(-)

diff --git a/cpukit/libfs/src/imfs/imfs.h b/cpukit/libfs/src/imfs/imfs.h
index f6ddc7d..f4025eb 100644
--- a/cpukit/libfs/src/imfs/imfs.h
+++ b/cpukit/libfs/src/imfs/imfs.h
@@ -380,7 +380,7 @@ extern const IMFS_node_control IMFS_node_control_sym_link;
 extern const IMFS_node_control IMFS_node_control_memfile;
 extern const IMFS_node_control IMFS_node_control_linfile;
 extern const IMFS_node_control IMFS_node_control_fifo;
-extern const IMFS_node_control IMFS_node_control_default;
+extern const IMFS_node_control IMFS_node_control_enosys;
 
 extern const rtems_filesystem_operations_table miniIMFS_ops;
 extern const rtems_filesystem_operations_table IMFS_ops;
diff --git a/cpukit/libfs/src/imfs/imfs_init.c b/cpukit/libfs/src/imfs/imfs_init.c
index f640919..ec61643 100644
--- a/cpukit/libfs/src/imfs/imfs_init.c
+++ b/cpukit/libfs/src/imfs/imfs_init.c
@@ -53,7 +53,7 @@ static const IMFS_node_control *const
   [IMFS_SYM_LINK] = &IMFS_node_control_sym_link,
   [IMFS_MEMORY_FILE] = &IMFS_node_control_memfile,
   [IMFS_LINEAR_FILE] = &IMFS_node_control_linfile,
-  [IMFS_FIFO] = &IMFS_node_control_fifo
+  [IMFS_FIFO] = &IMFS_node_control_enosys
 };
 
 int IMFS_initialize(
diff --git a/cpukit/libfs/src/imfs/imfs_initsupp.c b/cpukit/libfs/src/imfs/imfs_initsupp.c
index 7fe1e16..339a04f 100644
--- a/cpukit/libfs/src/imfs/imfs_initsupp.c
+++ b/cpukit/libfs/src/imfs/imfs_initsupp.c
@@ -20,6 +20,7 @@
 
 #include "imfs.h"
 
+#include <errno.h>
 #include <stdlib.h>
 #include <string.h>
 
@@ -139,6 +140,16 @@ void IMFS_node_free( const rtems_filesystem_location_info_t *loc )
   }
 }
 
+static IMFS_jnode_t *IMFS_node_initialize_enosys(
+  IMFS_jnode_t *node,
+  const IMFS_types_union *info
+)
+{
+  errno = ENOSYS;
+
+  return NULL;
+}
+
 IMFS_jnode_t *IMFS_node_initialize_default(
   IMFS_jnode_t *node,
   const IMFS_types_union *info
@@ -159,10 +170,10 @@ IMFS_jnode_t *IMFS_node_destroy_default( IMFS_jnode_t *node )
   return node;
 }
 
-const IMFS_node_control IMFS_node_control_default = {
+const IMFS_node_control IMFS_node_control_enosys = {
   .imfs_type = IMFS_INVALID_NODE,
   .handlers = &rtems_filesystem_handlers_default,
-  .node_initialize = IMFS_node_initialize_default,
+  .node_initialize = IMFS_node_initialize_enosys,
   .node_remove = IMFS_node_remove_default,
   .node_destroy = IMFS_node_destroy_default
 };
diff --git a/cpukit/libfs/src/imfs/miniimfs_init.c b/cpukit/libfs/src/imfs/miniimfs_init.c
index e06cda6..df50c05 100644
--- a/cpukit/libfs/src/imfs/miniimfs_init.c
+++ b/cpukit/libfs/src/imfs/miniimfs_init.c
@@ -49,11 +49,11 @@ static const IMFS_node_control *const
   IMFS_mini_node_controls [IMFS_TYPE_COUNT] = {
   [IMFS_DIRECTORY] = &IMFS_node_control_directory,
   [IMFS_DEVICE] = &IMFS_node_control_device,
-  [IMFS_HARD_LINK] = &IMFS_node_control_default,
-  [IMFS_SYM_LINK] = &IMFS_node_control_default,
+  [IMFS_HARD_LINK] = &IMFS_node_control_enosys,
+  [IMFS_SYM_LINK] = &IMFS_node_control_enosys,
   [IMFS_MEMORY_FILE] = &IMFS_node_control_memfile,
   [IMFS_LINEAR_FILE] = &IMFS_node_control_linfile,
-  [IMFS_FIFO] = &IMFS_node_control_default
+  [IMFS_FIFO] = &IMFS_node_control_enosys
 };
 
 int miniIMFS_initialize(
diff --git a/testsuites/sptests/spfifo01/init.c b/testsuites/sptests/spfifo01/init.c
index e01204e..9128a67 100644
--- a/testsuites/sptests/spfifo01/init.c
+++ b/testsuites/sptests/spfifo01/init.c
@@ -38,22 +38,11 @@ static void test_main(void)
     "Creating named fifo '" FIFO_PATH "'.\n"
     "Must result in failure since pipes are disabled in the configuration."
   );
-  status = mkfifo(FIFO_PATH, 0777);
-  rtems_test_assert(status == 0);
-
-  fd = open(FIFO_PATH, O_RDWR);
-  rtems_test_assert(fd >= 0);
-
-  n = read(fd, buf, sizeof(buf));
-  rtems_test_assert(n == -1);
-  rtems_test_assert(errno == ENOTSUP);
 
-  n = write(fd, buf, sizeof(buf));
-  rtems_test_assert(n == -1);
-  rtems_test_assert(errno == ENOTSUP);
-
-  status = close(fd);
-  rtems_test_assert(status == 0);
+  errno = 0;
+  status = mkfifo(FIFO_PATH, 0777);
+  rtems_test_assert(status == -1);
+  rtems_test_assert(errno == ENOSYS);
 
   puts("*** END OF FIFO / PIPE OPEN TEST - 1 ***");
 }




More information about the vc mailing list