Index: cpukit/ChangeLog
===================================================================
--- cpukit/ChangeLog	(revision ecfeb16b4236002fbc95092d02f2efefb11b6a46)
+++ cpukit/ChangeLog	(revision 597624691b9611fc67b0f38b9257cea23287c6c2)
@@ -1,2 +1,13 @@
+2011-03-15	Chris Johns <chrisj@rtems.org>
+
+	* libfs/src/rfs/rtems-rfs-rtems-file.c,
+	libfs/src/rfs/rtems-rfs-rtems.c, libfs/src/rfs/rtems-rfs-rtems.h:
+	The fix to the removal of file_info from iop was broken. The
+	node_access field must be the inode number in the RFS because the
+	file system ops provides no way to tell is a stat call is the
+	result of stat, fstat, or lstat. The solution is to move the file
+	handle to node_access_2 which is also shared with doff but these
+	do not overlap.
+	
 2011-03-15	Chris Johns <chrisj@rtems.org>
 
Index: cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c
===================================================================
--- cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c	(revision ecfeb16b4236002fbc95092d02f2efefb11b6a46)
+++ cpukit/libfs/src/rfs/rtems-rfs-rtems-file.c	(revision 597624691b9611fc67b0f38b9257cea23287c6c2)
@@ -72,5 +72,5 @@
   
   iop->size = rtems_rfs_file_size (file);
-  iop->pathinfo.node_access = file;
+  rtems_rfs_rtems_set_iop_file_handle (iop, file);
   
   rtems_rfs_rtems_unlock (fs);
@@ -88,5 +88,5 @@
 rtems_rfs_rtems_file_close (rtems_libio_t* iop)
 {
-  rtems_rfs_file_handle* file = iop->pathinfo.node_access;
+  rtems_rfs_file_handle* file = rtems_rfs_rtems_get_iop_file_handle (iop);
   rtems_rfs_file_system* fs = rtems_rfs_file_fs (file);
   int                    rc;
@@ -118,5 +118,5 @@
                            size_t         count)
 {
-  rtems_rfs_file_handle* file = iop->pathinfo.node_access;
+  rtems_rfs_file_handle* file = rtems_rfs_rtems_get_iop_file_handle (iop);
   rtems_rfs_pos          pos;
   uint8_t*               data = buffer;
@@ -183,5 +183,5 @@
                             size_t         count)
 {
-  rtems_rfs_file_handle* file = iop->pathinfo.node_access;
+  rtems_rfs_file_handle* file = rtems_rfs_rtems_get_iop_file_handle (iop);
   rtems_rfs_pos          pos;
   const uint8_t*         data = buffer;
@@ -280,5 +280,5 @@
                             int            whence)
 {
-  rtems_rfs_file_handle* file = iop->pathinfo.node_access;
+  rtems_rfs_file_handle* file = rtems_rfs_rtems_get_iop_file_handle (iop);
   rtems_rfs_pos          pos;
   int                    rc;
@@ -301,60 +301,4 @@
   
   return iop->offset;
-}
-
-/**
- * Stat the file.
- *
- * @param iop
- * @param buf
- * @return int
- */
-static int
-rtems_rfs_rtems_file_fstat (rtems_filesystem_location_info_t* pathloc,
-                            struct stat*                      buf)
-{
-  rtems_rfs_file_handle* file = pathloc->node_access;
-  int                    rc;
-
-  if (rtems_rfs_rtems_trace (RTEMS_RFS_RTEMS_DEBUG_STAT))
-    printf ("rtems-rfs: file-fstat: handle:%p\n", file);
-
-  rtems_rfs_rtems_lock (rtems_rfs_file_fs (file));
-
-  rc = rtems_rfs_rtems_stat_inode (rtems_rfs_file_fs (file),
-                                   rtems_rfs_file_inode (file),
-                                   buf);
-
-  rtems_rfs_rtems_unlock (rtems_rfs_file_fs (file));
-
-  return rc;
-}
-
-/**
- * File change mode routine.
- *
- * @param iop
- * @param mode
- * @return int
- */
-static int
-rtems_rfs_rtems_file_fchmod (rtems_filesystem_location_info_t* pathloc,
-                             mode_t                            mode)
-{
-  rtems_rfs_file_handle* file = pathloc->node_access;
-  int                    rc;
-
-  if (rtems_rfs_rtems_trace (RTEMS_RFS_RTEMS_DEBUG_FCHMOD))
-    printf ("rtems-rfs: file-fchmod: handle:%p\n", file);
-
-  rtems_rfs_rtems_lock (rtems_rfs_file_fs (file));
-
-  rc = rtems_rfs_rtems_fchmod_inode (rtems_rfs_file_fs (file),
-                                     rtems_rfs_file_inode (file),
-                                     mode);
-
-  rtems_rfs_rtems_unlock (rtems_rfs_file_fs (file));
-
-  return rc;
 }
 
@@ -370,5 +314,5 @@
                                 rtems_off64_t  length)
 {
-  rtems_rfs_file_handle* file = iop->pathinfo.node_access;
+  rtems_rfs_file_handle* file = rtems_rfs_rtems_get_iop_file_handle (iop);
   int                    rc;
 
@@ -400,6 +344,6 @@
   .ioctl_h     = rtems_rfs_rtems_file_ioctl,
   .lseek_h     = rtems_rfs_rtems_file_lseek,
-  .fstat_h     = rtems_rfs_rtems_file_fstat,
-  .fchmod_h    = rtems_rfs_rtems_file_fchmod,
+  .fstat_h     = rtems_rfs_rtems_fstat,
+  .fchmod_h    = rtems_rfs_rtems_fchmod,
   .ftruncate_h = rtems_rfs_rtems_file_ftruncate,
   .fpathconf_h = rtems_filesystem_default_fpathconf,
Index: cpukit/libfs/src/rfs/rtems-rfs-rtems.c
===================================================================
--- cpukit/libfs/src/rfs/rtems-rfs-rtems.c	(revision ecfeb16b4236002fbc95092d02f2efefb11b6a46)
+++ cpukit/libfs/src/rfs/rtems-rfs-rtems.c	(revision 597624691b9611fc67b0f38b9257cea23287c6c2)
@@ -794,18 +794,30 @@
 
 int
-rtems_rfs_rtems_fchmod_inode (rtems_rfs_file_system*  fs,
-                              rtems_rfs_inode_handle* inode,
-                              mode_t                  mode)
-{
-  uint16_t imode;
+rtems_rfs_rtems_fchmod (rtems_filesystem_location_info_t* pathloc,
+                        mode_t                            mode)
+{
+  rtems_rfs_file_system*  fs = rtems_rfs_rtems_pathloc_dev (pathloc);
+  rtems_rfs_ino           ino = rtems_rfs_rtems_get_pathloc_ino (pathloc);
+  rtems_rfs_inode_handle  inode;
+  uint16_t                imode;
 #if defined (RTEMS_POSIX_API)
-  uid_t     uid;
+  uid_t                   uid;
 #endif
+  int                     rc;
 
   if (rtems_rfs_rtems_trace (RTEMS_RFS_RTEMS_DEBUG_FCHMOD))
-    printf ("rtems-rfs-rtems: fchmod indo: in: ino:%" PRId32 " mode:%06" PRIomode_t "\n",
-            rtems_rfs_inode_ino (inode), mode);
-  
-  imode = rtems_rfs_inode_get_mode (inode);
+    printf ("rtems-rfs-rtems: fchmod: in: ino:%" PRId32 " mode:%06" PRIomode_t "\n",
+            ino, mode);
+  
+  rtems_rfs_rtems_lock (fs);
+  
+  rc = rtems_rfs_inode_open (fs, ino, &inode, true);
+  if (rc)
+  {
+    rtems_rfs_rtems_unlock (fs);
+    return rtems_rfs_rtems_error ("fchmod: opening inode", rc);
+  }
+
+  imode = rtems_rfs_inode_get_mode (&inode);
   
   /*
@@ -815,6 +827,10 @@
   uid = geteuid();
 
-  if ((uid != rtems_rfs_inode_get_uid (inode)) && (uid != 0))
-    return EPERM;
+  if ((uid != rtems_rfs_inode_get_uid (&inode)) && (uid != 0))
+  {
+    rtems_rfs_inode_close (fs, &inode);
+    rtems_rfs_rtems_unlock (fs);
+    return rtems_rfs_rtems_error ("fchmod: checking uid", EPERM);
+  }
 #endif
 
@@ -822,38 +838,5 @@
   imode |= mode & (S_IRWXU | S_IRWXG | S_IRWXO | S_ISUID | S_ISGID | S_ISVTX);
 
-  rtems_rfs_inode_set_mode (inode, imode);
-  
-  return 0;
-}
-
-int
-rtems_rfs_rtems_fchmod (rtems_filesystem_location_info_t* pathloc,
-                        mode_t                            mode)
-{
-  rtems_rfs_file_system*  fs = rtems_rfs_rtems_pathloc_dev (pathloc);
-  rtems_rfs_ino           ino = rtems_rfs_rtems_get_pathloc_ino (pathloc);
-  rtems_rfs_inode_handle  inode;
-  int                     rc;
-
-  if (rtems_rfs_rtems_trace (RTEMS_RFS_RTEMS_DEBUG_FCHMOD))
-    printf ("rtems-rfs-rtems: fchmod: in: ino:%" PRId32 " mode:%06" PRIomode_t "\n",
-            ino, mode);
-  
-  rtems_rfs_rtems_lock (fs);
-  
-  rc = rtems_rfs_inode_open (fs, ino, &inode, true);
-  if (rc)
-  {
-    rtems_rfs_rtems_unlock (fs);
-    return rtems_rfs_rtems_error ("fchmod: opening inode", rc);
-  }
-
-  rc = rtems_rfs_rtems_fchmod_inode (fs, &inode, mode);
-  if (rc > 0)
-  {
-    rtems_rfs_inode_close (fs, &inode);
-    rtems_rfs_rtems_unlock (fs);
-    return rtems_rfs_rtems_error ("fchmod: fchmod inode", EPERM);
-  }
+  rtems_rfs_inode_set_mode (&inode, imode);
   
   rc = rtems_rfs_inode_close (fs, &inode);
@@ -870,30 +853,41 @@
 
 int
-rtems_rfs_rtems_stat_inode (rtems_rfs_file_system*  fs,
-                            rtems_rfs_inode_handle* inode,
-                            struct stat*            buf)
-{
+rtems_rfs_rtems_fstat (rtems_filesystem_location_info_t* pathloc,
+                       struct stat*                      buf)
+{
+  rtems_rfs_file_system* fs = rtems_rfs_rtems_pathloc_dev (pathloc);
+  rtems_rfs_ino          ino = rtems_rfs_rtems_get_pathloc_ino (pathloc);
+  rtems_rfs_inode_handle inode;
   rtems_rfs_file_shared* shared;
   uint16_t               mode;
+  int                    rc;
 
   if (rtems_rfs_rtems_trace (RTEMS_RFS_RTEMS_DEBUG_STAT))
-    printf ("rtems-rfs-rtems: stat-inode: in: ino:%" PRId32 "\n",
-            rtems_rfs_inode_ino (inode));
-
-  mode = rtems_rfs_inode_get_mode (inode);
+    printf ("rtems-rfs-rtems: stat: in: ino:%" PRId32 "\n", ino);
+
+  rtems_rfs_rtems_lock (fs);
+  
+  rc = rtems_rfs_inode_open (fs, ino, &inode, true);
+  if (rc)
+  {
+    rtems_rfs_rtems_unlock (fs);
+    return rtems_rfs_rtems_error ("stat: opening inode", rc);
+  }
+
+  mode = rtems_rfs_inode_get_mode (&inode);
   
   if (RTEMS_RFS_S_ISCHR (mode) || RTEMS_RFS_S_ISBLK (mode))
   {
     buf->st_rdev = 
-      rtems_filesystem_make_dev_t (rtems_rfs_inode_get_block (inode, 0),
-                                   rtems_rfs_inode_get_block (inode, 1));
+      rtems_filesystem_make_dev_t (rtems_rfs_inode_get_block (&inode, 0),
+                                   rtems_rfs_inode_get_block (&inode, 1));
   }
   
   buf->st_dev     = rtems_rfs_fs_device (fs);
-  buf->st_ino     = rtems_rfs_inode_ino (inode);
+  buf->st_ino     = rtems_rfs_inode_ino (&inode);
   buf->st_mode    = rtems_rfs_rtems_mode (mode);
-  buf->st_nlink   = rtems_rfs_inode_get_links (inode);
-  buf->st_uid     = rtems_rfs_inode_get_uid (inode);
-  buf->st_gid     = rtems_rfs_inode_get_gid (inode);
+  buf->st_nlink   = rtems_rfs_inode_get_links (&inode);
+  buf->st_uid     = rtems_rfs_inode_get_uid (&inode);
+  buf->st_gid     = rtems_rfs_inode_get_gid (&inode);
 
   /*
@@ -901,5 +895,5 @@
    * the open file rather than the inode.
    */
-  shared = rtems_rfs_file_get_shared (fs, rtems_rfs_inode_ino (inode));
+  shared = rtems_rfs_file_get_shared (fs, rtems_rfs_inode_ino (&inode));
 
   if (shared)
@@ -917,48 +911,17 @@
   else
   {
-    buf->st_atime   = rtems_rfs_inode_get_atime (inode);
-    buf->st_mtime   = rtems_rfs_inode_get_mtime (inode);
-    buf->st_ctime   = rtems_rfs_inode_get_ctime (inode);
-    buf->st_blocks  = rtems_rfs_inode_get_block_count (inode);
+    buf->st_atime   = rtems_rfs_inode_get_atime (&inode);
+    buf->st_mtime   = rtems_rfs_inode_get_mtime (&inode);
+    buf->st_ctime   = rtems_rfs_inode_get_ctime (&inode);
+    buf->st_blocks  = rtems_rfs_inode_get_block_count (&inode);
 
     if (S_ISLNK (buf->st_mode))
-      buf->st_size = rtems_rfs_inode_get_block_offset (inode);
+      buf->st_size = rtems_rfs_inode_get_block_offset (&inode);
     else
-      buf->st_size = rtems_rfs_inode_get_size (fs, inode);
+      buf->st_size = rtems_rfs_inode_get_size (fs, &inode);
   }
   
   buf->st_blksize = rtems_rfs_fs_block_size (fs);
   
-  return 0;
-}
-
-int
-rtems_rfs_rtems_fstat (rtems_filesystem_location_info_t* pathloc,
-                       struct stat*                      buf)
-{
-  rtems_rfs_file_system* fs = rtems_rfs_rtems_pathloc_dev (pathloc);
-  rtems_rfs_ino          ino = rtems_rfs_rtems_get_pathloc_ino (pathloc);
-  rtems_rfs_inode_handle inode;
-  int                    rc;
-
-  if (rtems_rfs_rtems_trace (RTEMS_RFS_RTEMS_DEBUG_STAT))
-    printf ("rtems-rfs-rtems: stat: in: ino:%" PRId32 "\n", ino);
-
-  rtems_rfs_rtems_lock (fs);
-  
-  rc = rtems_rfs_inode_open (fs, ino, &inode, true);
-  if (rc)
-  {
-    rtems_rfs_rtems_unlock (fs);
-    return rtems_rfs_rtems_error ("stat: opening inode", rc);
-  }
-
-  rc = rtems_rfs_rtems_stat_inode (fs, &inode, buf);
-  if (rc > 0)
-  {
-    rtems_rfs_rtems_unlock (fs);
-    return rtems_rfs_rtems_error ("stat: stat'ing the inode", rc);
-  }
-
   rc = rtems_rfs_inode_close (fs, &inode);
   if (rc > 0)
Index: cpukit/libfs/src/rfs/rtems-rfs-rtems.h
===================================================================
--- cpukit/libfs/src/rfs/rtems-rfs-rtems.h	(revision ecfeb16b4236002fbc95092d02f2efefb11b6a46)
+++ cpukit/libfs/src/rfs/rtems-rfs-rtems.h	(revision 597624691b9611fc67b0f38b9257cea23287c6c2)
@@ -192,8 +192,26 @@
  *
  * @param _iop The I/O pointer.
- * @return
+ * @return ino
  */
 #define rtems_rfs_rtems_get_iop_ino(_iop) \
   ((intptr_t)(_iop)->pathinfo.node_access)
+
+/**
+ * Get the file handle from the I/O pointer.
+ *
+ * @param _iop The I/O pointer.
+ * @return filehandle The file handle
+ */
+#define rtems_rfs_rtems_get_iop_file_handle(_iop) \
+  ((rtems_rfs_file_handle*)(_iop)->pathinfo.node_access_2)
+
+/**
+ * Set the file handle in the I/O pointer.
+ *
+ * @param _iop The I/O pointer.
+ * @param _fh The file handle.
+ */
+#define rtems_rfs_rtems_set_iop_file_handle(_iop, _fh) \
+  (_iop)->pathinfo.node_access_2 = (_fh)
 
 /**
@@ -275,16 +293,4 @@
  * The following routine does a stat on a node.
  *
- * @param fs The file system data.
- * @param inode The inode to stat held in memory.
- * @param buf The stat buffer to fill.
- * @return int The result code.
- */
-int rtems_rfs_rtems_stat_inode (rtems_rfs_file_system*  fs,
-                                rtems_rfs_inode_handle* inode,
-                                struct stat*            buf);
-
-/**
- * The following routine does a stat on a node.
- *
  * @param iop
  * @param buf
@@ -295,16 +301,4 @@
 
 /**
- * File change mode routine changes an inode.
- *
- * @param fs The file system data.
- * @param inode The inode to change held in memory.
- * @param buf The new mode.
- * @return int The result code.
- */
-int rtems_rfs_rtems_fchmod_inode (rtems_rfs_file_system*  fs,
-                                  rtems_rfs_inode_handle* inode,
-                                  mode_t                  mode);
-
-/**
  * File change mode routine.
  *
