Index: cpukit/ChangeLog
===================================================================
--- cpukit/ChangeLog	(revision e8fcadbc490beb95478b7d6a9b37e29c749bf9a7)
+++ cpukit/ChangeLog	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -1,2 +1,25 @@
+2008-09-17	Miao Yan <yanmiaobest@gmail.com>
+
+	* Makefile.am, preinstall.am, libcsupport/Makefile.am,
+	libcsupport/include/rtems/libcsupport.h,
+	libcsupport/include/rtems/libio.h, libcsupport/src/base_fs.c,
+	libcsupport/src/libio_init.c, libcsupport/src/newlibc_exit.c,
+	libcsupport/src/newlibc_init.c, libcsupport/src/sync.c,
+	libfs/Makefile.am, libfs/src/imfs/deviceio.c,
+	sapi/include/confdefs.h: Merge GSOC project code to add simple device
+	only filesystem (devfs), optionally completely drop out filesystem,
+	and to clean up disabling newlib reentrancy support. This dropped 17K
+	from the minimum.exe for sparc/sis and arm/rtl22xx_t now has a 15K
+	code space.
+	* libcsupport/src/__usrenv.c, libcsupport/src/newlibc_reent.c,
+	libfs/src/devfs/devclose.c, libfs/src/devfs/devfs.h,
+	libfs/src/devfs/devfs_eval.c, libfs/src/devfs/devfs_init.c,
+	libfs/src/devfs/devfs_mknod.c, libfs/src/devfs/devfs_node_type.c,
+	libfs/src/devfs/devfs_show.c, libfs/src/devfs/devioctl.c,
+	libfs/src/devfs/devopen.c, libfs/src/devfs/devread.c,
+	libfs/src/devfs/devstat.c, libfs/src/devfs/devwrite.c,
+	libfs/src/imfs/deviceerrno.c: New files.
+	* libcsupport/src/newlibc.c: Removed.
+
 2008-09-16	Joel Sherrill <joel.sherrill@OARcorp.com>
 
Index: cpukit/Makefile.am
===================================================================
--- cpukit/Makefile.am	(revision e8fcadbc490beb95478b7d6a9b37e29c749bf9a7)
+++ cpukit/Makefile.am	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -80,4 +80,7 @@
 include_rtems_HEADERS += libfs/src/imfs/imfs.h
 
+## devfs
+include_rtems_HEADERS += libfs/src/devfs/devfs.h
+
 if LIBDOSFS
 include_rtems_HEADERS += libfs/src/dosfs/dosfs.h
Index: cpukit/libcsupport/Makefile.am
===================================================================
--- cpukit/libcsupport/Makefile.am	(revision e8fcadbc490beb95478b7d6a9b37e29c749bf9a7)
+++ cpukit/libcsupport/Makefile.am	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -48,5 +48,5 @@
     src/libio_init.c \
     src/libio_sockets.c src/eval.c src/fs_null_handlers.c src/privateenv.c \
-    src/open_dev_console.c
+    src/open_dev_console.c src/__usrenv.c
 
 TERMIOS_C_FILES = src/cfgetispeed.c src/cfgetospeed.c src/cfsetispeed.c \
@@ -95,5 +95,5 @@
 LIBC_GLUE_C_FILES = src/__getpid.c src/__gettod.c src/__times.c \
     src/truncate.c src/access.c src/stat.c src/lstat.c src/pathconf.c \
-    src/newlibc.c src/newlibc_init.c src/newlibc_exit.c src/no_posix.c \
+    src/newlibc_reent.c src/newlibc_init.c src/newlibc_exit.c src/no_posix.c \
     src/no_libc.c src/utsname.c
 
Index: cpukit/libcsupport/include/rtems/libcsupport.h
===================================================================
--- cpukit/libcsupport/include/rtems/libcsupport.h	(revision e8fcadbc490beb95478b7d6a9b37e29c749bf9a7)
+++ cpukit/libcsupport/include/rtems/libcsupport.h	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -46,5 +46,5 @@
  *  Prototypes required to install newlib reentrancy user extension
  */
-bool libc_create_hook(
+bool newlib_create_hook(
   rtems_tcb *current_task,
   rtems_tcb *creating_task
@@ -52,11 +52,11 @@
 
 #if defined(RTEMS_UNIX) && !defined(hpux)
-  rtems_extension libc_begin_hook(rtems_tcb *current_task);
-  #define __RTEMS_NEWLIB_BEGIN libc_begin_hook
+  rtems_extension newlib_begin_hook(rtems_tcb *current_task);
+  #define __RTEMS_NEWLIB_BEGIN newlib_begin_hook
 #else
   #define __RTEMS_NEWLIB_BEGIN 0
 #endif
 
-rtems_extension libc_delete_hook(
+rtems_extension newlib_delete_hook(
   rtems_tcb *current_task,
   rtems_tcb *deleted_task
@@ -65,12 +65,12 @@
 #define RTEMS_NEWLIB_EXTENSION \
 { \
-  libc_create_hook,                            /* rtems_task_create  */ \
-  0,                                           /* rtems_task_start   */ \
-  0,                                           /* rtems_task_restart */ \
-  libc_delete_hook,                            /* rtems_task_delete  */ \
-  0,                                           /* task_switch  */ \
-  __RTEMS_NEWLIB_BEGIN,                        /* task_begin   */ \
-  0,                                           /* task_exitted */ \
-  0                                            /* fatal        */ \
+  newlib_create_hook,     /* rtems_task_create  */ \
+  0,                      /* rtems_task_start   */ \
+  0,                      /* rtems_task_restart */ \
+  newlib_delete_hook,     /* rtems_task_delete  */ \
+  0,                      /* task_switch  */ \
+  __RTEMS_NEWLIB_BEGIN,   /* task_begin   */ \
+  0,                      /* task_exitted */ \
+  0                       /* fatal        */ \
 }
 
Index: cpukit/libcsupport/include/rtems/libio.h
===================================================================
--- cpukit/libcsupport/include/rtems/libio.h	(revision e8fcadbc490beb95478b7d6a9b37e29c749bf9a7)
+++ cpukit/libcsupport/include/rtems/libio.h	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -635,4 +635,16 @@
 extern const int                             rtems_filesystem_mount_table_size;
 
+
+typedef void (*rtems_libio_init_functions_t)(void);
+extern  rtems_libio_init_functions_t rtems_libio_init_helper;
+
+void    open_dev_console(void);
+
+typedef void (*rtems_libio_supp_functions_t)(void);
+extern  rtems_libio_supp_functions_t rtems_libio_supp_helper;
+
+typedef void (*rtems_fs_init_functions_t)(void);
+extern  rtems_fs_init_functions_t    rtems_fs_init_helper;
+
 #ifdef __cplusplus
 }
Index: cpukit/libcsupport/src/__usrenv.c
===================================================================
--- cpukit/libcsupport/src/__usrenv.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
+++ cpukit/libcsupport/src/__usrenv.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -0,0 +1,27 @@
+/*
+ *  COPYRIGHT (c) 1989-2008.
+ *  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.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems.h>
+#include <rtems/libio.h>
+#include <rtems/libio_.h>
+
+/*
+ *  Global information for POSIX Process Environment Support
+ */
+
+rtems_user_env_t   rtems_global_user_env;
+rtems_user_env_t * rtems_current_user_env = &rtems_global_user_env;
+
+
Index: cpukit/libcsupport/src/base_fs.c
===================================================================
--- cpukit/libcsupport/src/base_fs.c	(revision e8fcadbc490beb95478b7d6a9b37e29c749bf9a7)
+++ cpukit/libcsupport/src/base_fs.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -2,5 +2,5 @@
  *  Base file system initialization
  *
- *  COPYRIGHT (c) 1989-1999.
+ *  COPYRIGHT (c) 1989-2008.
  *  On-Line Applications Research Corporation (OAR).
  *
@@ -19,11 +19,4 @@
 #include <rtems/libio.h>
 #include <rtems/libio_.h>
-
-/*
- *  Global information for the base file system.
- */
-
-rtems_user_env_t   rtems_global_user_env;
-rtems_user_env_t * rtems_current_user_env = &rtems_global_user_env;
 
 /*
Index: cpukit/libcsupport/src/libio_init.c
===================================================================
--- cpukit/libcsupport/src/libio_init.c	(revision e8fcadbc490beb95478b7d6a9b37e29c749bf9a7)
+++ cpukit/libcsupport/src/libio_init.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -87,4 +87,5 @@
    */
 
-  rtems_filesystem_initialize();
+  if (rtems_fs_init_helper)
+     (* rtems_fs_init_helper)();
 }
Index: ukit/libcsupport/src/newlibc.c
===================================================================
--- cpukit/libcsupport/src/newlibc.c	(revision e8fcadbc490beb95478b7d6a9b37e29c749bf9a7)
+++ 	(revision )
@@ -1,175 +1,0 @@
-/*
- *  Implementation of hooks for the CYGNUS newlib libc
- *  These hooks set things up so that:
- *       + '_REENT' is switched at task switch time.
- *
- *  COPYRIGHT (c) 1994 by Division Incorporated
- *
- *  The license and distribution terms for this file may be
- *  found in the file LICENSE in this distribution or at
- *  http://www.rtems.com/license/LICENSE.
- *
- *  $Id$
- *
- */
-
-#if HAVE_CONFIG_H
-#include "config.h"
-#endif
-
-#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
-#include <rtems.h>
-
-#if defined(RTEMS_NEWLIB)
-#include <rtems/libcsupport.h>
-
-/* Since we compile with strict ANSI we need to undef it to get
- * prototypes for extensions
- */
-#undef __STRICT_ANSI__
-
-#include <stdlib.h>             /* for free() */
-#include <string.h>             /* for memset() */
-
-#include <sys/reent.h>          /* for extern of _REENT (aka _impure_ptr) */
-#include <errno.h>
-
-/*
- *  NOTE:
- *        There is some problem with doing this on the hpux version
- *        of the UNIX simulator (symptom is printf core dumps), so
- *        we just don't for now.
- *        Not sure if this is a problem with hpux, newlib, or something else.
- */
-
-#if defined(RTEMS_UNIX) && !defined(hpux)
-#define NEED_SETVBUF
-#endif
-
-#include <stdio.h>
-
-int _fwalk(struct _reent *ptr, int (*function) (FILE *) );
-
-extern struct _reent    libc_global_reent __ATTRIBUTE_IMPURE_PTR__;
-
-/*
- * reent struct allocation moved here from libc_start_hook() to avoid
- * mutual exclusion problems when memory is allocated from the start hook.
- *
- * Memory is also now allocated from the workspace rather than the heap.
- *  -- ptorre 9/30/03
- */
-bool libc_create_hook(
-  rtems_tcb *current_task,
-  rtems_tcb *creating_task
-)
-{
-  struct _reent *ptr;
-
-  /*  NOTE: The RTEMS malloc is reentrant without a reent ptr since
-   *        it is based on the Classic API Region Manager.
-   */
-
-  #define REENT_MALLOCED 0
-  #if REENT_MALLOCED
-    ptr = (struct _reent *) calloc(1, sizeof(struct _reent));
-  #else
-    /* It is OK to allocate from the workspace because these
-     * hooks run with thread dispatching disabled.
-     */
-    ptr = (struct _reent *) _Workspace_Allocate(sizeof(struct _reent));
-  #endif
-
-  if (ptr) {
-
-      _REENT_INIT_PTR((ptr)); /* GCC extension: structure constants */
-      creating_task->libc_reent = ptr;
-      return true;
-  }
-  else
-    return false;
-}
-
-/*
- * Called for all user TASKS (system tasks are MPCI Receive Server and IDLE)
- */
-
-#ifdef NEED_SETVBUF
-rtems_extension libc_begin_hook(rtems_tcb *current_task)
-{
-  setvbuf( stdout, NULL, _IOLBF, BUFSIZ );
-}
-#endif
-
-/*
- *  Called when a task is deleted.
- *  Must restore the new lib reentrancy state for the new current
- *  task.
- *
- */
-
-int newlib_free_buffers(
-  FILE *fp
-)
-{
-  switch ( fileno(fp) ) {
-    case 0:
-    case 1:
-    case 2:
-      if (fp->_flags & __SMBF) {
-        free( fp->_bf._base );
-        fp->_flags &= ~__SMBF;
-        fp->_bf._base = fp->_p = (unsigned char *) NULL;
-      }
-      break;
-    default:
-     fclose(fp);
-  }
-  return 0;
-}
-
-rtems_extension libc_delete_hook(
-  rtems_tcb *current_task,
-  rtems_tcb *deleted_task
-)
-{
-  struct _reent *ptr;
-
-  /*
-   * The reentrancy structure was allocated by newlib using malloc()
-   */
-
-  if (current_task == deleted_task) {
-    ptr = _REENT;
-  } else {
-    ptr = deleted_task->libc_reent;
-  }
-
-  if (ptr && ptr != &libc_global_reent) {
-/*
-    _wrapup_reent(ptr);
-    _reclaim_reent(ptr);
-*/
-    /*
-     *  Just in case there are some buffers lying around.
-     */
-    _fwalk(ptr, newlib_free_buffers);
-#if REENT_MALLOCED
-    free(ptr);
-#else
-    _Workspace_Free(ptr);
-#endif
-  }
-
-  deleted_task->libc_reent = NULL;
-
-  /*
-   * Require the switch back to another task to install its own
-   */
-
-  if ( current_task == deleted_task ) {
-    _REENT = 0;
-  }
-}
-
-#endif
Index: cpukit/libcsupport/src/newlibc_exit.c
===================================================================
--- cpukit/libcsupport/src/newlibc_exit.c	(revision e8fcadbc490beb95478b7d6a9b37e29c749bf9a7)
+++ cpukit/libcsupport/src/newlibc_exit.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -41,5 +41,5 @@
 /* do we think we are reentrant? */
 extern int             libc_reentrant;
-extern struct _reent   libc_global_reent __ATTRIBUTE_IMPURE_PTR__;
+extern struct _reent * const _global_impure_ptr __ATTRIBUTE_IMPURE_PTR__;
 
 /*
@@ -67,6 +67,6 @@
    */
 
-  if (_REENT != &libc_global_reent) {
-      _wrapup_reent(&libc_global_reent);
+  if (_REENT != _global_impure_ptr) {
+      _wrapup_reent(_global_impure_ptr);
 #if 0
       /*  Don't reclaim this one, just in case we do printfs
@@ -75,5 +75,5 @@
       _reclaim_reent(&libc_global_reent);
 #endif
-      _REENT = &libc_global_reent;
+      _REENT = _global_impure_ptr;
   }
 
Index: cpukit/libcsupport/src/newlibc_init.c
===================================================================
--- cpukit/libcsupport/src/newlibc_init.c	(revision e8fcadbc490beb95478b7d6a9b37e29c749bf9a7)
+++ cpukit/libcsupport/src/newlibc_init.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -18,20 +18,5 @@
 #endif
 
-#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
-#include <rtems.h>
-
 #if defined(RTEMS_NEWLIB)
-#include <rtems/libcsupport.h>
-
-/* Since we compile with strict ANSI we need to undef it to get
- * prototypes for extensions
- */
-#undef __STRICT_ANSI__
-
-#include <stdlib.h>             /* for free() */
-#include <string.h>             /* for memset() */
-
-#include <sys/reent.h>          /* for extern of _REENT (aka _impure_ptr) */
-#include <errno.h>
 
 /*
@@ -49,12 +34,7 @@
 
 
-struct _reent    libc_global_reent
-    __ATTRIBUTE_IMPURE_PTR__ = _REENT_INIT(libc_global_reent);
 void
 libc_init(void)
 {
-  _REENT = &libc_global_reent;
-
-  _Thread_Set_libc_reent (&_REENT);
 }
 
Index: cpukit/libcsupport/src/newlibc_reent.c
===================================================================
--- cpukit/libcsupport/src/newlibc_reent.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
+++ cpukit/libcsupport/src/newlibc_reent.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -0,0 +1,174 @@
+/*
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ *
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#define __RTEMS_VIOLATE_KERNEL_VISIBILITY__
+#include <rtems.h>
+
+#if defined(RTEMS_NEWLIB)
+#include <rtems/libcsupport.h>
+
+/* Since we compile with strict ANSI we need to undef it to get
+ * prototypes for extensions
+ */
+#undef __STRICT_ANSI__
+
+#include <stdlib.h>             /* for free() */
+#include <string.h>             /* for memset() */
+
+#include <sys/reent.h>          /* for extern of _REENT (aka _impure_ptr) */
+#include <errno.h>
+
+/*
+ *  NOTE:
+ *        There is some problem with doing this on the hpux version
+ *        of the UNIX simulator (symptom is printf core dumps), so
+ *        we just don't for now.
+ *        Not sure if this is a problem with hpux, newlib, or something else.
+ */
+
+#if defined(RTEMS_UNIX) && !defined(hpux)
+#define NEED_SETVBUF
+#endif
+
+#include <stdio.h>
+
+int _fwalk(struct _reent *ptr, int (*function) (FILE *) );
+
+extern struct _reent * const _global_impure_ptr __ATTRIBUTE_IMPURE_PTR__;
+/*
+ * reent struct allocation moved here from libc_start_hook() to avoid
+ * mutual exclusion problems when memory is allocated from the start hook.
+ *
+ * Memory is also now allocated from the workspace rather than the heap.
+ *  -- ptorre 9/30/03
+ */
+bool newlib_create_hook(
+  rtems_tcb *current_task,
+  rtems_tcb *creating_task
+)
+{
+  struct _reent *ptr;
+
+  if (_Thread_libc_reent == 0)
+  {
+    _REENT = _global_impure_ptr;
+
+    _Thread_Set_libc_reent (&_REENT);
+  }
+
+  /*  NOTE: The RTEMS malloc is reentrant without a reent ptr since
+   *        it is based on the Classic API Region Manager.
+   */
+
+  #define REENT_MALLOCED 0
+  #if REENT_MALLOCED
+    ptr = (struct _reent *) calloc(1, sizeof(struct _reent));
+  #else
+    /* It is OK to allocate from the workspace because these
+     * hooks run with thread dispatching disabled.
+     */
+    ptr = (struct _reent *) _Workspace_Allocate(sizeof(struct _reent));
+  #endif
+
+  if (ptr) {
+    _REENT_INIT_PTR((ptr)); /* GCC extension: structure constants */
+    creating_task->libc_reent = ptr;
+    return TRUE;
+  }
+
+  return FALSE;
+}
+
+/*
+ * Called for all user TASKS (system tasks are MPCI Receive Server and IDLE)
+ */
+
+#ifdef NEED_SETVBUF
+rtems_extension newlib_begin_hook(rtems_tcb *current_task)
+{
+  setvbuf( stdout, NULL, _IOLBF, BUFSIZ );
+}
+#endif
+
+/*
+ *  Called when a task is deleted.
+ *  Must restore the new lib reentrancy state for the new current
+ *  task.
+ *
+ */
+
+int newlib_free_buffers(
+  FILE *fp
+)
+{
+  switch ( fileno(fp) ) {
+    case 0:
+    case 1:
+    case 2:
+      if (fp->_flags & __SMBF) {
+        free( fp->_bf._base );
+        fp->_flags &= ~__SMBF;
+        fp->_bf._base = fp->_p = (unsigned char *) NULL;
+      }
+      break;
+    default:
+     fclose(fp);
+  }
+  return 0;
+}
+
+rtems_extension newlib_delete_hook(
+  rtems_tcb *current_task,
+  rtems_tcb *deleted_task
+)
+{
+  struct _reent *ptr;
+
+  /*
+   * The reentrancy structure was allocated by newlib using malloc()
+   */
+
+  if (current_task == deleted_task) {
+    ptr = _REENT;
+  } else {
+    ptr = deleted_task->libc_reent;
+  }
+
+  if (ptr && ptr != _global_impure_ptr) {
+/*
+    _wrapup_reent(ptr);
+    _reclaim_reent(ptr);
+*/
+    /*
+     *  Just in case there are some buffers lying around.
+     */
+    _fwalk(ptr, newlib_free_buffers);
+#if REENT_MALLOCED
+    free(ptr);
+#else
+    _Workspace_Free(ptr);
+#endif
+  }
+
+  deleted_task->libc_reent = NULL;
+
+  /*
+   * Require the switch back to another task to install its own
+   */
+
+  if ( current_task == deleted_task ) {
+    _REENT = 0;
+  }
+}
+
+#endif
Index: cpukit/libcsupport/src/sync.c
===================================================================
--- cpukit/libcsupport/src/sync.c	(revision e8fcadbc490beb95478b7d6a9b37e29c749bf9a7)
+++ cpukit/libcsupport/src/sync.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -8,5 +8,5 @@
  *         fdatasync()
  *
- *  COPYRIGHT (c) 1989-2003.
+ *  COPYRIGHT (c) 1989-2008.
  *  On-Line Applications Research Corporation (OAR).
  *
@@ -72,8 +72,8 @@
 
 /*
- * libc_global_reent is not prototyped in any .h files.
+ * _global_impure_ptr is not prototyped in any .h files.
  * We have to extern it here.
  */
-extern struct _reent libc_global_reent;
+extern struct _reent * const _global_impure_ptr __ATTRIBUTE_IMPURE_PTR__;
 
 void sync(void)
@@ -83,5 +83,5 @@
    *  Walk the one used initially by RTEMS.
    */
-  _fwalk(&libc_global_reent, sync_wrapper);
+  _fwalk(_global_impure_ptr, sync_wrapper);
 
   /*
Index: cpukit/libfs/Makefile.am
===================================================================
--- cpukit/libfs/Makefile.am	(revision e8fcadbc490beb95478b7d6a9b37e29c749bf9a7)
+++ cpukit/libfs/Makefile.am	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -32,5 +32,11 @@
     src/imfs/imfs_readlink.c src/imfs/imfs_fdatasync.c src/imfs/imfs_fcntl.c \
     src/imfs/ioman.c src/imfs/miniimfs_init.c src/imfs/imfs_load_tar.c \
-    src/imfs/imfs.h
+    src/imfs/imfs.h \
+    src/imfs/deviceerrno.c \
+    src/devfs/devfs_init.c src/devfs/devfs_eval.c src/devfs/devfs_mknod.c \
+    src/devfs/devfs_show.c src/devfs/devfs_node_type.c \
+    src/devfs/devopen.c src/devfs/devread.c src/devfs/devwrite.c \
+    src/devfs/devclose.c src/devfs/devioctl.c src/devfs/devstat.c \
+    src/devfs/devfs.h
 endif
 
Index: cpukit/libfs/src/devfs/devclose.c
===================================================================
--- cpukit/libfs/src/devfs/devclose.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
+++ cpukit/libfs/src/devfs/devclose.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -0,0 +1,43 @@
+/*
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems.h>
+#include <rtems/io.h>
+
+#include "devfs.h"
+
+int devFS_close(
+  rtems_libio_t *iop
+)
+{
+  rtems_libio_open_close_args_t  args;
+  rtems_status_code              status;
+  rtems_driver_name_t           *np;
+
+  np         = (rtems_device_name_t *)iop->file_info;
+
+  args.iop   = iop;
+  args.flags = 0;
+  args.mode  = 0;
+
+  status = rtems_io_close(
+    np->major,
+    np->minor,
+    (void *) &args
+  );
+  if ( status ) {
+    return rtems_deviceio_errno(status);
+  }
+  return 0;
+}
+
+
Index: cpukit/libfs/src/devfs/devfs.h
===================================================================
--- cpukit/libfs/src/devfs/devfs.h	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
+++ cpukit/libfs/src/devfs/devfs.h	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -0,0 +1,294 @@
+/** 
+*  @file  libfs/devfs/devfs.h
+*
+*  This include file contains all constants and structures associated
+*  with the 'device-only' filesystem.
+*/
+
+#ifndef _RTEMS_DEVFS_H
+#define _RTEMS_DEVFS_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include <rtems/libio_.h>
+
+/**
+ *  This structure define the type of device table
+ */
+
+typedef struct 
+{
+  /** This member pointes to device name which is a null-terminated string */
+  char                     *device_name;
+  /** This member is the name length of a device */
+  uint32_t                  device_name_length;
+  /** 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;
+
+}rtems_device_name_t;
+
+
+
+/**
+ *  This routine associates RTEMS status code with errno
+ */
+
+extern int rtems_deviceio_errno(rtems_status_code code);
+
+
+/**
+ *  The following defines the device table size. This values
+ *  is configured during application configuration time by 
+ *  the user. The default value is set to 4.
+ */
+
+extern uint32_t rtems_device_table_size;
+
+
+/**
+ *  The following defines the device-only filesystem operating
+ *  handlers.
+ */
+
+extern rtems_filesystem_operations_table devFS_ops; 
+
+/**
+ *  The following defines the device-only filesystem operating
+ *  handlers.
+ */
+
+extern rtems_filesystem_file_handlers_r  devFS_file_handlers; 
+
+
+/**
+ *  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 flag access flags
+ *  @param mode access mode
+ *  @retval the same as open
+ */
+
+int devFS_open(
+  rtems_libio_t *iop,
+  const char    *pathname,
+  uint32_t       flag,
+  uint32_t       mode
+);
+
+
+/**
+ *  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
+ */
+
+
+int devFS_close(
+  rtems_libio_t *iop
+);
+
+
+/**
+ *  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.
+ */
+
+ssize_t devFS_read(
+  rtems_libio_t *iop,
+  void          *buffer,
+  size_t         count
+);
+
+
+/**
+ *  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.
+ */
+
+ssize_t devFS_write(
+  rtems_libio_t *iop,
+  const void    *buffer,
+  size_t         count
+);
+
+
+/**
+ *  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.
+ */
+
+int devFS_ioctl(
+  rtems_libio_t *iop,
+  uint32_t       command,
+  void          *buffer
+);
+
+
+
+
+/**
+ *  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.
+ */
+
+int devFS_stat(
+  rtems_filesystem_location_info_t *loc,
+  struct stat                      *buf
+);
+
+
+
+/**
+ *  This routine is invoked upon determination of a node type.
+ *  Since this is a device-only filesystem, so there is only 
+ *  one node type in the system.
+ *  
+ *  @param pathloc contains filesytem access information, this 
+ *         parameter is ignored
+ *  @retval always returns RTEMS_FILESYSTEM_DEVICE
+ */
+
+int devFS_node_type(
+  rtems_filesystem_location_info_t  *pathloc
+);
+
+
+
+/**
+ *  This routine is invoked to determine if 'pathname' exists.
+ *  This routine first check access flags, then it searches 
+ *  the device table to get the information.
+ * 
+ *  @param pathname device name to be searched
+ *  @param flags access flags
+ *  @param pathloc contains filesystem access information
+ *  @retval upon success(pathname exists), this routines 
+ *  returns 0; if 'flag' is invalid, it returns -1 and errno 
+ *  is set to EIO; otherwise, it returns -1 and errno is set to ENOENT
+ */
+
+int devFS_evaluate_path(
+  const char                        *pathname,
+  int                                flags,
+  rtems_filesystem_location_info_t  *pathloc
+);
+
+
+/**
+ *  This routine is given a path to evaluate and a valid start 
+ *  location. It is responsible for finding the parent node for
+ *  a requested make command, setting pathloc information to
+ *  identify the parent node, and setting the name pointer to 
+ *  the first character of the name of the new node. In device 
+ *  only filesystem, devices do not has a tree hierarchy, there
+ *  are no parent-child relationship. So this routine is rather 
+ *  simple, it just set *name to path and returns
+ *
+ *  @param path device path to be evaluated
+ *  @param pathloc contains filesystem access information, this 
+ *         parameter is ignored
+ *  @param name 
+ *  @retval always returns 0
+ */
+
+int devFS_evaluate_for_make(
+   const char                         *path,
+   rtems_filesystem_location_info_t   *pathloc,
+   const char                        **name
+);
+
+
+
+/**
+ *  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.
+ *
+ *  @param path the device file name to be registered
+ *  @param mode file mode, this parameter is ignored
+ *  @param dev  device major and minor number
+ *  @param pathloc contains filesystem access information
+ *  @retval upon success, this routine returns 0; if 'path'
+ *  already exist, it returns -1 and errno is set to EEXIST;
+ *  if device table is full, it returns -1 and errno is set 
+ *  to ENOMEM
+ */
+
+int devFS_mknod(
+   const char                        *path,
+   mode_t                             mode, 
+   dev_t                              dev,  
+   rtems_filesystem_location_info_t  *pathloc 
+);
+
+
+/**
+ *  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  temp_mt_entry
+ *  @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.
+ */
+
+int devFS_initialize(
+  rtems_filesystem_mount_table_entry_t *temp_mt_entry
+);
+
+
+/**
+ *  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:
+ *  
+ *  /dev/console     0  0
+ *  /dev/clock       1  0
+ *  /dev/tty0        0  0
+ *  /flash           2  0
+ * 
+ *  This routine is intended for debugging, and can be used by shell 
+ *  program to provide user with the system information.
+ *  
+ *  @param  none
+ *  @retval 0
+ */
+
+int devFS_Show(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
+
Index: cpukit/libfs/src/devfs/devfs_eval.c
===================================================================
--- cpukit/libfs/src/devfs/devfs_eval.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
+++ cpukit/libfs/src/devfs/devfs_eval.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -0,0 +1,65 @@
+/*
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/seterr.h>
+#include <fcntl.h>
+#include <assert.h>
+#include "devfs.h"
+
+int devFS_evaluate_path(
+  const char                        *pathname,
+  int                                flags,
+  rtems_filesystem_location_info_t  *pathloc
+)
+{
+    int                   i;
+    rtems_device_name_t  *device_name_table;
+
+    /* see if 'flags' is valid */
+    if ( !rtems_libio_is_valid_perms( flags ) ) {
+        assert( 0 );
+        rtems_set_errno_and_return_minus_one( EIO );
+    }
+
+    /* get the device name table */
+    device_name_table = (rtems_device_name_t *)pathloc->node_access;
+    if (!device_name_table)
+        rtems_set_errno_and_return_minus_one( EFAULT );
+
+    for (i = 0; i < rtems_device_table_size; i++){
+        if ((device_name_table[i].device_name) && 
+		(strcmp(device_name_table[i].device_name, pathname) == 0)){
+            /* find the device, set proper values */
+            pathloc->node_access = (void *)&device_name_table[i];
+            pathloc->handlers = &devFS_file_handlers;
+            pathloc->ops = &devFS_ops;
+            pathloc->mt_entry = &rtems_filesystem_root;
+            return 0;
+        }
+    }
+    /* no such file or directory */
+    rtems_set_errno_and_return_minus_one( ENOENT );
+}
+
+
+
+int devFS_evaluate_for_make(
+   const char                         *path,
+   rtems_filesystem_location_info_t   *pathloc,
+   const char                        **name
+)
+{
+    /* we do nothing, just set name to path */
+   *name = path;
+    return 0;
+}
+
Index: cpukit/libfs/src/devfs/devfs_init.c
===================================================================
--- cpukit/libfs/src/devfs/devfs_init.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
+++ cpukit/libfs/src/devfs/devfs_init.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -0,0 +1,87 @@
+/*
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems/seterr.h>
+#include <stdlib.h>
+#include "devfs.h"
+
+rtems_filesystem_operations_table devFS_ops = 
+{
+    devFS_evaluate_path,
+    devFS_evaluate_for_make,
+    NULL,
+    NULL,
+    devFS_node_type,
+    devFS_mknod,
+    NULL,
+    NULL,
+    NULL,
+    devFS_initialize,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL
+};
+
+
+rtems_filesystem_file_handlers_r devFS_file_handlers = 
+{
+    devFS_open,
+    devFS_close,
+    devFS_read,
+    devFS_write,
+    devFS_ioctl,
+    NULL,
+    devFS_stat,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL,
+    NULL
+};
+
+
+
+int devFS_initialize(
+  rtems_filesystem_mount_table_entry_t *temp_mt_entry
+)
+{
+  rtems_device_name_t  *device_name_table;
+
+  /* allocate device only filesystem name table */
+  device_name_table = (rtems_device_name_t *)_Workspace_Allocate(
+        sizeof( rtems_device_name_t ) * ( rtems_device_table_size )
+        );
+
+  /* no memory for device filesystem */
+  if (!device_name_table)
+      rtems_set_errno_and_return_minus_one( ENOMEM );
+
+  memset(
+    device_name_table, 0, 
+    sizeof( rtems_device_name_t ) * ( rtems_device_table_size )
+    );
+
+  /* set file handlers */
+  temp_mt_entry->mt_fs_root.handlers     = &devFS_file_handlers;
+  temp_mt_entry->mt_fs_root.ops          = &devFS_ops;
+
+  /* Set the node_access to device name table */
+  temp_mt_entry->mt_fs_root.node_access = (void *)device_name_table;
+
+  return 0;
+}
+
Index: cpukit/libfs/src/devfs/devfs_mknod.c
===================================================================
--- cpukit/libfs/src/devfs/devfs_mknod.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
+++ cpukit/libfs/src/devfs/devfs_mknod.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -0,0 +1,81 @@
+/*
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <unistd.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#include <rtems/seterr.h>
+#include "devfs.h"
+
+int devFS_mknod(
+  const char                        *path,
+  mode_t                             mode, 
+  dev_t                              dev,  
+  rtems_filesystem_location_info_t  *pathloc 
+)
+{
+  int                       i;
+  int                       slot;
+  rtems_device_name_t      *device_name_table;
+  rtems_device_major_number major;
+  rtems_device_minor_number minor;
+  ISR_Level                 level;
+
+  /*
+   * This is a special case. In rtems_filesystem_initialize, 
+   * a special device '/dev' will be created. We check this 
+   * condition and do not create the '/dev' and the 'path' 
+   * actually passed in is 'dev', not '/dev'. Just return 0 to
+   * indicate we are OK.
+   */
+
+  if ((path[0] == 'd') && (path[1] == 'e') && 
+      (path[2] == 'v') && (path[3] == '\0'))
+      return 0;
+
+  /* must be a character device or a block device */
+  if (!S_ISBLK(mode) && !S_ISCHR(mode))
+    rtems_set_errno_and_return_minus_one( EINVAL );
+  else
+    rtems_filesystem_split_dev_t(dev, major, minor);
+
+  /* Find an empty slot in device name table */
+  device_name_table = (rtems_device_name_t *)pathloc->node_access;
+  if (!device_name_table)
+    rtems_set_errno_and_return_minus_one( EFAULT );
+
+  for (slot = -1, i = 0; i < rtems_device_table_size; i++){
+      if (device_name_table[i].device_name == NULL)
+          slot = i;
+      else
+          if (strcmp(path, device_name_table[i].device_name) == 0)
+              rtems_set_errno_and_return_minus_one( EEXIST );
+  }
+
+  if (slot == -1)
+      rtems_set_errno_and_return_minus_one( ENOMEM );
+
+  _ISR_Disable(level);
+  device_name_table[slot].device_name  = (char *)path;
+  device_name_table[slot].device_name_length = strlen(path);
+  device_name_table[slot].major = major;
+  device_name_table[slot].minor = minor;
+  device_name_table[slot].mode  = mode;
+  _ISR_Enable(level);
+
+  return 0;
+}
+
Index: cpukit/libfs/src/devfs/devfs_node_type.c
===================================================================
--- cpukit/libfs/src/devfs/devfs_node_type.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
+++ cpukit/libfs/src/devfs/devfs_node_type.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -0,0 +1,26 @@
+/*
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "devfs.h"
+
+int devFS_node_type(
+  rtems_filesystem_location_info_t  *pathloc
+)
+{
+  /*
+   * There is only one type of node: device 
+   */
+
+  return RTEMS_FILESYSTEM_DEVICE;
+}
+
+
Index: cpukit/libfs/src/devfs/devfs_show.c
===================================================================
--- cpukit/libfs/src/devfs/devfs_show.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
+++ cpukit/libfs/src/devfs/devfs_show.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -0,0 +1,35 @@
+/*
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "devfs.h"
+
+int devFS_Show(void)
+{
+  int                               i;
+  rtems_filesystem_location_info_t *temp_loc;
+  rtems_device_name_t              *device_name_table;
+
+  temp_loc = &rtems_filesystem_root;
+  device_name_table = (rtems_device_name_t *)temp_loc->node_access;
+  if (!device_name_table)
+    rtems_set_errno_and_return_minus_one( EFAULT );
+
+  for (i = 0; i < rtems_device_table_size; i++){
+    if (device_name_table[i].device_name){
+        printk("/%s %d %d\n", device_name_table[i].device_name, 
+            device_name_table[i].major, device_name_table[i].minor);
+    }
+  }
+  return 0;
+}
+
+
Index: cpukit/libfs/src/devfs/devioctl.c
===================================================================
--- cpukit/libfs/src/devfs/devioctl.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
+++ cpukit/libfs/src/devfs/devioctl.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -0,0 +1,45 @@
+#if HAVE_CONFIG_H
+/*
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#include "config.h"
+#endif
+
+#include <rtems.h>
+#include <rtems/io.h>
+
+#include "devfs.h"
+
+int devFS_ioctl(
+  rtems_libio_t *iop,
+  uint32_t       command,
+  void          *buffer
+)
+{
+  rtems_libio_ioctl_args_t  args;
+  rtems_status_code         status;
+  rtems_driver_name_t      *np;
+
+  np           = (rtems_device_name_t *)iop->file_info;
+
+  args.iop     = iop;
+  args.command = command;
+  args.buffer  = buffer;
+
+  status = rtems_io_control(
+    np->major,
+    np->minor,
+    (void *) &args
+  );
+
+  if ( status )
+    return rtems_deviceio_errno(status);
+
+  return args.ioctl_return;
+}
+
Index: cpukit/libfs/src/devfs/devopen.c
===================================================================
--- cpukit/libfs/src/devfs/devopen.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
+++ cpukit/libfs/src/devfs/devopen.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -0,0 +1,44 @@
+/*
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems.h>
+#include <rtems/io.h>
+
+#include "devfs.h"
+
+int devFS_open(
+  rtems_libio_t *iop,
+  const char    *pathname,
+  uint32_t       flag,
+  uint32_t       mode
+)
+{
+  rtems_libio_open_close_args_t  args;
+  rtems_status_code              status;
+  rtems_driver_name_t           *np;
+
+  np         = (rtems_device_name_t *)iop->file_info;
+
+  args.iop   = iop;
+  args.flags = iop->flags;
+  args.mode  = mode;
+
+  status = rtems_io_open(
+    np->major,
+    np->minor,
+    (void *) &args
+  );
+  if ( status )
+    return rtems_deviceio_errno(status);
+
+  return 0;
+}
Index: cpukit/libfs/src/devfs/devread.c
===================================================================
--- cpukit/libfs/src/devfs/devread.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
+++ cpukit/libfs/src/devfs/devread.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -0,0 +1,48 @@
+/*
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems.h>
+#include <rtems/io.h>
+
+#include "devfs.h"
+
+ssize_t devFS_read(
+  rtems_libio_t *iop,
+  void          *buffer,
+  size_t         count
+)
+{
+  rtems_libio_rw_args_t   args;
+  rtems_status_code       status;
+  rtems_driver_name_t     *np;
+
+  np               = (rtems_device_name_t *)iop->file_info;
+
+  args.iop         = iop;
+  args.offset      = iop->offset;
+  args.buffer      = buffer;
+  args.count       = count;
+  args.flags       = iop->flags;
+  args.bytes_moved = 0;
+
+  status = rtems_io_read(
+    np->major,
+    np->minor,
+    (void *) &args
+  );
+
+  if ( status )
+    return rtems_deviceio_errno(status);
+
+  return (ssize_t) args.bytes_moved;
+}
+
Index: cpukit/libfs/src/devfs/devstat.c
===================================================================
--- cpukit/libfs/src/devfs/devstat.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
+++ cpukit/libfs/src/devfs/devstat.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -0,0 +1,40 @@
+/*
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems.h>
+#include <rtems/io.h>
+#include <rtems/seterr.h>
+#include <rtems/libio.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+
+#include "devfs.h"
+
+int devFS_stat(
+  rtems_filesystem_location_info_t *loc,
+  struct stat                      *buf
+)
+{
+  rtems_device_name_t *the_dev;
+
+  the_dev = (rtems_device_name_t *)loc->node_access;
+  if (!the_dev)
+    rtems_set_errno_and_return_minus_one( EFAULT );
+
+  buf->st_dev  = rtems_filesystem_make_dev_t( the_dev->major, the_dev->minor );
+
+  buf->st_mode = the_dev->mode;
+
+  return 0;
+}
+
+
Index: cpukit/libfs/src/devfs/devwrite.c
===================================================================
--- cpukit/libfs/src/devfs/devwrite.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
+++ cpukit/libfs/src/devfs/devwrite.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -0,0 +1,48 @@
+/*
+ *  The license and distribution terms for this file may be
+ *  found in the file LICENSE in this distribution or at
+ *  http://www.rtems.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems.h>
+#include <rtems/io.h>
+
+#include "devfs.h"
+
+ssize_t devFS_write(
+  rtems_libio_t *iop,
+  const void    *buffer,
+  size_t         count
+)
+{
+  rtems_libio_rw_args_t   args;
+  rtems_status_code       status;
+  rtems_driver_name_t    *np;
+
+  np           = (rtems_device_name_t *)iop->file_info;
+
+  args.iop         = iop;
+  args.offset      = iop->offset;
+  args.buffer      = (void *) buffer;
+  args.count       = count;
+  args.flags       = iop->flags;
+  args.bytes_moved = 0;
+
+  status = rtems_io_write(
+    np->major,
+    np->minor,
+    (void *) &args
+  );
+
+  if ( status )
+    return rtems_deviceio_errno(status);
+
+  return (ssize_t) args.bytes_moved;
+}
+
Index: cpukit/libfs/src/imfs/deviceerrno.c
===================================================================
--- cpukit/libfs/src/imfs/deviceerrno.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
+++ cpukit/libfs/src/imfs/deviceerrno.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -0,0 +1,57 @@
+/*
+ *  IMFS Device Node Handlers
+ *
+ *  This file contains the set of handlers used to map operations on
+ *  IMFS device nodes onto calls to the RTEMS Classic API IO Manager.
+ *
+ *  COPYRIGHT (c) 1989-2008.
+ *  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.com/license/LICENSE.
+ *
+ *  $Id$
+ */
+
+#if HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <rtems.h>
+#include <rtems/libio.h>
+#include <rtems/assoc.h>                /* assoc.h not included by rtems.h */
+#include <errno.h>
+
+/*
+ * Convert RTEMS status to a UNIX errno
+ */
+
+const rtems_assoc_t errno_assoc[] = {
+    { "OK",                 RTEMS_SUCCESSFUL,                0 },
+    { "BUSY",               RTEMS_RESOURCE_IN_USE,           EBUSY },
+    { "INVALID NAME",       RTEMS_INVALID_NAME,              EINVAL },
+    { "NOT IMPLEMENTED",    RTEMS_NOT_IMPLEMENTED,           ENOSYS },
+    { "TIMEOUT",            RTEMS_TIMEOUT,                   ETIMEDOUT },
+    { "NO MEMORY",          RTEMS_NO_MEMORY,                 ENOMEM },
+    { "NO DEVICE",          RTEMS_UNSATISFIED,               ENODEV },
+    { "INVALID NUMBER",     RTEMS_INVALID_NUMBER,            EBADF},
+    { "NOT RESOURCE OWNER", RTEMS_NOT_OWNER_OF_RESOURCE,     EPERM},
+    { "IO ERROR",           RTEMS_IO_ERROR,                  EIO},
+    { 0, 0, 0 },
+};
+
+int
+rtems_deviceio_errno(rtems_status_code code)
+{
+    int rc;
+
+    if ((rc = rtems_assoc_remote_by_local(errno_assoc, (uint32_t  ) code)))
+    {
+        errno = rc;
+        return -1;
+    }
+    return -1;
+}
+
+
Index: cpukit/libfs/src/imfs/deviceio.c
===================================================================
--- cpukit/libfs/src/imfs/deviceio.c	(revision e8fcadbc490beb95478b7d6a9b37e29c749bf9a7)
+++ cpukit/libfs/src/imfs/deviceio.c	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -5,5 +5,5 @@
  *  IMFS device nodes onto calls to the RTEMS Classic API IO Manager.
  *
- *  COPYRIGHT (c) 1989-1999.
+ *  COPYRIGHT (c) 1989-2008.
  *  On-Line Applications Research Corporation (OAR).
  *
Index: cpukit/preinstall.am
===================================================================
--- cpukit/preinstall.am	(revision e8fcadbc490beb95478b7d6a9b37e29c749bf9a7)
+++ cpukit/preinstall.am	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -147,4 +147,8 @@
 PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/imfs.h
 
+$(PROJECT_INCLUDE)/rtems/devfs.h: libfs/src/devfs/devfs.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
+	$(INSTALL_DATA) $< $(PROJECT_INCLUDE)/rtems/devfs.h
+PREINSTALL_FILES += $(PROJECT_INCLUDE)/rtems/devfs.h
+
 if LIBDOSFS
 $(PROJECT_INCLUDE)/rtems/dosfs.h: libfs/src/dosfs/dosfs.h $(PROJECT_INCLUDE)/rtems/$(dirstamp)
Index: cpukit/sapi/include/confdefs.h
===================================================================
--- cpukit/sapi/include/confdefs.h	(revision e8fcadbc490beb95478b7d6a9b37e29c749bf9a7)
+++ cpukit/sapi/include/confdefs.h	(revision d40da79b04ee4756675c3356cfc156fb7d9bd547)
@@ -73,4 +73,35 @@
 #endif
 
+
+#include <rtems/libio.h>
+
+#ifdef CONFIGURE_INIT
+rtems_libio_init_functions_t rtems_libio_init_helper = 
+    #ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
+    NULL;
+    #else
+    rtems_libio_init;
+    #endif
+
+rtems_libio_supp_functions_t rtems_libio_supp_helper = 
+    #ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
+    NULL;
+    #else
+    open_dev_console;
+    #endif
+
+rtems_fs_init_functions_t    rtems_fs_init_helper = 
+    #ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
+    NULL;
+    #else
+    rtems_filesystem_initialize;
+    #endif
+#endif
+
+
+#ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
+  #define CONFIGURE_HAS_OWN_MOUNT_TABLE
+#endif
+
 /**
  *  This macro defines the number of POSIX file descriptors allocated 
@@ -139,4 +170,20 @@
 #endif
 
+#ifdef CONFIGURE_INIT
+  #ifdef CONFIGURE_APPLICATION_DISABLE_FILESYSTEM
+    extern uint32_t rtems_device_table_size;
+    #define CONFIGURE_MEMORY_FOR_DEVFS  0
+  #elif defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM)
+    #ifndef CONFIGURE_MAXIMUM_DEVICES
+      #define CONFIGURE_MAXIMUM_DEVICES 4
+    #endif
+    #include <rtems/devfs.h>
+    uint32_t rtems_device_table_size = CONFIGURE_MAXIMUM_DEVICES;
+    #define CONFIGURE_MEMORY_FOR_DEVFS _Configure_Object_RAM(CONFIGURE_MAXIMUM_DEVICES, sizeof (rtems_device_name_t))
+  #else
+    #define CONFIGURE_MEMORY_FOR_DEVFS  0
+  #endif
+#endif
+
 /*
  *  Mount Table Configuration
@@ -163,4 +210,6 @@
       #ifdef CONFIGURE_USE_IMFS_AS_BASE_FILESYSTEM
         &IMFS_ops,
+      #elif defined(CONFIGURE_USE_DEVFS_AS_BASE_FILESYSTEM)
+        &devFS_ops,
       #else  /* using miniIMFS as base filesystem */
         &miniIMFS_ops,
@@ -575,14 +624,4 @@
 #endif
 
-/**
- *  Default the number of devices per device driver.  This value may be
- *  overridden by the user.
- *
- *  @note This configuration parameter is obsolete. Thus we will warn the
- *        user that it is obsolete.
- */
-#ifdef CONFIGURE_MAXIMUM_DEVICES
-  #warning "CONFIGURE_MAXIMUM_DEVICES is obsolete.  Do not use any longer."
-#endif
 
 #ifdef CONFIGURE_APPLICATION_NEEDS_ATA_DRIVER
@@ -1682,4 +1721,5 @@
 (( \
    CONFIGURE_MEMORY_FOR_SYSTEM_OVERHEAD + \
+   CONFIGURE_MEMORY_FOR_DEVFS + \
    CONFIGURE_MEMORY_FOR_TASKS( \
      CONFIGURE_TOTAL_TASKS_AND_THREADS, CONFIGURE_TOTAL_TASKS_AND_THREADS) + \
