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_location_info_t loc;
rtems_filesystem_mount_table_entry_t *temp_mt_entry; 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 */ /* XXX add code to check for required operations */
@@ -141,98 +142,98 @@ int mount(
*/ */
if ( mount_point ) { if ( mount_point ) {
if ( rtems_filesystem_evaluate_path(
mount_point,
RTEMS_LIBIO_PERMS_RWX,
&loc,
TRUE ) == -1 )
goto cleanup_and_bail;
/* if ( rtems_filesystem_evaluate_path(
* Test to see if it is a directory mount_point, RTEMS_LIBIO_PERMS_RWX, &loc, TRUE ) == -1 )
*/ goto cleanup_and_bail;
if ( loc.ops->node_type( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) { /*
errno = ENOTDIR; * Test to see if it is a directory
goto cleanup_and_bail; */
}
/* loc_to_free = &loc;
* You can only mount one file system onto a single mount point. if ( loc.ops->node_type( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
*/ errno = ENOTDIR;
goto cleanup_and_bail;
}
if ( search_mt_for_mount_point( &loc ) == FOUND ) { /*
errno = EBUSY; * You can only mount one file system onto a single mount point.
goto cleanup_and_bail; */
}
/* if ( search_mt_for_mount_point( &loc ) == FOUND ) {
* This must be a good mount point, so move the location information errno = EBUSY;
* into the allocated mount entry goto cleanup_and_bail;
*/ }
temp_mt_entry->mt_point_node.node_access = loc.node_access; /*
temp_mt_entry->mt_point_node.handlers = loc.handlers; * This must be a good mount point, so move the location information
temp_mt_entry->mt_point_node.ops = loc.ops; * into the allocated mount entry. Note: the information that
temp_mt_entry->mt_point_node.mt_entry = loc.mt_entry; * 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;
* This link to the parent is only done when we are dealing with system temp_mt_entry->mt_point_node.handlers = loc.handlers;
* below the base file system temp_mt_entry->mt_point_node.ops = loc.ops;
*/ temp_mt_entry->mt_point_node.mt_entry = loc.mt_entry;
if ( !loc.ops->mount ){ /*
errno = ENOTSUP; * This link to the parent is only done when we are dealing with system
goto cleanup_and_bail; * below the base file system
} */
if ( loc.ops->mount( temp_mt_entry ) ) { if ( !loc.ops->mount ){
goto cleanup_and_bail; errno = ENOTSUP;
} goto cleanup_and_bail;
} }
else {
/* if ( loc.ops->mount( temp_mt_entry ) ) {
* This is a mount of the base file system --> The goto cleanup_and_bail;
* mt_point_node.node_access will be set to null to indicate that this }
* is the root of the entire file system. } else {
*/
temp_mt_entry->mt_fs_root.node_access = NULL; /*
temp_mt_entry->mt_fs_root.handlers = NULL; * This is a mount of the base file system --> The
temp_mt_entry->mt_fs_root.ops = NULL; * mt_point_node.node_access will be set to null to indicate that this
* is the root of the entire file system.
*/
temp_mt_entry->mt_point_node.node_access = NULL; temp_mt_entry->mt_fs_root.node_access = NULL;
temp_mt_entry->mt_point_node.handlers = NULL; temp_mt_entry->mt_fs_root.handlers = NULL;
temp_mt_entry->mt_point_node.ops = NULL; temp_mt_entry->mt_fs_root.ops = NULL;
temp_mt_entry->mt_point_node.mt_entry = NULL;
temp_mt_entry->mt_point_node.node_access = NULL;
temp_mt_entry->mt_point_node.handlers = NULL;
temp_mt_entry->mt_point_node.ops = NULL;
temp_mt_entry->mt_point_node.mt_entry = NULL;
} }
if ( !fs_ops->fsmount_me ){ if ( !fs_ops->fsmount_me ){
errno = ENOTSUP; errno = ENOTSUP;
goto cleanup_and_bail; goto cleanup_and_bail;
} }
if ( fs_ops->fsmount_me( temp_mt_entry ) ) if ( fs_ops->fsmount_me( temp_mt_entry ) )
goto cleanup_and_bail; goto cleanup_and_bail;
/* /*
* Add the mount table entry to the mount table chain * Add the mount table entry to the mount table chain
*/ */
Chain_Append( &rtems_filesystem_mount_table_control, &temp_mt_entry->Node ); Chain_Append( &rtems_filesystem_mount_table_control, &temp_mt_entry->Node );
*mt_entry = temp_mt_entry; *mt_entry = temp_mt_entry;
rtems_filesystem_freenode( &loc );
return 0; return 0;
cleanup_and_bail: cleanup_and_bail:
free( temp_mt_entry ); free( temp_mt_entry );
rtems_filesystem_freenode( &loc ); if ( loc_to_free )
rtems_filesystem_freenode( loc_to_free );
return -1; return -1;
} }

View File

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

View File

@@ -95,6 +95,7 @@ int mount(
{ {
rtems_filesystem_location_info_t loc; rtems_filesystem_location_info_t loc;
rtems_filesystem_mount_table_entry_t *temp_mt_entry; 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 */ /* XXX add code to check for required operations */
@@ -141,98 +142,98 @@ int mount(
*/ */
if ( mount_point ) { if ( mount_point ) {
if ( rtems_filesystem_evaluate_path(
mount_point,
RTEMS_LIBIO_PERMS_RWX,
&loc,
TRUE ) == -1 )
goto cleanup_and_bail;
/* if ( rtems_filesystem_evaluate_path(
* Test to see if it is a directory mount_point, RTEMS_LIBIO_PERMS_RWX, &loc, TRUE ) == -1 )
*/ goto cleanup_and_bail;
if ( loc.ops->node_type( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) { /*
errno = ENOTDIR; * Test to see if it is a directory
goto cleanup_and_bail; */
}
/* loc_to_free = &loc;
* You can only mount one file system onto a single mount point. if ( loc.ops->node_type( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
*/ errno = ENOTDIR;
goto cleanup_and_bail;
}
if ( search_mt_for_mount_point( &loc ) == FOUND ) { /*
errno = EBUSY; * You can only mount one file system onto a single mount point.
goto cleanup_and_bail; */
}
/* if ( search_mt_for_mount_point( &loc ) == FOUND ) {
* This must be a good mount point, so move the location information errno = EBUSY;
* into the allocated mount entry goto cleanup_and_bail;
*/ }
temp_mt_entry->mt_point_node.node_access = loc.node_access; /*
temp_mt_entry->mt_point_node.handlers = loc.handlers; * This must be a good mount point, so move the location information
temp_mt_entry->mt_point_node.ops = loc.ops; * into the allocated mount entry. Note: the information that
temp_mt_entry->mt_point_node.mt_entry = loc.mt_entry; * 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;
* This link to the parent is only done when we are dealing with system temp_mt_entry->mt_point_node.handlers = loc.handlers;
* below the base file system temp_mt_entry->mt_point_node.ops = loc.ops;
*/ temp_mt_entry->mt_point_node.mt_entry = loc.mt_entry;
if ( !loc.ops->mount ){ /*
errno = ENOTSUP; * This link to the parent is only done when we are dealing with system
goto cleanup_and_bail; * below the base file system
} */
if ( loc.ops->mount( temp_mt_entry ) ) { if ( !loc.ops->mount ){
goto cleanup_and_bail; errno = ENOTSUP;
} goto cleanup_and_bail;
} }
else {
/* if ( loc.ops->mount( temp_mt_entry ) ) {
* This is a mount of the base file system --> The goto cleanup_and_bail;
* mt_point_node.node_access will be set to null to indicate that this }
* is the root of the entire file system. } else {
*/
temp_mt_entry->mt_fs_root.node_access = NULL; /*
temp_mt_entry->mt_fs_root.handlers = NULL; * This is a mount of the base file system --> The
temp_mt_entry->mt_fs_root.ops = NULL; * mt_point_node.node_access will be set to null to indicate that this
* is the root of the entire file system.
*/
temp_mt_entry->mt_point_node.node_access = NULL; temp_mt_entry->mt_fs_root.node_access = NULL;
temp_mt_entry->mt_point_node.handlers = NULL; temp_mt_entry->mt_fs_root.handlers = NULL;
temp_mt_entry->mt_point_node.ops = NULL; temp_mt_entry->mt_fs_root.ops = NULL;
temp_mt_entry->mt_point_node.mt_entry = NULL;
temp_mt_entry->mt_point_node.node_access = NULL;
temp_mt_entry->mt_point_node.handlers = NULL;
temp_mt_entry->mt_point_node.ops = NULL;
temp_mt_entry->mt_point_node.mt_entry = NULL;
} }
if ( !fs_ops->fsmount_me ){ if ( !fs_ops->fsmount_me ){
errno = ENOTSUP; errno = ENOTSUP;
goto cleanup_and_bail; goto cleanup_and_bail;
} }
if ( fs_ops->fsmount_me( temp_mt_entry ) ) if ( fs_ops->fsmount_me( temp_mt_entry ) )
goto cleanup_and_bail; goto cleanup_and_bail;
/* /*
* Add the mount table entry to the mount table chain * Add the mount table entry to the mount table chain
*/ */
Chain_Append( &rtems_filesystem_mount_table_control, &temp_mt_entry->Node ); Chain_Append( &rtems_filesystem_mount_table_control, &temp_mt_entry->Node );
*mt_entry = temp_mt_entry; *mt_entry = temp_mt_entry;
rtems_filesystem_freenode( &loc );
return 0; return 0;
cleanup_and_bail: cleanup_and_bail:
free( temp_mt_entry ); free( temp_mt_entry );
rtems_filesystem_freenode( &loc ); if ( loc_to_free )
rtems_filesystem_freenode( loc_to_free );
return -1; return -1;
} }

View File

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

View File

@@ -95,6 +95,7 @@ int mount(
{ {
rtems_filesystem_location_info_t loc; rtems_filesystem_location_info_t loc;
rtems_filesystem_mount_table_entry_t *temp_mt_entry; 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 */ /* XXX add code to check for required operations */
@@ -141,98 +142,98 @@ int mount(
*/ */
if ( mount_point ) { if ( mount_point ) {
if ( rtems_filesystem_evaluate_path(
mount_point,
RTEMS_LIBIO_PERMS_RWX,
&loc,
TRUE ) == -1 )
goto cleanup_and_bail;
/* if ( rtems_filesystem_evaluate_path(
* Test to see if it is a directory mount_point, RTEMS_LIBIO_PERMS_RWX, &loc, TRUE ) == -1 )
*/ goto cleanup_and_bail;
if ( loc.ops->node_type( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) { /*
errno = ENOTDIR; * Test to see if it is a directory
goto cleanup_and_bail; */
}
/* loc_to_free = &loc;
* You can only mount one file system onto a single mount point. if ( loc.ops->node_type( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
*/ errno = ENOTDIR;
goto cleanup_and_bail;
}
if ( search_mt_for_mount_point( &loc ) == FOUND ) { /*
errno = EBUSY; * You can only mount one file system onto a single mount point.
goto cleanup_and_bail; */
}
/* if ( search_mt_for_mount_point( &loc ) == FOUND ) {
* This must be a good mount point, so move the location information errno = EBUSY;
* into the allocated mount entry goto cleanup_and_bail;
*/ }
temp_mt_entry->mt_point_node.node_access = loc.node_access; /*
temp_mt_entry->mt_point_node.handlers = loc.handlers; * This must be a good mount point, so move the location information
temp_mt_entry->mt_point_node.ops = loc.ops; * into the allocated mount entry. Note: the information that
temp_mt_entry->mt_point_node.mt_entry = loc.mt_entry; * 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;
* This link to the parent is only done when we are dealing with system temp_mt_entry->mt_point_node.handlers = loc.handlers;
* below the base file system temp_mt_entry->mt_point_node.ops = loc.ops;
*/ temp_mt_entry->mt_point_node.mt_entry = loc.mt_entry;
if ( !loc.ops->mount ){ /*
errno = ENOTSUP; * This link to the parent is only done when we are dealing with system
goto cleanup_and_bail; * below the base file system
} */
if ( loc.ops->mount( temp_mt_entry ) ) { if ( !loc.ops->mount ){
goto cleanup_and_bail; errno = ENOTSUP;
} goto cleanup_and_bail;
} }
else {
/* if ( loc.ops->mount( temp_mt_entry ) ) {
* This is a mount of the base file system --> The goto cleanup_and_bail;
* mt_point_node.node_access will be set to null to indicate that this }
* is the root of the entire file system. } else {
*/
temp_mt_entry->mt_fs_root.node_access = NULL; /*
temp_mt_entry->mt_fs_root.handlers = NULL; * This is a mount of the base file system --> The
temp_mt_entry->mt_fs_root.ops = NULL; * mt_point_node.node_access will be set to null to indicate that this
* is the root of the entire file system.
*/
temp_mt_entry->mt_point_node.node_access = NULL; temp_mt_entry->mt_fs_root.node_access = NULL;
temp_mt_entry->mt_point_node.handlers = NULL; temp_mt_entry->mt_fs_root.handlers = NULL;
temp_mt_entry->mt_point_node.ops = NULL; temp_mt_entry->mt_fs_root.ops = NULL;
temp_mt_entry->mt_point_node.mt_entry = NULL;
temp_mt_entry->mt_point_node.node_access = NULL;
temp_mt_entry->mt_point_node.handlers = NULL;
temp_mt_entry->mt_point_node.ops = NULL;
temp_mt_entry->mt_point_node.mt_entry = NULL;
} }
if ( !fs_ops->fsmount_me ){ if ( !fs_ops->fsmount_me ){
errno = ENOTSUP; errno = ENOTSUP;
goto cleanup_and_bail; goto cleanup_and_bail;
} }
if ( fs_ops->fsmount_me( temp_mt_entry ) ) if ( fs_ops->fsmount_me( temp_mt_entry ) )
goto cleanup_and_bail; goto cleanup_and_bail;
/* /*
* Add the mount table entry to the mount table chain * Add the mount table entry to the mount table chain
*/ */
Chain_Append( &rtems_filesystem_mount_table_control, &temp_mt_entry->Node ); Chain_Append( &rtems_filesystem_mount_table_control, &temp_mt_entry->Node );
*mt_entry = temp_mt_entry; *mt_entry = temp_mt_entry;
rtems_filesystem_freenode( &loc );
return 0; return 0;
cleanup_and_bail: cleanup_and_bail:
free( temp_mt_entry ); free( temp_mt_entry );
rtems_filesystem_freenode( &loc ); if ( loc_to_free )
rtems_filesystem_freenode( loc_to_free );
return -1; return -1;
} }

View File

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