forked from Imagelibrary/rtems
Added code to correctly free any allocated space during the evaluation
process.
This commit is contained in:
@@ -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,17 +142,16 @@ int mount(
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if ( mount_point ) {
|
if ( mount_point ) {
|
||||||
|
|
||||||
if ( rtems_filesystem_evaluate_path(
|
if ( rtems_filesystem_evaluate_path(
|
||||||
mount_point,
|
mount_point, RTEMS_LIBIO_PERMS_RWX, &loc, TRUE ) == -1 )
|
||||||
RTEMS_LIBIO_PERMS_RWX,
|
|
||||||
&loc,
|
|
||||||
TRUE ) == -1 )
|
|
||||||
goto cleanup_and_bail;
|
goto cleanup_and_bail;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Test to see if it is a directory
|
* Test to see if it is a directory
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
loc_to_free = &loc;
|
||||||
if ( loc.ops->node_type( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
|
if ( loc.ops->node_type( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
|
||||||
errno = ENOTDIR;
|
errno = ENOTDIR;
|
||||||
goto cleanup_and_bail;
|
goto cleanup_and_bail;
|
||||||
@@ -168,7 +168,10 @@ int mount(
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* This must be a good mount point, so move the location information
|
* 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;
|
temp_mt_entry->mt_point_node.node_access = loc.node_access;
|
||||||
@@ -189,8 +192,7 @@ int mount(
|
|||||||
if ( loc.ops->mount( temp_mt_entry ) ) {
|
if ( loc.ops->mount( temp_mt_entry ) ) {
|
||||||
goto cleanup_and_bail;
|
goto cleanup_and_bail;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is a mount of the base file system --> The
|
* This is a mount of the base file system --> The
|
||||||
@@ -224,15 +226,14 @@ int mount(
|
|||||||
|
|
||||||
*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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 );
|
||||||
|
|
||||||
|
|||||||
@@ -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,17 +142,16 @@ int mount(
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if ( mount_point ) {
|
if ( mount_point ) {
|
||||||
|
|
||||||
if ( rtems_filesystem_evaluate_path(
|
if ( rtems_filesystem_evaluate_path(
|
||||||
mount_point,
|
mount_point, RTEMS_LIBIO_PERMS_RWX, &loc, TRUE ) == -1 )
|
||||||
RTEMS_LIBIO_PERMS_RWX,
|
|
||||||
&loc,
|
|
||||||
TRUE ) == -1 )
|
|
||||||
goto cleanup_and_bail;
|
goto cleanup_and_bail;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Test to see if it is a directory
|
* Test to see if it is a directory
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
loc_to_free = &loc;
|
||||||
if ( loc.ops->node_type( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
|
if ( loc.ops->node_type( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
|
||||||
errno = ENOTDIR;
|
errno = ENOTDIR;
|
||||||
goto cleanup_and_bail;
|
goto cleanup_and_bail;
|
||||||
@@ -168,7 +168,10 @@ int mount(
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* This must be a good mount point, so move the location information
|
* 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;
|
temp_mt_entry->mt_point_node.node_access = loc.node_access;
|
||||||
@@ -189,8 +192,7 @@ int mount(
|
|||||||
if ( loc.ops->mount( temp_mt_entry ) ) {
|
if ( loc.ops->mount( temp_mt_entry ) ) {
|
||||||
goto cleanup_and_bail;
|
goto cleanup_and_bail;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is a mount of the base file system --> The
|
* This is a mount of the base file system --> The
|
||||||
@@ -224,15 +226,14 @@ int mount(
|
|||||||
|
|
||||||
*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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 );
|
||||||
|
|
||||||
|
|||||||
@@ -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,17 +142,16 @@ int mount(
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
if ( mount_point ) {
|
if ( mount_point ) {
|
||||||
|
|
||||||
if ( rtems_filesystem_evaluate_path(
|
if ( rtems_filesystem_evaluate_path(
|
||||||
mount_point,
|
mount_point, RTEMS_LIBIO_PERMS_RWX, &loc, TRUE ) == -1 )
|
||||||
RTEMS_LIBIO_PERMS_RWX,
|
|
||||||
&loc,
|
|
||||||
TRUE ) == -1 )
|
|
||||||
goto cleanup_and_bail;
|
goto cleanup_and_bail;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Test to see if it is a directory
|
* Test to see if it is a directory
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
loc_to_free = &loc;
|
||||||
if ( loc.ops->node_type( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
|
if ( loc.ops->node_type( &loc ) != RTEMS_FILESYSTEM_DIRECTORY ) {
|
||||||
errno = ENOTDIR;
|
errno = ENOTDIR;
|
||||||
goto cleanup_and_bail;
|
goto cleanup_and_bail;
|
||||||
@@ -168,7 +168,10 @@ int mount(
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* This must be a good mount point, so move the location information
|
* 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;
|
temp_mt_entry->mt_point_node.node_access = loc.node_access;
|
||||||
@@ -189,8 +192,7 @@ int mount(
|
|||||||
if ( loc.ops->mount( temp_mt_entry ) ) {
|
if ( loc.ops->mount( temp_mt_entry ) ) {
|
||||||
goto cleanup_and_bail;
|
goto cleanup_and_bail;
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is a mount of the base file system --> The
|
* This is a mount of the base file system --> The
|
||||||
@@ -224,15 +226,14 @@ int mount(
|
|||||||
|
|
||||||
*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;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 );
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user