Added code to correctly free any allocated space during the evaluation

process.
This commit is contained in:
Jennifer Averett
1999-10-25 14:23:03 +00:00
parent 72d3f610f4
commit 04df848c65
6 changed files with 189 additions and 183 deletions

View File

@@ -95,6 +95,7 @@ int mount(
{
rtems_filesystem_location_info_t loc;
rtems_filesystem_mount_table_entry_t *temp_mt_entry;
rtems_filesystem_location_info_t *loc_to_free = NULL;
/* XXX add code to check for required operations */
@@ -141,17 +142,16 @@ int mount(
*/
if ( mount_point ) {
if ( rtems_filesystem_evaluate_path(
mount_point,
RTEMS_LIBIO_PERMS_RWX,
&loc,
TRUE ) == -1 )
mount_point, RTEMS_LIBIO_PERMS_RWX, &loc, TRUE ) == -1 )
goto cleanup_and_bail;
/*
* Test to see if it is a directory
*/
loc_to_free = &loc;
if ( loc.ops->node_type( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
errno = ENOTDIR;
goto cleanup_and_bail;
@@ -168,7 +168,10 @@ int mount(
/*
* This must be a good mount point, so move the location information
* into the allocated mount entry
* into the allocated mount entry. Note: the information that
* may have been allocated in loc should not be sent to freenode
* until the system is unmounted. It may be needed to correctly
* traverse the tree.
*/
temp_mt_entry->mt_point_node.node_access = loc.node_access;
@@ -189,8 +192,7 @@ int mount(
if ( loc.ops->mount( temp_mt_entry ) ) {
goto cleanup_and_bail;
}
}
else {
} else {
/*
* This is a mount of the base file system --> The
@@ -224,15 +226,14 @@ int mount(
*mt_entry = temp_mt_entry;
rtems_filesystem_freenode( &loc );
return 0;
cleanup_and_bail:
free( temp_mt_entry );
rtems_filesystem_freenode( &loc );
if ( loc_to_free )
rtems_filesystem_freenode( loc_to_free );
return -1;
}

View File

@@ -137,6 +137,7 @@ int unmount(
* Free the memory associated with the extracted mount table entry.
*/
rtems_filesystem_freenode( &temp_loc.mt_entry->mt_point_node );
free( temp_loc.mt_entry );
rtems_filesystem_freenode( &temp_loc );

View File

@@ -95,6 +95,7 @@ int mount(
{
rtems_filesystem_location_info_t loc;
rtems_filesystem_mount_table_entry_t *temp_mt_entry;
rtems_filesystem_location_info_t *loc_to_free = NULL;
/* XXX add code to check for required operations */
@@ -141,17 +142,16 @@ int mount(
*/
if ( mount_point ) {
if ( rtems_filesystem_evaluate_path(
mount_point,
RTEMS_LIBIO_PERMS_RWX,
&loc,
TRUE ) == -1 )
mount_point, RTEMS_LIBIO_PERMS_RWX, &loc, TRUE ) == -1 )
goto cleanup_and_bail;
/*
* Test to see if it is a directory
*/
loc_to_free = &loc;
if ( loc.ops->node_type( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
errno = ENOTDIR;
goto cleanup_and_bail;
@@ -168,7 +168,10 @@ int mount(
/*
* This must be a good mount point, so move the location information
* into the allocated mount entry
* into the allocated mount entry. Note: the information that
* may have been allocated in loc should not be sent to freenode
* until the system is unmounted. It may be needed to correctly
* traverse the tree.
*/
temp_mt_entry->mt_point_node.node_access = loc.node_access;
@@ -189,8 +192,7 @@ int mount(
if ( loc.ops->mount( temp_mt_entry ) ) {
goto cleanup_and_bail;
}
}
else {
} else {
/*
* This is a mount of the base file system --> The
@@ -224,15 +226,14 @@ int mount(
*mt_entry = temp_mt_entry;
rtems_filesystem_freenode( &loc );
return 0;
cleanup_and_bail:
free( temp_mt_entry );
rtems_filesystem_freenode( &loc );
if ( loc_to_free )
rtems_filesystem_freenode( loc_to_free );
return -1;
}

View File

@@ -137,6 +137,7 @@ int unmount(
* Free the memory associated with the extracted mount table entry.
*/
rtems_filesystem_freenode( &temp_loc.mt_entry->mt_point_node );
free( temp_loc.mt_entry );
rtems_filesystem_freenode( &temp_loc );

View File

@@ -95,6 +95,7 @@ int mount(
{
rtems_filesystem_location_info_t loc;
rtems_filesystem_mount_table_entry_t *temp_mt_entry;
rtems_filesystem_location_info_t *loc_to_free = NULL;
/* XXX add code to check for required operations */
@@ -141,17 +142,16 @@ int mount(
*/
if ( mount_point ) {
if ( rtems_filesystem_evaluate_path(
mount_point,
RTEMS_LIBIO_PERMS_RWX,
&loc,
TRUE ) == -1 )
mount_point, RTEMS_LIBIO_PERMS_RWX, &loc, TRUE ) == -1 )
goto cleanup_and_bail;
/*
* Test to see if it is a directory
*/
loc_to_free = &loc;
if ( loc.ops->node_type( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
errno = ENOTDIR;
goto cleanup_and_bail;
@@ -168,7 +168,10 @@ int mount(
/*
* This must be a good mount point, so move the location information
* into the allocated mount entry
* into the allocated mount entry. Note: the information that
* may have been allocated in loc should not be sent to freenode
* until the system is unmounted. It may be needed to correctly
* traverse the tree.
*/
temp_mt_entry->mt_point_node.node_access = loc.node_access;
@@ -189,8 +192,7 @@ int mount(
if ( loc.ops->mount( temp_mt_entry ) ) {
goto cleanup_and_bail;
}
}
else {
} else {
/*
* This is a mount of the base file system --> The
@@ -224,15 +226,14 @@ int mount(
*mt_entry = temp_mt_entry;
rtems_filesystem_freenode( &loc );
return 0;
cleanup_and_bail:
free( temp_mt_entry );
rtems_filesystem_freenode( &loc );
if ( loc_to_free )
rtems_filesystem_freenode( loc_to_free );
return -1;
}

View File

@@ -137,6 +137,7 @@ int unmount(
* Free the memory associated with the extracted mount table entry.
*/
rtems_filesystem_freenode( &temp_loc.mt_entry->mt_point_node );
free( temp_loc.mt_entry );
rtems_filesystem_freenode( &temp_loc );