forked from Imagelibrary/rtems
2011-05-17 Chris Johns <chrisj@rtems.org>
PR 1774/filesystem
* libfs/src/imfs/imfs_eval.c: The previous change broke some of
the tests. This has been fixed.
This commit is contained in:
@@ -1,3 +1,9 @@
|
|||||||
|
2011-05-17 Chris Johns <chrisj@rtems.org>
|
||||||
|
|
||||||
|
PR 1774/filesystem
|
||||||
|
* libfs/src/imfs/imfs_eval.c: The previous change broke some of
|
||||||
|
the tests. This has been fixed.
|
||||||
|
|
||||||
2011-05-11 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
2011-05-11 Sebastian Huber <sebastian.huber@embedded-brains.de>
|
||||||
|
|
||||||
PR 1790/cpukit
|
PR 1790/cpukit
|
||||||
|
|||||||
@@ -270,6 +270,22 @@ int IMFS_evaluate_link(
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* IMFS_evaluate_for_make
|
* IMFS_evaluate_for_make
|
||||||
@@ -284,16 +300,15 @@ int IMFS_evaluate_for_make(
|
|||||||
const char *path, /* IN */
|
const char *path, /* IN */
|
||||||
rtems_filesystem_location_info_t *pathloc, /* IN/OUT */
|
rtems_filesystem_location_info_t *pathloc, /* IN/OUT */
|
||||||
const char **name /* OUT */
|
const char **name /* OUT */
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
int i = 0;
|
int i = 0;
|
||||||
int len;
|
int len;
|
||||||
IMFS_token_types type;
|
IMFS_token_types type;
|
||||||
char token[ IMFS_NAME_MAX + 1 ];
|
char token[ IMFS_NAME_MAX + 1 ];
|
||||||
rtems_filesystem_location_info_t newloc;
|
|
||||||
IMFS_jnode_t *node;
|
IMFS_jnode_t *node;
|
||||||
bool done = false;
|
bool done = false;
|
||||||
int pathlen;
|
size_t pathlen;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -346,8 +361,7 @@ int IMFS_evaluate_for_make(
|
|||||||
* Am I at the root of this mounted filesystem?
|
* Am I at the root of this mounted filesystem?
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (pathloc->node_access ==
|
if (pathloc->node_access == pathloc->mt_entry->mt_fs_root.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?
|
||||||
@@ -355,10 +369,10 @@ int IMFS_evaluate_for_make(
|
|||||||
|
|
||||||
if ( pathloc->node_access == rtems_filesystem_root.node_access ) {
|
if ( pathloc->node_access == rtems_filesystem_root.node_access ) {
|
||||||
break;
|
break;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
newloc = pathloc->mt_entry->mt_point_node;
|
*pathloc = pathloc->mt_entry->mt_point_node;
|
||||||
*pathloc = newloc;
|
return (*pathloc->ops->evalformake_h)( &path[i-len], pathloc, name );
|
||||||
return (*pathloc->ops->evalformake_h)( &path[i], pathloc, name );
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if ( !node->Parent )
|
if ( !node->Parent )
|
||||||
@@ -401,7 +415,7 @@ int IMFS_evaluate_for_make(
|
|||||||
rtems_set_errno_and_return_minus_one( ENOTDIR );
|
rtems_set_errno_and_return_minus_one( ENOTDIR );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Otherwise find the token name in the present location.
|
* Find the token name in the present location.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
node = IMFS_find_match_in_dir( node, token );
|
node = IMFS_find_match_in_dir( node, token );
|
||||||
@@ -414,15 +428,17 @@ int IMFS_evaluate_for_make(
|
|||||||
if ( ! node )
|
if ( ! node )
|
||||||
done = true;
|
done = true;
|
||||||
else {
|
else {
|
||||||
/*
|
if (( node->type == IMFS_DIRECTORY ) && ( node->info.directory.mt_fs != NULL )) {
|
||||||
* If we are at a node that is a mount point. Set loc to the
|
IMFS_skip_separator( path, &pathlen, &i);
|
||||||
* new fs root node and let them finish evaluating the path.
|
if ((path[i] != '.') || (path[i + 1] != '.')) {
|
||||||
*/
|
*pathloc = node->info.directory.mt_fs->mt_fs_root;
|
||||||
|
return (*pathloc->ops->evalformake_h)( &path[i],
|
||||||
if ( node->info.directory.mt_fs != NULL ) {
|
pathloc,
|
||||||
newloc = node->info.directory.mt_fs->mt_fs_root;
|
name );
|
||||||
*pathloc = newloc;
|
}
|
||||||
return (*pathloc->ops->evalformake_h)( &path[i], pathloc, name );
|
i += 2;
|
||||||
|
pathlen -= 2;
|
||||||
|
node = node->Parent;
|
||||||
}
|
}
|
||||||
|
|
||||||
pathloc->node_access = node;
|
pathloc->node_access = node;
|
||||||
@@ -497,7 +513,6 @@ int IMFS_eval_path(
|
|||||||
int len;
|
int len;
|
||||||
IMFS_token_types type = IMFS_CURRENT_DIR;
|
IMFS_token_types type = IMFS_CURRENT_DIR;
|
||||||
char token[ IMFS_NAME_MAX + 1 ];
|
char token[ IMFS_NAME_MAX + 1 ];
|
||||||
rtems_filesystem_location_info_t newloc;
|
|
||||||
IMFS_jnode_t *node;
|
IMFS_jnode_t *node;
|
||||||
int result;
|
int result;
|
||||||
|
|
||||||
@@ -559,10 +574,9 @@ int IMFS_eval_path(
|
|||||||
if ( pathloc->node_access == rtems_filesystem_root.node_access ) {
|
if ( pathloc->node_access == rtems_filesystem_root.node_access ) {
|
||||||
break; /* Throw out the .. in this case */
|
break; /* Throw out the .. in this case */
|
||||||
} else {
|
} else {
|
||||||
newloc = pathloc->mt_entry->mt_point_node;
|
*pathloc = pathloc->mt_entry->mt_point_node;
|
||||||
*pathloc = newloc;
|
return (*pathloc->ops->evalpath_h)(&(pathname[i-len]),
|
||||||
return (*pathloc->ops->evalpath_h)(&(pathname[i]),
|
pathnamelen+len,
|
||||||
pathnamelen,
|
|
||||||
flags,pathloc);
|
flags,pathloc);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -605,7 +619,7 @@ int IMFS_eval_path(
|
|||||||
rtems_set_errno_and_return_minus_one( ENOTDIR );
|
rtems_set_errno_and_return_minus_one( ENOTDIR );
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Otherwise find the token name in the present location.
|
* Find the token name in the current node.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
node = IMFS_find_match_in_dir( node, token );
|
node = IMFS_find_match_in_dir( node, token );
|
||||||
@@ -613,25 +627,38 @@ int IMFS_eval_path(
|
|||||||
if ( !node )
|
if ( !node )
|
||||||
rtems_set_errno_and_return_minus_one( ENOENT );
|
rtems_set_errno_and_return_minus_one( ENOENT );
|
||||||
|
|
||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set the node access to the point we have found.
|
* Set the node access to the point we have found.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
pathloc->node_access = node;
|
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;
|
break;
|
||||||
|
|
||||||
case IMFS_NO_MORE_PATH:
|
case IMFS_NO_MORE_PATH:
|
||||||
@@ -656,8 +683,7 @@ int IMFS_eval_path(
|
|||||||
|
|
||||||
if ( node->type == IMFS_DIRECTORY ) {
|
if ( node->type == IMFS_DIRECTORY ) {
|
||||||
if ( node->info.directory.mt_fs != NULL ) {
|
if ( node->info.directory.mt_fs != NULL ) {
|
||||||
newloc = node->info.directory.mt_fs->mt_fs_root;
|
*pathloc = node->info.directory.mt_fs->mt_fs_root;
|
||||||
*pathloc = newloc;
|
|
||||||
return (*pathloc->ops->evalpath_h)( &pathname[i-len],
|
return (*pathloc->ops->evalpath_h)( &pathname[i-len],
|
||||||
pathnamelen+len,
|
pathnamelen+len,
|
||||||
flags, pathloc );
|
flags, pathloc );
|
||||||
|
|||||||
Reference in New Issue
Block a user