<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>change log for rtems (2011-05-10)</title>
</head>
<body text='#000000' bgcolor='#ffffff'>
<a name='cs1'></a>
<table border='0' cellspacing='0' cellpadding='5' width='100%' bgcolor='#eeeeee'>
<tr><td colspan='3' bgcolor='#dddddd'>
 <font color='#bb2222'><strong>ccj</strong></font>
</td></tr>
<tr><td colspan='3' bgcolor='#dddddd'><pre>2011-05-11      Chris Johns <chrisj@rtems.org>

        PR 1774/filesystem
        * libfs/src/imfs/imfs_eval.c: Updated to fix regressions found in
        the testsuite.
</pre></td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/ChangeLog.diff?r1=text&tr1=1.2807&r2=text&tr2=1.2808&diff_format=h">M</a></td><td width='1%'>1.2808</td><td width='100%'>cpukit/ChangeLog</td></tr>
<tr><td width='1%'><a href="http://www.rtems.com/cgi-bin/viewcvs.cgi//rtems/cpukit/libfs/src/imfs/imfs_eval.c.diff?r1=text&tr1=1.32&r2=text&tr2=1.33&diff_format=h">M</a></td><td width='1%'>1.33</td><td width='100%'>cpukit/libfs/src/imfs/imfs_eval.c</td></tr>
</table>
<pre>
<font color='#006600'>diff -u rtems/cpukit/ChangeLog:1.2807 rtems/cpukit/ChangeLog:1.2808
--- rtems/cpukit/ChangeLog:1.2807       Thu May  5 07:30:36 2011
+++ rtems/cpukit/ChangeLog      Tue May 10 22:01:54 2011
</font><font color='#997700'>@@ -1,3 +1,9 @@
</font><font color='#000088'>+2011-05-11    Chris Johns <chrisj@rtems.org>
+
+       PR 1774/filesystem
+       * libfs/src/imfs/imfs_eval.c: Updated to fix regressions found in
+       the testsuite.
+
</font> 2011-05-05        Ralf Corsépius <ralf.corsepius@rtems.org>
 
        * librpc/include/rpc/auth.h, librpc/include/rpc/auth_unix.h,
<font color='#997700'>@@ -48,7 +54,7 @@
</font> 2011-04-16        Chris Johns <chrisj@rtems.org>
 
        PR 1774/filesystem
<font color='#880000'>-   * libfs/src/imfs/imfs_eval.c: Fix the IMFS eval and eval for make
</font><font color='#000088'>+      * libfs/src/imfs/imfs_eval.c: Fix the IMFS eval anda eval for make
</font>   handlers to not inspect a mounted file sytems path.
 
 2011-04-15     Sebastian Huber <sebastian.huber@embedded-brains.de>

<font color='#006600'>diff -u rtems/cpukit/libfs/src/imfs/imfs_eval.c:1.32 rtems/cpukit/libfs/src/imfs/imfs_eval.c:1.33
--- rtems/cpukit/libfs/src/imfs/imfs_eval.c:1.32        Fri Apr 15 23:40:11 2011
+++ rtems/cpukit/libfs/src/imfs/imfs_eval.c     Tue May 10 22:01:54 2011
</font><font color='#997700'>@@ -256,6 +256,22 @@
</font>   return result;
 }
 
<font color='#000088'>+/*
+ * IMFS_skip_separator
+ *
+ * Skip the separator in the path.
+ */
+static void IMFS_skip_separator (
+   const char *path,       /* IN     */
+   size_t     *len,        /* IN/OUT */
+   int        *index       /* IN/OUT */
+)
+{
+  while ( IMFS_is_separator( path[*index] ) && path[*index] && *len ) {
+    ++(*index);
+    --(*len);
+  }
+}
</font> 
 /*
  *  IMFS_evaluate_for_make
<font color='#997700'>@@ -267,20 +283,19 @@
</font>  */
 
 int IMFS_evaluate_for_make(
<font color='#880000'>-   const char                         *path,       /* IN     */
-   rtems_filesystem_location_info_t   *pathloc,    /* IN/OUT */
-   const char                        **name        /* OUT    */
-)
</font><font color='#000088'>+  const char                         *path,       /* IN     */
+  rtems_filesystem_location_info_t   *pathloc,    /* IN/OUT */
+  const char                        **name        /* OUT    */
+                           )
</font> {
<font color='#880000'>-  int                                 i = 0;
-  int                                 len;
-  IMFS_token_types                    type;
-  char                                token[ IMFS_NAME_MAX + 1 ];
-  rtems_filesystem_location_info_t    newloc;
-  IMFS_jnode_t                       *node;
-  bool                                done = false;
-  int                                 pathlen;
-  int                                 result;
</font><font color='#000088'>+  int               i = 0;
+  int               len;
+  IMFS_token_types  type;
+  char              token[ IMFS_NAME_MAX + 1 ];
+  IMFS_jnode_t     *node;
+  bool              done = false;
+  size_t            pathlen;
+  int               result;
</font> 
   /*
    * This was filled in by the caller and is valid in the
<font color='#997700'>@@ -292,7 +307,6 @@
</font>    * Get the path length.
    */
   pathlen = strlen( path );
<font color='#880000'>-
</font>   /*
    *  Evaluate all tokens until we are done or an error occurs.
    */
<font color='#997700'>@@ -313,27 +327,26 @@
</font>     if ( type != IMFS_NO_MORE_PATH )
       if ( node->type == IMFS_DIRECTORY )
         if ( !IMFS_evaluate_permission( pathloc, RTEMS_LIBIO_PERMS_SEARCH ) )
<font color='#880000'>-           rtems_set_errno_and_return_minus_one( EACCES );
</font><font color='#000088'>+          rtems_set_errno_and_return_minus_one( EACCES );
</font> 
     node = pathloc->node_access;
 
     switch( type ) {
 
       case IMFS_UP_DIR:
<font color='#880000'>-       /*
-        *  Am I at the root of all filesystems? (chroot'ed?)
-        */
</font><font color='#000088'>+        /*
+         *  Am I at the root of all filesystems? (chroot'ed?)
+         */
</font> 
<font color='#880000'>-       if ( pathloc->node_access == rtems_filesystem_root.node_access )
-         break;       /* Throw out the .. in this case */
</font><font color='#000088'>+        if ( pathloc->node_access == rtems_filesystem_root.node_access )
+          break;       /* Throw out the .. in this case */
</font> 
 
<font color='#880000'>-       /*
-        * Am I at the root of this mounted filesystem?
-        */
</font><font color='#000088'>+        /*
+         * Am I at the root of this mounted filesystem?
+         */
</font> 
<font color='#880000'>-        if (pathloc->node_access ==
-            pathloc->mt_entry->mt_fs_root.node_access){
</font><font color='#000088'>+        if (pathloc->node_access == pathloc->mt_entry->mt_fs_root.node_access){
</font> 
           /*
            *  Am I at the root of all filesystems?
<font color='#997700'>@@ -341,12 +354,13 @@
</font> 
           if ( pathloc->node_access == rtems_filesystem_root.node_access ) {
             break;
<font color='#000088'>+
</font>           } else {
<font color='#880000'>-            newloc = pathloc->mt_entry->mt_point_node;
-            *pathloc = newloc;
-            return (*pathloc->ops->evalformake_h)( &path[i], pathloc, name );
</font><font color='#000088'>+            *pathloc = pathloc->mt_entry->mt_point_node;
+            return (*pathloc->ops->evalformake_h)( &path[i-len], pathloc, name );
</font>           }
         } else {
<font color='#000088'>+
</font>           if ( !node->Parent )
             rtems_set_errno_and_return_minus_one( ENOENT );
 
<font color='#997700'>@@ -357,9 +371,6 @@
</font>         break;
 
       case IMFS_NAME:
<font color='#880000'>-        /*
-         *  If we are at a link follow it.
-         */
</font> 
         if ( node->type == IMFS_HARD_LINK ) {
 
<font color='#997700'>@@ -387,7 +398,7 @@
</font>           rtems_set_errno_and_return_minus_one( ENOTDIR );
 
         /*
<font color='#880000'>-         * Otherwise find the token name in the present location.
</font><font color='#000088'>+         * Find the token name in the present location.
</font>          */
 
         node = IMFS_find_match_in_dir( node, token );
<font color='#997700'>@@ -400,17 +411,18 @@
</font>         if ( ! node )
           done = true;
         else {
<font color='#880000'>-          /*
-           * If we are at a node that is a mount point. Set loc to the
-           * new fs root node and let them finish evaluating the path.
-           */
-
-          if ( node->info.directory.mt_fs != NULL ) {
-            newloc  = node->info.directory.mt_fs->mt_fs_root;
-            *pathloc = newloc;
-            return (*pathloc->ops->evalformake_h)( &path[i], pathloc, name );
</font><font color='#000088'>+        if (( node->type == IMFS_DIRECTORY ) && ( node->info.directory.mt_fs != NULL )) {
+            IMFS_skip_separator( path, &pathlen, &i);
+            if ((path[i] != '.') || (path[i + 1] != '.')) {
+              *pathloc = node->info.directory.mt_fs->mt_fs_root;
+              return (*pathloc->ops->evalformake_h)( &path[i],
+                                                     pathloc,
+                                                     name );
+            }
+            i += 2;
+            pathlen -= 2;
+            node = node->Parent;
</font>           }
<font color='#880000'>-<span style="background-color: #FF0000">          </span>
</font>           pathloc->node_access = node;
         }
         break;
<font color='#997700'>@@ -463,7 +475,6 @@
</font>   return result;
 }
 
<font color='#880000'>-
</font> /*
  *  IMFS_eval_path
  *
<font color='#997700'>@@ -479,13 +490,12 @@
</font>   rtems_filesystem_location_info_t  *pathloc       /* IN/OUT */
                    )
 {
<font color='#880000'>-  int                                 i = 0;
-  int                                 len;
-  IMFS_token_types                    type = IMFS_CURRENT_DIR;
-  char                                token[ IMFS_NAME_MAX + 1 ];
-  rtems_filesystem_location_info_t    newloc;
-  IMFS_jnode_t                       *node;
-  int                                 result;
</font><font color='#000088'>+  int               i = 0;
+  int               len;
+  IMFS_token_types  type = IMFS_CURRENT_DIR;
+  char              token[ IMFS_NAME_MAX + 1 ];
+  IMFS_jnode_t     *node;
+  int               result;
</font> 
   if ( !rtems_libio_is_valid_perms( flags ) ) {
     rtems_set_errno_and_return_minus_one( EIO );
<font color='#997700'>@@ -544,17 +554,19 @@
</font>           if ( pathloc->node_access == rtems_filesystem_root.node_access ) {
             break;       /* Throw out the .. in this case */
           } else {
<font color='#880000'>-            newloc = pathloc->mt_entry->mt_point_node;
-            *pathloc = newloc;
-            return (*pathloc->ops->evalpath_h)(&(pathname[i]),
-                                               pathnamelen,
</font><font color='#000088'>+            *pathloc = pathloc->mt_entry->mt_point_node;
+            return (*pathloc->ops->evalpath_h)(&(pathname[i-len]),
+                                               pathnamelen+len,
</font>                                                flags,pathloc);
           }
         } else {
<font color='#000088'>+
</font>           if ( !node->Parent )
             rtems_set_errno_and_return_minus_one( ENOENT );
 
           node = node->Parent;
<font color='#000088'>+          pathloc->node_access = node;
+
</font>         }
 
         pathloc->node_access = node;
<font color='#997700'>@@ -564,17 +576,17 @@
</font>         /*
          *  If we are at a link follow it.
          */
<font color='#880000'>-
</font>         if ( node->type == IMFS_HARD_LINK ) {
<font color='#880000'>-
</font>           IMFS_evaluate_hard_link( pathloc, 0 );
<font color='#880000'>-
</font>           node = pathloc->node_access;
<font color='#880000'>-          if ( !node )
-            rtems_set_errno_and_return_minus_one( ENOTDIR );
</font><font color='#000088'>+<span style="background-color: #FF0000">       </span>
+          /*
+           * It would be a design error if we evaluated the link and
+           * was broken.
+           */
+          IMFS_assert( node );
</font> 
         } else if ( node->type == IMFS_SYM_LINK ) {
<font color='#880000'>-
</font>           result = IMFS_evaluate_sym_link( pathloc, 0 );
 
           /*
<font color='#997700'>@@ -589,37 +601,47 @@
</font>         /*
          *  Only a directory can be decended into.
          */
<font color='#880000'>-
</font>         if ( node->type != IMFS_DIRECTORY )
           rtems_set_errno_and_return_minus_one( ENOTDIR );
 
         /*
<font color='#880000'>-         *  Otherwise find the token name in the present location.
</font><font color='#000088'>+         *  Find the token name in the current node.
</font>          */
<font color='#880000'>-
</font>         node = IMFS_find_match_in_dir( node, token );
<font color='#880000'>-
</font>         if ( !node )
           rtems_set_errno_and_return_minus_one( ENOENT );
 
         /*
<font color='#880000'>-         *  Set the node access to the point we have found.
-         */
</font><font color='#000088'>+         *  If we are at a node that is a mount point so current directory
+         *  actually exists on the mounted file system and not in the node that
+         *  contains the mount point node. For example a stat of the mount
+         *  point should return the details of the root of the mounted file
+         *  system not the mount point node of parent file system.
+         *
+         *  If the node we have just moved to is a mount point do not loop and
+         *  get the token because the token may be suitable for the mounted
+         *  file system and not the IMFS. For example the IMFS length is
+         *  limited. If the token is a parent directory move back up otherwise
+         *  set loc to the new fs root node and let them finish evaluating the
+         *  path.
+         */
+        if (( node->type == IMFS_DIRECTORY ) && ( node->info.directory.mt_fs != NULL )) {
+          IMFS_skip_separator( pathname, &pathnamelen, &i);
+          if ((pathname[i] != '.') || (pathname[i + 1] != '.')) {
+            *pathloc = node->info.directory.mt_fs->mt_fs_root;
+            return (*pathloc->ops->evalpath_h)( &pathname[i],
+                                                pathnamelen,
+                                                flags, pathloc );
+          }
+          i += 2;
+          pathnamelen -= 2;
+          node = node->Parent;
+        }
</font> 
<font color='#880000'>-        pathloc->node_access = node;
-<span style="background-color: #FF0000">        </span>
</font>         /*
<font color='#880000'>-         *  If we are at a node that is a mount point. Set loc to the
-         *  new fs root node and let them finish evaluating the path.
</font><font color='#000088'>+         *  Set the node access to the point we have found.
</font>          */
<font color='#880000'>-
-        if ( node->info.directory.mt_fs != NULL ) {
-          newloc   = node->info.directory.mt_fs->mt_fs_root;
-          *pathloc = newloc;
-          return (*pathloc->ops->evalpath_h)( &pathname[i],
-                                              pathnamelen,
-                                              flags, pathloc );
-        }
</font><font color='#000088'>+        pathloc->node_access = node;
</font>         break;
 
       case IMFS_NO_MORE_PATH:
<font color='#997700'>@@ -644,8 +666,7 @@
</font> 
   if ( node->type == IMFS_DIRECTORY ) {
     if ( node->info.directory.mt_fs != NULL ) {
<font color='#880000'>-      newloc   = node->info.directory.mt_fs->mt_fs_root;
-      *pathloc = newloc;
</font><font color='#000088'>+      *pathloc = node->info.directory.mt_fs->mt_fs_root;
</font>       return (*pathloc->ops->evalpath_h)( &pathname[i-len],
                                           pathnamelen+len,
                                           flags, pathloc );
</pre>
<p> </p>

<p>--<br />
<small>Generated by <a href="http://www.codewiz.org/projects/index.html#loginfo">Deluxe Loginfo</a> 2.122 by Bernardo Innocenti <bernie@develer.com></small></p>
</body>
</html>