summaryrefslogtreecommitdiffstats
path: root/cpukit
diff options
context:
space:
mode:
authorChris Johns <chrisj@rtems.org>2011-04-16 03:47:32 +0000
committerChris Johns <chrisj@rtems.org>2011-04-16 03:47:32 +0000
commitec9d48633341c842652647befc3d0220a84eb6b0 (patch)
treebc4cd23a8aad9d4ac9b5135717e5b56949634dda /cpukit
parent2011-04-11 Keith Robertson <kjrobert at alumni dot uwaterloo dot ca> (diff)
downloadrtems-ec9d48633341c842652647befc3d0220a84eb6b0.tar.bz2
2011-04-16 Chris Johns <chrisj@rtems.org>
PR 1774/filesystem * libfs/src/imfs/imfs_eval.c: Fix the IMFS eval and eval for make handlers to not inspect a mounted file sytems path.
Diffstat (limited to 'cpukit')
-rw-r--r--cpukit/ChangeLog6
-rw-r--r--cpukit/libfs/src/imfs/imfs_eval.c112
2 files changed, 63 insertions, 55 deletions
diff --git a/cpukit/ChangeLog b/cpukit/ChangeLog
index ded8e1125d..a1d7020f10 100644
--- a/cpukit/ChangeLog
+++ b/cpukit/ChangeLog
@@ -1,3 +1,9 @@
+2011-04-16 Chris Johns <chrisj@rtems.org>
+
+ PR 1774/filesystem
+ * libfs/src/imfs/imfs_eval.c: Fix the IMFS eval and eval for make
+ handlers to not inspect a mounted file sytems path.
+
2011-04-04 Sebastien Bourdeauducq <sebastien.bourdeauducq@gmail.com>
PR 1722/networking
diff --git a/cpukit/libfs/src/imfs/imfs_eval.c b/cpukit/libfs/src/imfs/imfs_eval.c
index 7aba2b535e..040316dfce 100644
--- a/cpukit/libfs/src/imfs/imfs_eval.c
+++ b/cpukit/libfs/src/imfs/imfs_eval.c
@@ -306,6 +306,7 @@ int IMFS_evaluate_for_make(
* Get the path length.
*/
pathlen = strlen( path );
+
/*
* Evaluate all tokens until we are done or an error occurs.
*/
@@ -335,56 +336,58 @@ int IMFS_evaluate_for_make(
case IMFS_UP_DIR:
/*
* Am I at the root of all filesystems? (chroot'ed?)
- */
+ */
if ( pathloc->node_access == rtems_filesystem_root.node_access )
break; /* Throw out the .. in this case */
- /*
- * Am I at the root of this mounted filesystem?
- */
+ /*
+ * Am I at the root of this mounted filesystem?
+ */
- if (pathloc->node_access == pathloc->mt_entry->mt_fs_root.node_access){
+ if (pathloc->node_access ==
+ pathloc->mt_entry->mt_fs_root.node_access){
/*
- * Am I at the root of all filesystems?
- */
+ * Am I at the root of all filesystems?
+ */
if ( pathloc->node_access == rtems_filesystem_root.node_access ) {
break;
-
- } else {
+ } else {
newloc = pathloc->mt_entry->mt_point_node;
*pathloc = newloc;
- return (*pathloc->ops->evalformake_h)( &path[i-len], pathloc, name );
- }
- } else {
-
+ return (*pathloc->ops->evalformake_h)( &path[i], pathloc, name );
+ }
+ } else {
if ( !node->Parent )
rtems_set_errno_and_return_minus_one( ENOENT );
node = node->Parent;
- }
+ }
pathloc->node_access = node;
break;
case IMFS_NAME:
+ /*
+ * If we are at a link follow it.
+ */
- if ( node->type == IMFS_HARD_LINK ) {
+ if ( node->type == IMFS_HARD_LINK ) {
result = IMFS_evaluate_link( pathloc, 0 );
if ( result == -1 )
return -1;
- } else if ( node->type == IMFS_SYM_LINK ) {
+ } else if ( node->type == IMFS_SYM_LINK ) {
result = IMFS_evaluate_link( pathloc, 0 );
if ( result == -1 )
return -1;
- }
+ }
node = pathloc->node_access;
if ( !node )
@@ -392,38 +395,38 @@ int IMFS_evaluate_for_make(
/*
* Only a directory can be decended into.
- */
+ */
if ( node->type != IMFS_DIRECTORY )
rtems_set_errno_and_return_minus_one( ENOTDIR );
- /*
- * 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-len], pathloc, name );
- }
-
- /*
- * Otherwise find the token name in the present location.
- */
+ /*
+ * Otherwise find the token name in the present location.
+ */
node = IMFS_find_match_in_dir( node, token );
- /*
- * If there is no node we have found the name of the node we
+ /*
+ * If there is no node we have found the name of the node we
* wish to create.
- */
+ */
if ( ! node )
done = true;
- else
- pathloc->node_access = node;
+ else {
+ /*
+ * 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 );
+ }
+
+ pathloc->node_access = node;
+ }
break;
case IMFS_NO_MORE_PATH:
@@ -558,18 +561,15 @@ int IMFS_eval_path(
} else {
newloc = pathloc->mt_entry->mt_point_node;
*pathloc = newloc;
- return (*pathloc->ops->evalpath_h)(&(pathname[i-len]),
- pathnamelen+len,
+ return (*pathloc->ops->evalpath_h)(&(pathname[i]),
+ pathnamelen,
flags,pathloc);
}
} else {
-
if ( !node->Parent )
rtems_set_errno_and_return_minus_one( ENOENT );
node = node->Parent;
- pathloc->node_access = node;
-
}
pathloc->node_access = node;
@@ -605,31 +605,33 @@ int IMFS_eval_path(
rtems_set_errno_and_return_minus_one( ENOTDIR );
/*
- * 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->evalpath_h)( &pathname[i-len],
- pathnamelen+len,
- flags, pathloc );
- }
-
- /*
* Otherwise find the token name in the present location.
*/
node = IMFS_find_match_in_dir( node, token );
+
if ( !node )
rtems_set_errno_and_return_minus_one( ENOENT );
+
/*
* Set the node access to the point we have found.
*/
pathloc->node_access = node;
+
+ /*
+ * 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->evalpath_h)( &pathname[i],
+ pathnamelen,
+ flags, pathloc );
+ }
break;
case IMFS_NO_MORE_PATH: