[PATCH 5/5] imfs: Replace devfs with an IMFS specialization

Sebastian Huber sebastian.huber at embedded-brains.de
Fri Mar 6 06:48:00 UTC 2020


Add a simplified path evaluation function IMFS_eval_path_devfs() for a
device only IMFS configuration.

The code size can be further reduced by the application if it disables
the support for legacy IO drivers via:

  #define CONFIGURE_IMFS_DISABLE_MKNOD
  #define CONFIGURE_IMFS_DISABLE_MKNOD_DEVICE

Obsolete CONFIGURE_MAXIMUM_DEVICES.  Remove BSP_MAXIMUM_DEVICES.

Update #3894.
Update #3898.
---
 bsps/i386/pc386/include/bsp.h            |   2 -
 bsps/riscv/griscv/include/bsp.h          |   3 -
 bsps/sparc/leon3/include/bsp.h           |   3 -
 cpukit/Makefile.am                       |  10 --
 cpukit/headers.am                        |   1 -
 cpukit/include/rtems/confdefs/bsp.h      |   1 -
 cpukit/include/rtems/confdefs/libio.h    | 102 +++++--------
 cpukit/include/rtems/confdefs/obsolete.h |   4 +
 cpukit/include/rtems/devfs.h             | 255 -------------------------------
 cpukit/include/rtems/imfs.h              |   7 +
 cpukit/libfs/src/devfs/devclose.c        |  29 ----
 cpukit/libfs/src/devfs/devfs_eval.c      |  95 ------------
 cpukit/libfs/src/devfs/devfs_init.c      |  79 ----------
 cpukit/libfs/src/devfs/devfs_mknod.c     |  63 --------
 cpukit/libfs/src/devfs/devfs_show.c      |  51 -------
 cpukit/libfs/src/devfs/devioctl.c        |  31 ----
 cpukit/libfs/src/devfs/devopen.c         |  39 -----
 cpukit/libfs/src/devfs/devread.c         |  31 ----
 cpukit/libfs/src/devfs/devstat.c         |  36 -----
 cpukit/libfs/src/devfs/devwrite.c        |  31 ----
 cpukit/libfs/src/imfs/imfs_eval_devfs.c  | 163 ++++++++++++++++++++
 testsuites/libtests/devfs01/init.c       |  49 +++---
 testsuites/libtests/devfs02/devfs02.doc  |  22 ---
 testsuites/libtests/devfs02/devfs02.scn  |  13 --
 testsuites/libtests/devfs02/init.c       | 108 -------------
 testsuites/libtests/devfs03/devfs03.doc  |  21 ---
 testsuites/libtests/devfs03/devfs03.scn  |   6 -
 testsuites/libtests/devfs03/init.c       |  99 ------------
 testsuites/libtests/devfs04/init.c       |  11 +-
 testsuites/libtests/deviceio01/init.c    |   7 +-
 30 files changed, 244 insertions(+), 1128 deletions(-)
 delete mode 100644 cpukit/include/rtems/devfs.h
 delete mode 100644 cpukit/libfs/src/devfs/devclose.c
 delete mode 100644 cpukit/libfs/src/devfs/devfs_eval.c
 delete mode 100644 cpukit/libfs/src/devfs/devfs_init.c
 delete mode 100644 cpukit/libfs/src/devfs/devfs_mknod.c
 delete mode 100644 cpukit/libfs/src/devfs/devfs_show.c
 delete mode 100644 cpukit/libfs/src/devfs/devioctl.c
 delete mode 100644 cpukit/libfs/src/devfs/devopen.c
 delete mode 100644 cpukit/libfs/src/devfs/devread.c
 delete mode 100644 cpukit/libfs/src/devfs/devstat.c
 delete mode 100644 cpukit/libfs/src/devfs/devwrite.c
 create mode 100644 cpukit/libfs/src/imfs/imfs_eval_devfs.c
 delete mode 100644 testsuites/libtests/devfs02/devfs02.doc
 delete mode 100644 testsuites/libtests/devfs02/devfs02.scn
 delete mode 100644 testsuites/libtests/devfs02/init.c
 delete mode 100644 testsuites/libtests/devfs03/devfs03.doc
 delete mode 100644 testsuites/libtests/devfs03/devfs03.scn
 delete mode 100644 testsuites/libtests/devfs03/init.c

diff --git a/bsps/i386/pc386/include/bsp.h b/bsps/i386/pc386/include/bsp.h
index 7bc6f839bd..7989b880a9 100644
--- a/bsps/i386/pc386/include/bsp.h
+++ b/bsps/i386/pc386/include/bsp.h
@@ -239,8 +239,6 @@ void i386_stub_glue_init_breakin(void);
 int i386_stub_glue_uart(void);
 void breakpoint(void);
 
-#define BSP_MAXIMUM_DEVICES 6
-
 /*
  * Debug helper methods
  */
diff --git a/bsps/riscv/griscv/include/bsp.h b/bsps/riscv/griscv/include/bsp.h
index 320316f723..95cccd3d0a 100644
--- a/bsps/riscv/griscv/include/bsp.h
+++ b/bsps/riscv/griscv/include/bsp.h
@@ -69,9 +69,6 @@ extern "C" {
 /* Maximum supported APBUARTs by BSP */
 #define BSP_NUMBER_OF_TERMIOS_PORTS 8
 
-/* Make sure maximum number of consoles fit in filesystem */
-#define BSP_MAXIMUM_DEVICES 8
-
 /* GRLIB driver functions */
 
 extern void BSP_shared_interrupt_mask(int irq);
diff --git a/bsps/sparc/leon3/include/bsp.h b/bsps/sparc/leon3/include/bsp.h
index 100dd9624c..85730b5e20 100644
--- a/bsps/sparc/leon3/include/bsp.h
+++ b/bsps/sparc/leon3/include/bsp.h
@@ -61,9 +61,6 @@ void *bsp_idle_thread( uintptr_t ignored );
 /* Maximum supported APBUARTs by BSP */
 #define BSP_NUMBER_OF_TERMIOS_PORTS 8
 
-/* Make sure maximum number of consoles fit in filesystem */
-#define BSP_MAXIMUM_DEVICES 8
-
 /*
  * Network driver configuration
  */
diff --git a/cpukit/Makefile.am b/cpukit/Makefile.am
index 9b0b821deb..136e1764e2 100644
--- a/cpukit/Makefile.am
+++ b/cpukit/Makefile.am
@@ -380,16 +380,6 @@ librtemscpu_a_SOURCES += libfs/src/defaults/default_unmount.c
 librtemscpu_a_SOURCES += libfs/src/defaults/default_utime.c
 librtemscpu_a_SOURCES += libfs/src/defaults/default_write.c
 librtemscpu_a_SOURCES += libfs/src/defaults/default_writev.c
-librtemscpu_a_SOURCES += libfs/src/devfs/devclose.c
-librtemscpu_a_SOURCES += libfs/src/devfs/devfs_eval.c
-librtemscpu_a_SOURCES += libfs/src/devfs/devfs_init.c
-librtemscpu_a_SOURCES += libfs/src/devfs/devfs_mknod.c
-librtemscpu_a_SOURCES += libfs/src/devfs/devfs_show.c
-librtemscpu_a_SOURCES += libfs/src/devfs/devioctl.c
-librtemscpu_a_SOURCES += libfs/src/devfs/devopen.c
-librtemscpu_a_SOURCES += libfs/src/devfs/devread.c
-librtemscpu_a_SOURCES += libfs/src/devfs/devstat.c
-librtemscpu_a_SOURCES += libfs/src/devfs/devwrite.c
 librtemscpu_a_SOURCES += libfs/src/dosfs/fat.c
 librtemscpu_a_SOURCES += libfs/src/dosfs/fat_fat_operations.c
 librtemscpu_a_SOURCES += libfs/src/dosfs/fat_file.c
diff --git a/cpukit/headers.am b/cpukit/headers.am
index 185e3b8e38..4a93e7b224 100644
--- a/cpukit/headers.am
+++ b/cpukit/headers.am
@@ -82,7 +82,6 @@ include_rtems_HEADERS += include/rtems/config.h
 include_rtems_HEADERS += include/rtems/console.h
 include_rtems_HEADERS += include/rtems/counter.h
 include_rtems_HEADERS += include/rtems/cpuuse.h
-include_rtems_HEADERS += include/rtems/devfs.h
 include_rtems_HEADERS += include/rtems/deviceio.h
 include_rtems_HEADERS += include/rtems/devnull.h
 include_rtems_HEADERS += include/rtems/devzero.h
diff --git a/cpukit/include/rtems/confdefs/bsp.h b/cpukit/include/rtems/confdefs/bsp.h
index 9af46a8d29..7237c03522 100644
--- a/cpukit/include/rtems/confdefs/bsp.h
+++ b/cpukit/include/rtems/confdefs/bsp.h
@@ -48,7 +48,6 @@
   #undef BSP_IDLE_TASK_STACK_SIZE
   #undef BSP_INITIAL_EXTENSION
   #undef BSP_INTERRUPT_STACK_SIZE
-  #undef BSP_MAXIMUM_DEVICES
   #undef CONFIGURE_BSP_PREREQUISITE_DRIVERS
   #undef CONFIGURE_MALLOC_BSP_SUPPORTS_SBRK
 #else
diff --git a/cpukit/include/rtems/confdefs/libio.h b/cpukit/include/rtems/confdefs/libio.h
index 3c45771952..603b2882c1 100644
--- a/cpukit/include/rtems/confdefs/libio.h
+++ b/cpukit/include/rtems/confdefs/libio.h
@@ -47,7 +47,6 @@
 #include <rtems/sysinit.h>
 
 #ifdef CONFIGURE_FILESYSTEM_ALL
-  #define CONFIGURE_FILESYSTEM_DEVFS
   #define CONFIGURE_FILESYSTEM_DOSFS
   #define CONFIGURE_FILESYSTEM_FTPFS
   #define CONFIGURE_FILESYSTEM_IMFS
@@ -57,12 +56,6 @@
   #define CONFIGURE_FILESYSTEM_TFTPFS
 #endif
 
-#ifdef CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
-  #define CONFIGURE_FILESYSTEM_DEVFS
-#elif !defined(CONFIGURE_APPLICATION_DISABLE_FILESYSTEM)
-  #define _CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
-#endif
-
 #ifdef CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM
   #ifdef CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
     #error "CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM cannot be used together with CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM"
@@ -78,6 +71,21 @@
   #define CONFIGURE_IMFS_DISABLE_UTIME
 #endif
 
+#ifdef CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
+  #define CONFIGURE_IMFS_DISABLE_CHMOD
+  #define CONFIGURE_IMFS_DISABLE_CHOWN
+  #define CONFIGURE_IMFS_DISABLE_LINK
+  #define CONFIGURE_IMFS_DISABLE_MKNOD_FILE
+  #define CONFIGURE_IMFS_DISABLE_MOUNT
+  #define CONFIGURE_IMFS_DISABLE_READDIR
+  #define CONFIGURE_IMFS_DISABLE_READLINK
+  #define CONFIGURE_IMFS_DISABLE_RENAME
+  #define CONFIGURE_IMFS_DISABLE_RMNOD
+  #define CONFIGURE_IMFS_DISABLE_SYMLINK
+  #define CONFIGURE_IMFS_DISABLE_UNMOUNT
+  #define CONFIGURE_IMFS_DISABLE_UTIME
+#endif
+
 #ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
   #ifdef CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
     #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM"
@@ -87,10 +95,6 @@
     #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_USE_MINIIMFS_AS_BASE_FILESYSTEM"
   #endif
 
-  #ifdef CONFIGURE_FILESYSTEM_DEVFS
-    #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_DEVFS"
-  #endif
-
   #ifdef CONFIGURE_FILESYSTEM_DOSFS
     #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_DOSFS"
   #endif
@@ -118,13 +122,9 @@
   #ifdef CONFIGURE_FILESYSTEM_TFTPFS
     #error "CONFIGURE_APPLICATION_DISABLE_FILESYSTEM cannot be used together with CONFIGURE_FILESYSTEM_TFTPFS"
   #endif
-#else
-  #define _CONFIGURE_FILESYSTEM_INITIALIZE
 #endif
 
-#ifdef CONFIGURE_FILESYSTEM_DEVFS
-#include <rtems/devfs.h>
-#endif
+#include <rtems/imfs.h>
 
 #ifdef CONFIGURE_FILESYSTEM_DOSFS
 #include <rtems/dosfs.h>
@@ -134,11 +134,6 @@
 #include <rtems/ftpfs.h>
 #endif
 
-#if defined(CONFIGURE_FILESYSTEM_IMFS) \
-  || defined(_CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM)
-#include <rtems/imfs.h>
-#endif
-
 #ifdef CONFIGURE_FILESYSTEM_JFFS2
 #include <rtems/jffs2.h>
 #endif
@@ -159,28 +154,7 @@
 extern "C" {
 #endif
 
-#ifdef CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
-
-#ifndef CONFIGURE_MAXIMUM_DEVICES
-  #ifdef BSP_MAXIMUM_DEVICES
-    #define CONFIGURE_MAXIMUM_DEVICES BSP_MAXIMUM_DEVICES
-  #else
-    #define CONFIGURE_MAXIMUM_DEVICES 4
-  #endif
-#endif
-
-static devFS_node devFS_root_filesystem_nodes[ CONFIGURE_MAXIMUM_DEVICES ];
-
-static const devFS_data _Filesystem_Root_data = {
-  devFS_root_filesystem_nodes,
-  CONFIGURE_MAXIMUM_DEVICES
-};
-
-#define _CONFIGURE_FILESYSTEM_ROOT_TYPE RTEMS_FILESYSTEM_TYPE_DEVFS
-
-#endif /* CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM */
-
-#ifdef _CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
+#ifndef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
 
 #ifndef CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK
   #define CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK \
@@ -198,12 +172,16 @@ static const devFS_data _Filesystem_Root_data = {
 
 const int imfs_memfile_bytes_per_block = CONFIGURE_IMFS_MEMFILE_BYTES_PER_BLOCK;
 
-static IMFS_fs_info_t _IMFS_fs_info;
+static IMFS_fs_info_t IMFS_root_fs_info;
 
-static const rtems_filesystem_operations_table _IMFS_ops = {
+static const rtems_filesystem_operations_table IMFS_root_ops = {
   rtems_filesystem_default_lock,
   rtems_filesystem_default_unlock,
-  IMFS_eval_path,
+  #ifdef CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
+    IMFS_eval_path_devfs,
+  #else
+    IMFS_eval_path,
+  #endif
   #ifdef CONFIGURE_IMFS_DISABLE_LINK
     rtems_filesystem_default_link,
   #else
@@ -266,13 +244,17 @@ static const rtems_filesystem_operations_table _IMFS_ops = {
   rtems_filesystem_default_statvfs
 };
 
-static const IMFS_mknod_controls _IMFS_mknod_controls = {
+static const IMFS_mknod_controls IMFS_root_mknod_controls = {
   #ifdef CONFIGURE_IMFS_DISABLE_READDIR
     &IMFS_mknod_control_dir_minimal,
   #else
     &IMFS_mknod_control_dir_default,
   #endif
-  &IMFS_mknod_control_device,
+  #ifdef CONFIGURE_IMFS_DISABLE_MKNOD_DEVICE
+    &IMFS_mknod_control_enosys,
+  #else
+    &IMFS_mknod_control_device,
+  #endif
   #ifdef CONFIGURE_IMFS_DISABLE_MKNOD_FILE
     &IMFS_mknod_control_enosys,
   #else
@@ -285,18 +267,12 @@ static const IMFS_mknod_controls _IMFS_mknod_controls = {
   #endif
 };
 
-static const IMFS_mount_data _Filesystem_Root_data = {
-  &_IMFS_fs_info,
-  &_IMFS_ops,
-  &_IMFS_mknod_controls
+static const IMFS_mount_data IMFS_root_mount_data = {
+  &IMFS_root_fs_info,
+  &IMFS_root_ops,
+  &IMFS_root_mknod_controls
 };
 
-#define _CONFIGURE_FILESYSTEM_ROOT_TYPE "/"
-
-#endif /* _CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM */
-
-#ifdef _CONFIGURE_FILESYSTEM_INITIALIZE
-
 #if defined(CONFIGURE_FILESYSTEM_DEVFS) \
   && !defined(CONFIGURE_FILESYSTEM_ENTRY_DEVFS)
   #define CONFIGURE_FILESYSTEM_ENTRY_DEVFS \
@@ -346,9 +322,7 @@ static const IMFS_mount_data _Filesystem_Root_data = {
 #endif
 
 const rtems_filesystem_table_t rtems_filesystem_table[] = {
-  #ifdef _CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
-    { "/", IMFS_initialize_support },
-  #endif
+  { "/", IMFS_initialize_support },
   #ifdef CONFIGURE_FILESYSTEM_ENTRY_DEVFS
     CONFIGURE_FILESYSTEM_ENTRY_DEVFS,
   #endif
@@ -380,9 +354,9 @@ const rtems_filesystem_mount_configuration
 rtems_filesystem_root_configuration = {
   NULL,
   NULL,
-  _CONFIGURE_FILESYSTEM_ROOT_TYPE,
+  "/",
   RTEMS_FILESYSTEM_READ_WRITE,
-  &_Filesystem_Root_data
+  &IMFS_root_mount_data
 };
 
 RTEMS_SYSINIT_ITEM(
@@ -391,7 +365,7 @@ RTEMS_SYSINIT_ITEM(
   RTEMS_SYSINIT_ORDER_MIDDLE
 );
 
-#endif /* _CONFIGURE_FILESYSTEM_INITIALIZE */
+#endif /* !CONFIGURE_APPLICATION_DISABLE_FILESYSTEM */
 
 #ifndef CONFIGURE_MAXIMUM_FILE_DESCRIPTORS
   #define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 3
diff --git a/cpukit/include/rtems/confdefs/obsolete.h b/cpukit/include/rtems/confdefs/obsolete.h
index 50293bce23..4e85fb679f 100644
--- a/cpukit/include/rtems/confdefs/obsolete.h
+++ b/cpukit/include/rtems/confdefs/obsolete.h
@@ -65,6 +65,10 @@
   #error "The CONFIGURE_BDBUF_BUFFER_COUNT configuration option is obsolete since RTEMS 4.10.0"
 #endif
 
+#ifdef CONFIGURE_MAXIMUM_DEVICES
+  #warning "The CONFIGURE_MAXIMUM_DEVICES configuration option is obsolete since RTEMS 5.1"
+#endif
+
 #ifdef CONFIGURE_ENABLE_GO
   #warning "The CONFIGURE_ENABLE_GO configuration option is obsolete since RTEMS 5.1"
 #endif
diff --git a/cpukit/include/rtems/devfs.h b/cpukit/include/rtems/devfs.h
deleted file mode 100644
index ff4dfe09bc..0000000000
--- a/cpukit/include/rtems/devfs.h
+++ /dev/null
@@ -1,255 +0,0 @@
-/**
-* @file
-* 
-* @brief Device Only File System
-*  
-* This include file contains all constants and structures associated
-* with the 'device-only' filesystem.
-*/
-
-#ifndef _RTEMS_DEVFS_H
-#define _RTEMS_DEVFS_H
-
-#include <rtems/libio_.h>
-
-/**
- * @defgroup DevFsDeviceTable Device Only File System
- *
- * @ingroup FileSystemTypesAndMount
- *
- * @brief This structure defines the type of device table
- */
-/**@{*/
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-/**
- *  @brief Per Device Node Control Structure
- *
- *  This structure is instanced per device node and contains all information
- *  used by this file system implementation to manage that device node.
- */
-typedef struct {
-  /** This member points to device name which is not a null-terminated string */
-  const char               *name;
-  /** This member is the name length of a device */
-  size_t                    namelen;
-  /** major number of a device */
-  rtems_device_major_number major;
-  /** minor number of a device */
-  rtems_device_minor_number minor;
-  /** device creation mode, only device file can be created */
-  mode_t                    mode;
-} devFS_node;
-
-typedef struct {
-  devFS_node *nodes;
-  size_t      count;
-} devFS_data;
-
-/**
- *  The following defines the device-only filesystem operating
- *  operations.
- */
-extern const rtems_filesystem_operations_table devFS_ops;
-
-/**
- *  The following defines the device-only filesystem operating
- *  handlers.
- */
-extern const rtems_filesystem_file_handlers_r  devFS_file_handlers;
-
-/**
- * @brief Obtain Immutable Pointer to Immutable File System Data
- *
- * This methods returns the immutable file system specific information
- * associated with this file.
- */
-static inline const devFS_data *devFS_get_data(
-  const rtems_filesystem_location_info_t *loc
-)
-{
-  return (const devFS_data *) loc->mt_entry->immutable_fs_info;
-}
-
-/**
- *  @brief Evaluate Path
- */
-extern void devFS_eval_path(
-  rtems_filesystem_eval_path_context_t *ctx
-);
-
-/**
- *  @brief Maps Open Operation to rtems_io_open
- *
- *  This handler maps open operation to rtems_io_open.
- *
- *  @param iop This is the RTEMS's internal representation of file.
- *  @param pathname a null-terminated string that starts with /dev.
- *  @param oflag access flags
- *  @param mode access mode
- *
- *  @retval the same as open
- */
-extern int devFS_open(
-  rtems_libio_t *iop,
-  const char    *pathname,
-  int            oflag,
-  mode_t         mode
-);
-
-
-/**
- *  @brief Maps Close Operation to rtems_io_close
- *
- *  This handler maps close operation to rtems_io_close.
- *
- *  @param iop This is the RTEMS's internal representation of file
- *
- *  @retval the same as close
- */
-extern int devFS_close(
-  rtems_libio_t *iop
-);
-
-/**
- *  @brief Maps Read Operation to rtems_io_read
- *
- *  This handler maps read operation to rtems_io_read.
- *
- *  @param iop This is the RTEMS's internal representation of file
- *  @param  buffer memory location to store read data
- *  @param  count  how many bytes to read
- *
- *  @retval On successful, this routine returns total bytes read. On error
- *  it returns -1 and errno is set to proper value.
- */
-extern ssize_t devFS_read(
-  rtems_libio_t *iop,
-  void          *buffer,
-  size_t         count
-);
-
-/**
- *  @brief Writes Operation to rtems_io_write
- *
- *  This handler maps write operation to rtems_io_write.
- *
- *  @param iop This is the RTEMS's internal representation of file
- *  @param buffer data to be written
- *  @param count  how many bytes to write
- *
- *  @retval On successful, this routine returns total bytes written. On error
- *  it returns -1 and errno is set to proper value.
- */
-extern ssize_t devFS_write(
-  rtems_libio_t *iop,
-  const void    *buffer,
-  size_t         count
-);
-
-/**
- *  @brief Maps ioctl Operation to rtems_io_ioctl
- *
- *  This handler maps ioctl operation to rtems_io_ioctl.
- *
- *  @param iop This is the RTEMS's internal representation of file
- *  @param command io control command
- *  @param buffer  io control parameters
- *
- *  @retval On successful, this routine returns total bytes written. On error
- *  it returns -1 and errno is set to proper value.
- */
-extern int devFS_ioctl(
-  rtems_libio_t   *iop,
-  ioctl_command_t  command,
-  void            *buffer
-);
-
-/**
- *  @brief Gets the Device File Information
- *
- *  This handler gets the device file information. This routine only
- *  set the following member of struct stat:
- *
- *  - st_dev: device number
- *  - st_mode: device file creation mode, only two mode are accepted:
- *    + S_IFCHR: character device file
- *    + S_IFBLK: block device file
- *
- *  @param loc contains filesystem access information
- *  @param buf buffer to hold the device file's information
- *
- *  @retval On successful, this routine returns 0. On error
- *  it returns -1 and errno is set to proper value.
- */
-extern int devFS_stat(
-  const rtems_filesystem_location_info_t *loc,
-  struct stat                            *buf
-);
-
-/**
- *  @brief Creates an item in the main device table.
- *
- *  This routine is invoked upon registration of a new device
- *  file. It is responsible for creating a item in the main
- *  device table. This routine searches the device table in
- *  sequential order, when found a empty slot, it fills the slot
- *  with proper values.
- *
- *  @see rtems_filesystem_mknod_t.
- */
-extern int devFS_mknod(
-  const rtems_filesystem_location_info_t *parentloc,
-  const char                             *name,
-  size_t                                  namelen,
-  mode_t                                  mode,
-  dev_t                                   dev
-);
-
-/**
- *  @brief Creates the Main Device Table
- *
- *  This routine is invoked upon rtems filesystem initialization.
- *  It is responsible for creating the main device table,
- *  initializing it to a known state, and set device file operation
- *  handlers. After this, the device-only filesytem is ready for use
- *
- *  @param  mt_entry The filesystem mount table entry.
- *  @param  data Filesystem specific data.
- *
- *  @retval upon success, this routine returns 0; otherwise it returns
- *  -1 and errno is set to proper value. The only error is when malloc
- *  failed, and errno is set to NOMEM.
- */
-extern int devFS_initialize(
-  rtems_filesystem_mount_table_entry_t *mt_entry,
-  const void                           *data
-);
-
-/**
- *  @brief Retrieves and Prints all the Device Registered in System
- *
- *  This routine retrieves all the device registered in system, and
- *  prints out their detail information. For example, on one system,
- *  devFS_show will print out following message:
- *
- *  @code
- *    /dev/console     0  0
- *    /dev/clock       1  0
- *    /dev/tty0        0  0
- *    /flash           2  0
- *  @endcode
- *
- *  This routine is intended for debugging, and can be used by shell
- *  program to provide user with the system information.
- */
-extern void devFS_Show(void);
-
-#ifdef __cplusplus
-}
-#endif
-/**@}*/
-#endif
-
diff --git a/cpukit/include/rtems/imfs.h b/cpukit/include/rtems/imfs.h
index 09e8bd4a9d..b2a9868b38 100644
--- a/cpukit/include/rtems/imfs.h
+++ b/cpukit/include/rtems/imfs.h
@@ -536,6 +536,13 @@ extern void IMFS_eval_path(
   rtems_filesystem_eval_path_context_t *ctx
 );
 
+/**
+ * @brief IMFS device filesystem evaluation node support.
+ */
+extern void IMFS_eval_path_devfs(
+  rtems_filesystem_eval_path_context_t *ctx
+);
+
 /**
  * @brief Create a new IMFS link node.
  * 
diff --git a/cpukit/libfs/src/devfs/devclose.c b/cpukit/libfs/src/devfs/devclose.c
deleted file mode 100644
index e3ca969988..0000000000
--- a/cpukit/libfs/src/devfs/devclose.c
+++ /dev/null
@@ -1,29 +0,0 @@
-/**
- * @file
- *
- * @brief Maps Close Operation to rtems_io_close
- * @ingroup DevFsDeviceTable Define Device Table Type
- */
-
-/*
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-  #include "config.h"
-#endif
-
-#include <rtems/devfs.h>
-
-#include <rtems/deviceio.h>
-
-int devFS_close(
-  rtems_libio_t *iop
-)
-{
-  const devFS_node *np = iop->pathinfo.node_access;
-
-  return rtems_deviceio_close( iop, np->major, np->minor );
-}
diff --git a/cpukit/libfs/src/devfs/devfs_eval.c b/cpukit/libfs/src/devfs/devfs_eval.c
deleted file mode 100644
index ba8e36fad0..0000000000
--- a/cpukit/libfs/src/devfs/devfs_eval.c
+++ /dev/null
@@ -1,95 +0,0 @@
-/**
- * @file
- *
- * @brief Evaluate Patch
- * @ingroup DevFsDeviceTable Define Device Table Type
- */
-
-/*
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-  #include "config.h"
-#endif
-
-#include <string.h>
-
-#include <rtems/devfs.h>
-
-static devFS_node *devFS_search_node(
-  const devFS_data *data,
-  const char *path,
-  size_t pathlen,
-  devFS_node **free_node_ptr
-)
-{
-  size_t i = 0;
-  size_t n = data->count;
-  devFS_node *nodes = data->nodes;
-  devFS_node *node = NULL;
-  devFS_node *free_node = NULL;
-
-  for (i = 0; (free_node == NULL || node == NULL) && i < n; ++i) {
-    devFS_node *current = nodes + i;
-
-    if (current->name != NULL) {
-      if (
-        current->namelen == pathlen
-          && memcmp(current->name, path, pathlen) == 0
-      ) {
-        node = current;
-      }
-    } else {
-      free_node = current;
-    }
-  }
-
-  *free_node_ptr = free_node;
-
-  return node;
-}
-
-void devFS_eval_path(
-  rtems_filesystem_eval_path_context_t *ctx
-)
-{
-  rtems_filesystem_location_info_t *currentloc =
-    rtems_filesystem_eval_path_get_currentloc(ctx);
-  devFS_node *free_node;
-  devFS_node *node = devFS_search_node(
-    devFS_get_data(currentloc),
-    rtems_filesystem_eval_path_get_path(ctx),
-    rtems_filesystem_eval_path_get_pathlen(ctx),
-    &free_node
-  );
-  int eval_flags = rtems_filesystem_eval_path_get_flags(ctx);
-
-  if (node != NULL) {
-    if ((eval_flags & RTEMS_FS_EXCLUSIVE) == 0) {
-      currentloc->node_access = node;
-      rtems_filesystem_eval_path_clear_path(ctx);
-    } else {
-      rtems_filesystem_eval_path_error(ctx, EEXIST);
-    }
-  } else {
-    if ((eval_flags & RTEMS_FS_MAKE) != 0) {
-      if (free_node != NULL) {
-        free_node->mode = S_IRWXU | S_IRWXG | S_IRWXO;
-        currentloc->node_access = free_node;
-        rtems_filesystem_eval_path_set_token(
-          ctx,
-          rtems_filesystem_eval_path_get_path(ctx),
-          rtems_filesystem_eval_path_get_pathlen(ctx)
-        );
-        rtems_filesystem_eval_path_clear_path(ctx);
-      } else {
-        rtems_filesystem_eval_path_error(ctx, ENOSPC);
-      }
-    } else {
-      rtems_filesystem_eval_path_error(ctx, ENOENT);
-    }
-  }
-}
diff --git a/cpukit/libfs/src/devfs/devfs_init.c b/cpukit/libfs/src/devfs/devfs_init.c
deleted file mode 100644
index e8ad761f29..0000000000
--- a/cpukit/libfs/src/devfs/devfs_init.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/**
- * @file
- *
- * @brief Creates the Main Device Table
- * @ingroup DevFsDeviceTable Define Device Table Type
- */
-
-/*
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-  #include "config.h"
-#endif
-
-#include <rtems/devfs.h>
-
-const rtems_filesystem_operations_table devFS_ops = {
-  .lock_h = rtems_filesystem_default_lock,
-  .unlock_h = rtems_filesystem_default_unlock,
-  .eval_path_h = devFS_eval_path,
-  .link_h = rtems_filesystem_default_link,
-  .are_nodes_equal_h = rtems_filesystem_default_are_nodes_equal,
-  .mknod_h = devFS_mknod,
-  .rmnod_h = rtems_filesystem_default_rmnod,
-  .fchmod_h = rtems_filesystem_default_fchmod,
-  .chown_h = rtems_filesystem_default_chown,
-  .clonenod_h = rtems_filesystem_default_clonenode,
-  .freenod_h = rtems_filesystem_default_freenode,
-  .mount_h = rtems_filesystem_default_mount,
-  .unmount_h = rtems_filesystem_default_unmount,
-  .fsunmount_me_h = rtems_filesystem_default_fsunmount,
-  .utime_h = rtems_filesystem_default_utime,
-  .symlink_h = rtems_filesystem_default_symlink,
-  .readlink_h = rtems_filesystem_default_readlink,
-  .rename_h = rtems_filesystem_default_rename,
-  .statvfs_h = rtems_filesystem_default_statvfs
-};
-
-const rtems_filesystem_file_handlers_r devFS_file_handlers = {
-  .open_h = devFS_open,
-  .close_h = devFS_close,
-  .read_h = devFS_read,
-  .write_h = devFS_write,
-  .ioctl_h = devFS_ioctl,
-  .lseek_h = rtems_filesystem_default_lseek_file,
-  .fstat_h = devFS_stat,
-  .ftruncate_h = rtems_filesystem_default_ftruncate,
-  .fsync_h = rtems_filesystem_default_fsync_or_fdatasync,
-  .fdatasync_h = rtems_filesystem_default_fsync_or_fdatasync,
-  .fcntl_h = rtems_filesystem_default_fcntl,
-  .kqfilter_h = rtems_filesystem_default_kqfilter,
-  .mmap_h = rtems_filesystem_default_mmap,
-  .poll_h = rtems_filesystem_default_poll,
-  .readv_h = rtems_filesystem_default_readv,
-  .writev_h = rtems_filesystem_default_writev
-};
-
-int devFS_initialize(
-  rtems_filesystem_mount_table_entry_t *mt_entry,
-  const void *data
-)
-{
-  int rv = 0;
-
-  if (data != NULL) {
-    mt_entry->ops = &devFS_ops;
-    mt_entry->immutable_fs_info = data;
-    mt_entry->mt_fs_root->location.handlers = &devFS_file_handlers;
-  } else {
-    errno = EINVAL;
-    rv = -1;
-  }
-
-  return rv;
-}
-
diff --git a/cpukit/libfs/src/devfs/devfs_mknod.c b/cpukit/libfs/src/devfs/devfs_mknod.c
deleted file mode 100644
index 3b86d8c192..0000000000
--- a/cpukit/libfs/src/devfs/devfs_mknod.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/**
- * @file
- *
- * @brief Creates an item in the main device table.
- * @ingroup DevFsDeviceTable Define Device Table Type
- */
-
-/*
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-  #include "config.h"
-#endif
-
-#include <sys/stat.h>
-#include <stdlib.h>
-#include <string.h>
-
-#include <rtems/devfs.h>
-
-int devFS_mknod(
-  const rtems_filesystem_location_info_t *parentloc,
-  const char *name,
-  size_t namelen,
-  mode_t mode,
-  dev_t dev
-)
-{
-  int rv = 0;
-
-  if (namelen != 3 || name [0] != 'd' || name [1] != 'e' || name [2] != 'v') {
-    if (S_ISBLK(mode) || S_ISCHR(mode)) {
-      char *dupname = malloc(namelen);
-
-      if (dupname != NULL) {
-        devFS_node *node = parentloc->node_access;
-
-        node->name = dupname;
-        node->namelen = namelen;
-        node->major = rtems_filesystem_dev_major_t(dev);
-        node->minor = rtems_filesystem_dev_minor_t(dev);
-        node->mode = mode;
-        memcpy(dupname, name, namelen);
-      } else {
-        errno = ENOMEM;
-        rv = -1;
-      }
-    } else {
-      errno = ENOTSUP;
-      rv = -1;
-    }
-  } else {
-    if (!S_ISDIR(mode)) {
-      errno = ENOTSUP;
-      rv = -1;
-    }
-  }
-
-  return rv;
-}
diff --git a/cpukit/libfs/src/devfs/devfs_show.c b/cpukit/libfs/src/devfs/devfs_show.c
deleted file mode 100644
index 07e67c6f51..0000000000
--- a/cpukit/libfs/src/devfs/devfs_show.c
+++ /dev/null
@@ -1,51 +0,0 @@
-/**
- * @file
- *
- * @brief Retrieves and Prints all the Device Registered in System
- * @ingroup DevFsDeviceTable Define Device Table Type
- */
-
-/*
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-  #include "config.h"
-#endif
-
-#include <rtems/devfs.h>
-
-#include <rtems/bspIo.h>
-
-void devFS_Show(void)
-{
-  rtems_filesystem_location_info_t *rootloc = &rtems_filesystem_root->location;
-
-  if (rootloc->mt_entry->ops == &devFS_ops) {
-    const devFS_data *data = devFS_get_data(rootloc);
-    size_t i = 0;
-    size_t n = data->count;
-    devFS_node *nodes = data->nodes;
-
-    for (i = 0; i < n; ++i) {
-      devFS_node *current = nodes + i;
-
-      if (current->name != NULL) {
-        size_t j = 0;
-        size_t m = current->namelen;
-
-        printk("/");
-        for (j = 0; j < m; ++j) {
-          printk("%c", current->name [j]);
-        }
-        printk(
-          " %lu %lu\n",
-          (unsigned long) current->major,
-          (unsigned long) current->minor
-        );
-      }
-    }
-  }
-}
diff --git a/cpukit/libfs/src/devfs/devioctl.c b/cpukit/libfs/src/devfs/devioctl.c
deleted file mode 100644
index 693d30e825..0000000000
--- a/cpukit/libfs/src/devfs/devioctl.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * @file
- *
- * @brief Maps ioctl Operation to rtems_io_ioctl
- * @ingroup DevFsDeviceTable Define Device Table Type
- */
-
-/*
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-  #include "config.h"
-#endif
-
-#include <rtems/devfs.h>
-
-#include <rtems/deviceio.h>
-
-int devFS_ioctl(
-  rtems_libio_t   *iop,
-  ioctl_command_t  command,
-  void            *buffer
-)
-{
-  const devFS_node *np = iop->pathinfo.node_access;
-
-  return rtems_deviceio_control( iop, command, buffer, np->major, np->minor );
-}
diff --git a/cpukit/libfs/src/devfs/devopen.c b/cpukit/libfs/src/devfs/devopen.c
deleted file mode 100644
index d6d5c8062d..0000000000
--- a/cpukit/libfs/src/devfs/devopen.c
+++ /dev/null
@@ -1,39 +0,0 @@
-/**
- * @file
- *
- * @brief Maps Open Operation to rtems_io_open
- * @ingroup DevFsDeviceTable Define Device Table Type
- */
-
-/*
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-  #include "config.h"
-#endif
-
-#include <rtems/devfs.h>
-
-#include <rtems/deviceio.h>
-
-int devFS_open(
-  rtems_libio_t *iop,
-  const char    *pathname,
-  int            oflag,
-  mode_t         mode
-)
-{
-  const devFS_node *np = iop->pathinfo.node_access;
-
-  return rtems_deviceio_open(
-    iop,
-    pathname,
-    oflag,
-    mode,
-    np->major,
-    np->minor
-  );
-}
diff --git a/cpukit/libfs/src/devfs/devread.c b/cpukit/libfs/src/devfs/devread.c
deleted file mode 100644
index 8ae3e84b65..0000000000
--- a/cpukit/libfs/src/devfs/devread.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * @file
- *
- * @brief DevFS Read
- * @ingroup Read Operation to rtems_io_read
- */
-
-/*
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-  #include "config.h"
-#endif
-
-#include <rtems/devfs.h>
-
-#include <rtems/deviceio.h>
-
-ssize_t devFS_read(
-  rtems_libio_t *iop,
-  void          *buffer,
-  size_t         count
-)
-{
-  const devFS_node *np = iop->pathinfo.node_access;
-
-  return rtems_deviceio_read( iop, buffer, count, np->major, np->minor );
-}
diff --git a/cpukit/libfs/src/devfs/devstat.c b/cpukit/libfs/src/devfs/devstat.c
deleted file mode 100644
index c88f729924..0000000000
--- a/cpukit/libfs/src/devfs/devstat.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/**
- * @file
- *
- * @brief Gets the Device File Information
- * @ingroup DevFsDeviceTable Define Device Table Type
- */
-
-/*
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-  #include "config.h"
-#endif
-
-#include <rtems/devfs.h>
-
-int devFS_stat(
-  const rtems_filesystem_location_info_t *loc,
-  struct stat *buf
-)
-{
-  int rv = 0;
-  const devFS_node *the_dev = loc->node_access;
-
-  if (the_dev != NULL) {
-    buf->st_rdev = rtems_filesystem_make_dev_t( the_dev->major, the_dev->minor );
-    buf->st_mode = the_dev->mode;
-  } else {
-    rv = rtems_filesystem_default_fstat(loc, buf);
-  }
-
-  return rv;
-}
diff --git a/cpukit/libfs/src/devfs/devwrite.c b/cpukit/libfs/src/devfs/devwrite.c
deleted file mode 100644
index 7fd8006776..0000000000
--- a/cpukit/libfs/src/devfs/devwrite.c
+++ /dev/null
@@ -1,31 +0,0 @@
-/**
- * @file
- *
- * @brief Writes Operation to rtems_io_write
- * @ingroup DevFsDeviceTable Define Device Table Type
- */
-
-/*
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#if HAVE_CONFIG_H
-  #include "config.h"
-#endif
-
-#include <rtems/devfs.h>
-
-#include <rtems/deviceio.h>
-
-ssize_t devFS_write(
-  rtems_libio_t *iop,
-  const void    *buffer,
-  size_t         count
-)
-{
-  const devFS_node *np = iop->pathinfo.node_access;
-
-  return rtems_deviceio_write( iop, buffer, count, np->major, np->minor );
-}
diff --git a/cpukit/libfs/src/imfs/imfs_eval_devfs.c b/cpukit/libfs/src/imfs/imfs_eval_devfs.c
new file mode 100644
index 0000000000..d25e4ff8e2
--- /dev/null
+++ b/cpukit/libfs/src/imfs/imfs_eval_devfs.c
@@ -0,0 +1,163 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
+/**
+ * @file
+ *
+ * @ingroup ClassicIO
+ *
+ * @brief Implementation of IMFS_eval_path_devfs().
+ */
+
+/*
+ * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/imfs.h>
+
+#include <string.h>
+
+typedef struct {
+  uint8_t len;
+  char name[3];
+} IMFS_devfs_dir;
+
+static const IMFS_devfs_dir IMFS_devfs_dirs[] = {
+  { .len = 1, .name = { '/' } },
+  { .len = 1, .name = { '.' } },
+  { .len = 2, .name = { '.', '.' } },
+  { .len = 3, .name = { 'd', 'e', 'v' } }
+};
+
+static IMFS_jnode_t *IMFS_devfs_is_dir(
+  rtems_filesystem_eval_path_context_t *ctx,
+  IMFS_directory_t                     *dir
+)
+{
+  const char *path;
+  size_t      pathlen;
+  size_t      i;
+
+  path = rtems_filesystem_eval_path_get_path( ctx );
+  pathlen = rtems_filesystem_eval_path_get_pathlen( ctx );
+
+  for ( i = 0; i < RTEMS_ARRAY_SIZE( IMFS_devfs_dirs ); ++i ) {
+    bool match;
+
+    match = IMFS_devfs_dirs[ i ].len == pathlen
+      && memcmp( IMFS_devfs_dirs[ i ].name, path, pathlen ) == 0;
+
+    if ( match ) {
+      int eval_flags;
+
+      eval_flags = rtems_filesystem_eval_path_get_flags( ctx );
+      eval_flags &= ~RTEMS_FS_EXCLUSIVE;
+      rtems_filesystem_eval_path_set_flags( ctx, eval_flags );
+      rtems_filesystem_eval_path_clear_path( ctx );
+      return &dir->Node;
+    }
+  }
+
+  return NULL;
+}
+
+static IMFS_jnode_t *IMFS_devfs_search(
+  rtems_filesystem_eval_path_context_t *ctx,
+  IMFS_directory_t                     *dir
+)
+{
+  const char          *path;
+  size_t               pathlen;
+  rtems_chain_control *entries;
+  rtems_chain_node    *current;
+  rtems_chain_node    *tail;
+
+  path = rtems_filesystem_eval_path_get_path( ctx );
+  pathlen = rtems_filesystem_eval_path_get_pathlen( ctx );
+  entries = &dir->Entries;
+  current = rtems_chain_first( entries );
+  tail = rtems_chain_tail( entries );
+
+  while ( current != tail ) {
+    IMFS_jnode_t *entry;
+    bool          match;
+
+    entry = (IMFS_jnode_t *) current;
+    match = entry->namelen == pathlen
+      && memcmp( entry->name, path, pathlen ) == 0;
+
+    if ( match ) {
+      return entry;
+    }
+
+    current = rtems_chain_next( current );
+  }
+
+  return NULL;
+}
+
+void IMFS_eval_path_devfs( rtems_filesystem_eval_path_context_t *ctx )
+{
+  rtems_filesystem_location_info_t *currentloc;
+  IMFS_directory_t                 *dir;
+  IMFS_jnode_t                     *entry;
+
+  currentloc = rtems_filesystem_eval_path_get_currentloc( ctx );
+  dir = currentloc->node_access;
+
+  entry = IMFS_devfs_is_dir( ctx, dir );
+
+  if ( entry != NULL ) {
+    return;
+  }
+
+  entry = IMFS_devfs_search( ctx, dir );
+
+  if ( entry != NULL ) {
+    int eval_flags;
+
+    eval_flags = rtems_filesystem_eval_path_get_flags( ctx );
+
+    if ( ( eval_flags & RTEMS_FS_EXCLUSIVE ) == 0 ) {
+      --dir->Node.reference_count;
+      ++entry->reference_count;
+      currentloc->node_access = entry;
+      currentloc->node_access_2 = IMFS_generic_get_context_by_node( entry );
+      IMFS_Set_handlers( currentloc );
+      rtems_filesystem_eval_path_clear_path( ctx );
+    } else {
+      rtems_filesystem_eval_path_error( ctx, EEXIST );
+    }
+  } else {
+    rtems_filesystem_eval_path_set_token(
+      ctx,
+      rtems_filesystem_eval_path_get_path( ctx ),
+      rtems_filesystem_eval_path_get_pathlen( ctx )
+    );
+    rtems_filesystem_eval_path_clear_path( ctx );
+  }
+}
diff --git a/testsuites/libtests/devfs01/init.c b/testsuites/libtests/devfs01/init.c
index 44b55e171c..193c7641db 100644
--- a/testsuites/libtests/devfs01/init.c
+++ b/testsuites/libtests/devfs01/init.c
@@ -1,10 +1,28 @@
+/* SPDX-License-Identifier: BSD-2-Clause */
+
 /*
- *  COPYRIGHT (c) 1989-2012.
- *  On-Line Applications Research Corporation (OAR).
+ * Copyright (C) 2020 embedded brains GmbH (http://www.embedded-brains.de)
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
  *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+ * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
+ * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
  */
 
 #ifdef HAVE_CONFIG_H
@@ -12,34 +30,24 @@
 #endif
 
 #include <tmacros.h>
-#include "test_support.h"
-#include <rtems/devfs.h>
 #include <errno.h>
 
 const char rtems_test_name[] = "DEVFS 1";
 
-/* forward declarations to avoid warnings */
-rtems_task Init(rtems_task_argument argument);
-
-rtems_task Init(
-  rtems_task_argument argument
-)
+static void Init(rtems_task_argument argument)
 {
   TEST_BEGIN();
 
-  puts( "devFS_Show" );
-  devFS_Show();
-  
   TEST_END();
-
   rtems_test_exit(0);
 }
 
-/* configuration information */
+#define CONFIGURE_APPLICATION_DOES_NOT_NEED_CLOCK_DRIVER
+
+#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
 
-#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
+#define CONFIGURE_MAXIMUM_TASKS 1
 
-#define CONFIGURE_MAXIMUM_TASKS             1
 #define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
 
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
@@ -49,4 +57,3 @@ rtems_task Init(
 #define CONFIGURE_INIT
 
 #include <rtems/confdefs.h>
-/* end of file */
diff --git a/testsuites/libtests/devfs02/devfs02.doc b/testsuites/libtests/devfs02/devfs02.doc
deleted file mode 100644
index 6b594fd055..0000000000
--- a/testsuites/libtests/devfs02/devfs02.doc
+++ /dev/null
@@ -1,22 +0,0 @@
-#  COPYRIGHT (c) 1989-2010.
-#  On-Line Applications Research Corporation (OAR).
-#
-#  The license and distribution terms for this file may be
-#  found in the file LICENSE in this distribution or at
-#  http://www.rtems.org/license/LICENSE.
-#
-
-This file describes the directives and concepts tested by this test set.
-
-test set name:  devfs02
-
-directives:
-
-+ devFS_mknod
-+ devFS_evaluate_path
-
-concepts:
-
-+ System calls open, mknod, mkfifo are used to exercise the above
-mentioned routines. This test exercise mostly the error paths.
-
diff --git a/testsuites/libtests/devfs02/devfs02.scn b/testsuites/libtests/devfs02/devfs02.scn
deleted file mode 100644
index 188207dc77..0000000000
--- a/testsuites/libtests/devfs02/devfs02.scn
+++ /dev/null
@@ -1,13 +0,0 @@
-*** TEST DEVFS02 ***
-Init - attempt to create a fifo - expect EINVAL
-Init - set the device name table to NULL
- Init - attempt to create a node - expect EFAULT
-Init - attempt to stat a node - expect EFAULT
-Init - attempt to open a node
-Init - restore the device name table
-Init - set device table size to zero
-Init - attempt to create a node - expect ENOMEM
-Init - restore device table size
-Init - attempt to create /node -- OK
-Init - attempt to create /node - expect EEXIST
-*** END OF TEST DEVFS02 ***
diff --git a/testsuites/libtests/devfs02/init.c b/testsuites/libtests/devfs02/init.c
deleted file mode 100644
index 3e136972b3..0000000000
--- a/testsuites/libtests/devfs02/init.c
+++ /dev/null
@@ -1,108 +0,0 @@
-/*
- *  COPYRIGHT (c) 1989-2012.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  Modifications to support reference counting in the file system are
- *  Copyright (c) 2012 embedded brains GmbH.
- *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#ifdef HAVE_CONFIG_H
-  #include "config.h"
-#endif
-
-#include "test_support.h"
-
-#include <tmacros.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-#include <rtems/devfs.h>
-#include <rtems/malloc.h>
-
-const char rtems_test_name[] = "DEVFS 2";
-
-/* forward declarations to avoid warnings */
-rtems_task Init(rtems_task_argument argument);
-
-rtems_task Init(
-  rtems_task_argument argument
-)
-{
-  int status;
-  rtems_filesystem_location_info_t *rootloc = &rtems_filesystem_root->location;
-  const devFS_data *data = rootloc->mt_entry->immutable_fs_info;
-  devFS_data zero_count_data = {
-    .nodes = data->nodes,
-    .count = 0
-  };
-  void *opaque;
-
-  TEST_BEGIN();
-
-  puts( "Init - attempt to create a fifo - expect ENOTSUP" );
-  status = mkfifo( "/fifo01", 0 );
-  rtems_test_assert( status == -1 );
-  rtems_test_assert( errno == ENOTSUP );
-
-  /* Manipulate the device table size */
-  puts( "Init - set device table size to zero" );
-  rootloc->mt_entry->immutable_fs_info = &zero_count_data;
-
-  puts( "Init - attempt to create a node - expect ENOSPC" );
-  status = mknod( "/node", S_IFBLK, 0LL );
-  rtems_test_assert( status == -1 );
-  rtems_test_assert( errno == ENOSPC );
-
-  /* Now restore */
-  puts( "Init - restore device table size" );
-  rootloc->mt_entry->immutable_fs_info = data;
-
-  opaque = rtems_heap_greedy_allocate( NULL, 0 );
-
-  puts( "Init - attempt to create a node - expect ENOMEM" );
-  status = mknod( "/node", S_IFBLK, 0LL );
-  rtems_test_assert( status == -1 );
-  rtems_test_assert( errno == ENOMEM );
-
-  rtems_heap_greedy_free( opaque );
-
-  puts( "Init - attempt to create /node -- OK" );
-  status = mknod( "/node", S_IFBLK, 0LL );
-  rtems_test_assert( status == 0 );
-
-  puts( "Init - attempt to create /node - expect EEXIST" );
-  status = mknod( "/node", S_IFBLK, 0LL );
-  rtems_test_assert( status == -1 );
-  rtems_test_assert( errno == EEXIST );
-
-  TEST_END();
-
-  rtems_test_exit(0);
-}
-
-/* configuration information */
-
-#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
-
-#define CONFIGURE_MAXIMUM_TASKS             1
-#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
-
-#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
-
-#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 2
-
-/* Make sure that we have enough devices for all BSPs */
-#define CONFIGURE_MAXIMUM_DEVICES 64
-
-#define CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
-
-#define CONFIGURE_INIT
-#include <rtems/confdefs.h>
-/* end of file */
diff --git a/testsuites/libtests/devfs03/devfs03.doc b/testsuites/libtests/devfs03/devfs03.doc
deleted file mode 100644
index 3cbb71facc..0000000000
--- a/testsuites/libtests/devfs03/devfs03.doc
+++ /dev/null
@@ -1,21 +0,0 @@
-#  COPYRIGHT (c) 1989-2010.
-#  On-Line Applications Research Corporation (OAR).
-#
-#  The license and distribution terms for this file may be
-#  found in the file LICENSE in this distribution or at
-#  http://www.rtems.org/license/LICENSE.
-#
-
-This file describes the directives and concepts tested by this test set.
-
-test set name:  devfs03
-
-directives:
-
-+ devFS_initialize
-
-concepts:
-
-+ A call to mount, after consuming much of the workspace memory leads
-to an ENOMEM which initializing the filesystem.
-
diff --git a/testsuites/libtests/devfs03/devfs03.scn b/testsuites/libtests/devfs03/devfs03.scn
deleted file mode 100644
index 06f283eba2..0000000000
--- a/testsuites/libtests/devfs03/devfs03.scn
+++ /dev/null
@@ -1,6 +0,0 @@
-*** TEST DEVFS03 ***
-Init - attempt to create /dir01 -- OK
-Init - allocating most of workspace memory
-Init - mount a new fs at /dir01 - expect ENOMEM
-Init - freeing the workspace memory
-*** END OF TEST DEVFS03 ***
diff --git a/testsuites/libtests/devfs03/init.c b/testsuites/libtests/devfs03/init.c
deleted file mode 100644
index 24940832f0..0000000000
--- a/testsuites/libtests/devfs03/init.c
+++ /dev/null
@@ -1,99 +0,0 @@
-/*
- *  COPYRIGHT (c) 1989-2012.
- *  On-Line Applications Research Corporation (OAR).
- *
- *  Modifications to support reference counting in the file system are
- *  Copyright (c) 2012 embedded brains GmbH.
- *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.org/license/LICENSE.
- */
-
-#ifdef HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#include <tmacros.h>
-#include "test_support.h"
-#include <rtems/devfs.h>
-#include <errno.h>
-#include <unistd.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <fcntl.h>
-
-const char rtems_test_name[] = "DEVFS 3";
-
-/* forward declarations to avoid warnings */
-rtems_task Init(rtems_task_argument argument);
-
-rtems_task Init(
-  rtems_task_argument argument
-)
-{
-  int status;
-  devFS_node nodes [1];
-  devFS_data data = {
-    .nodes = nodes,
-    .count = 1
-  };
-
-  TEST_BEGIN();
-
-  memset(nodes, 0, sizeof(nodes));
-
-  puts( "Init - attempt to create /dir01 -- OK" );
-  status = mkdir( "/dir01", S_IRWXU );
-  rtems_test_assert( status == 0 );
-
-  puts( "Init - mount a new fs at /dir01 - expect EINVAL" );
-  status = mount( NULL, 
-		  "/dir01", 
-		  "devfs", 
-		  RTEMS_FILESYSTEM_READ_WRITE,
-		  NULL );
-  rtems_test_assert( status == -1 );
-  rtems_test_assert( errno == EINVAL );
-
-  puts( "Init - mount a new fs at /dir01 - OK" );
-  status = mount( NULL, 
-		  "/dir01", 
-		  "devfs", 
-		  RTEMS_FILESYSTEM_READ_WRITE,
-		  &data );
-  rtems_test_assert( status == 0 );
-
-  puts( "Init - make file /dir01/dev -- expect ENOTSUP" );
-  status = creat( "/dir01/dev", S_IRWXU );
-  rtems_test_assert( status == -1 );
-  rtems_test_assert( errno == ENOTSUP );
-
-  puts( "Init - unmount fs at /dir01 - OK" );
-  status = unmount( "/dir01" );
-  rtems_test_assert( status == 0 );
-
-  status = rmdir( "/dir01" );
-  rtems_test_assert( status == 0 );
-
-  TEST_END();
-
-  rtems_test_exit(0);
-}
-
-/* configuration information */
-
-#define CONFIGURE_APPLICATION_NEEDS_SIMPLE_CONSOLE_DRIVER
-#define CONFIGURE_APPLICATION_NEEDS_CLOCK_DRIVER
-
-#define CONFIGURE_MAXIMUM_FILE_DESCRIPTORS 4
-#define CONFIGURE_MAXIMUM_TASKS             1
-#define CONFIGURE_INITIAL_EXTENSIONS RTEMS_TEST_INITIAL_EXTENSION
-
-#define CONFIGURE_RTEMS_INIT_TASKS_TABLE
-
-#define CONFIGURE_FILESYSTEM_DEVFS
-
-#define CONFIGURE_INIT
-#include <rtems/confdefs.h>
-/* end of file */
diff --git a/testsuites/libtests/devfs04/init.c b/testsuites/libtests/devfs04/init.c
index bc747a8e07..a7549abdad 100644
--- a/testsuites/libtests/devfs04/init.c
+++ b/testsuites/libtests/devfs04/init.c
@@ -13,21 +13,17 @@
 
 #include <tmacros.h>
 #include "test_support.h"
-#include <rtems/devfs.h>
 #include <errno.h>
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/ioctl.h>
 #include <fcntl.h>
 #include "test_driver.h"
-#include <rtems/devnull.h>
 
 const char rtems_test_name[] = "DEVFS 4";
 
-/* forward declarations to avoid warnings */
-rtems_task Init(rtems_task_argument argument);
-
-rtems_task Init(
+static rtems_task Init(
   rtems_task_argument argument
 )
 {
@@ -88,9 +84,6 @@ rtems_task Init(
 
 #define CONFIGURE_RTEMS_INIT_TASKS_TABLE
 
-/* Make sure that we have enough devices for all BSPs */
-#define CONFIGURE_MAXIMUM_DEVICES 64
-
 #define CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM
 
 #define CONFIGURE_INIT
diff --git a/testsuites/libtests/deviceio01/init.c b/testsuites/libtests/deviceio01/init.c
index ff6223234f..c27e345be5 100644
--- a/testsuites/libtests/deviceio01/init.c
+++ b/testsuites/libtests/deviceio01/init.c
@@ -13,21 +13,18 @@
 
 #include <tmacros.h>
 #include "test_support.h"
-#include <rtems/devfs.h>
 #include <errno.h>
 #include <unistd.h>
 #include <sys/types.h>
 #include <sys/stat.h>
+#include <sys/ioctl.h>
 #include <fcntl.h>
 #include "test_driver.h"
 #include <rtems/devnull.h>
 
 const char rtems_test_name[] = "DEVICEIO 1";
 
-/* forward declarations to avoid warnings */
-rtems_task Init(rtems_task_argument argument);
-
-rtems_task Init(
+static rtems_task Init(
   rtems_task_argument argument
 )
 {
-- 
2.16.4



More information about the devel mailing list