static IMFS_jnode_t *IMFS_node_remove_hard_link( IMFS_jnode_t *node ) { IMFS_link_t *hard_link = (IMFS_link_t *) node; IMFS_jnode_t *target = hard_link->link_node; _Assert( target != NULL ); if ( target->st_nlink == 1 ) { target = (*target->control->node_remove)( target ); if ( target == NULL ) { node = NULL; } } else { --target->st_nlink; IMFS_update_ctime( target ); } if ( target != NULL ) { --target->reference_count; if ( target->reference_count == 0 ) { IMFS_node_destroy( target ); } } return node; }
void IMFS_node_free( const rtems_filesystem_location_info_t *loc ) { IMFS_jnode_t *node = loc->node_access; if ( node->reference_count == 1 ) { IMFS_node_destroy( node ); } else { --node->reference_count; } }
void IMFS_fsunmount( rtems_filesystem_mount_table_entry_t *temp_mt_entry ) { IMFS_jnode_t *jnode; IMFS_jnode_t *next; rtems_filesystem_location_info_t loc; int result = 0; /* * Traverse tree that starts at the mt_fs_root and deallocate memory * associated memory space */ loc = temp_mt_entry->mt_fs_root->location; jnode = (IMFS_jnode_t *)loc.node_access; /* * Set this to null to indicate that it is being unmounted. */ temp_mt_entry->mt_fs_root->location.node_access = NULL; do { next = jnode->Parent; loc.node_access = (void *)jnode; IMFS_Set_handlers( &loc ); if ( !IMFS_is_directory( jnode ) || jnode_has_no_children( jnode ) ) { result = IMFS_rmnod( NULL, &loc ); if ( result != 0 ) rtems_fatal_error_occurred( 0xdeadbeef ); IMFS_node_destroy( jnode ); jnode = next; } if ( jnode != NULL ) { if ( IMFS_is_directory( jnode ) ) { if ( jnode_has_children( jnode ) ) jnode = jnode_get_first_child( jnode ); } } } while (jnode != NULL); }