summaryrefslogtreecommitdiffstats
path: root/cpukit/libfs/src/imfs/imfs_rmnod.c
diff options
context:
space:
mode:
Diffstat (limited to 'cpukit/libfs/src/imfs/imfs_rmnod.c')
-rw-r--r--cpukit/libfs/src/imfs/imfs_rmnod.c79
1 files changed, 36 insertions, 43 deletions
diff --git a/cpukit/libfs/src/imfs/imfs_rmnod.c b/cpukit/libfs/src/imfs/imfs_rmnod.c
index ed6001a691..25c7cde084 100644
--- a/cpukit/libfs/src/imfs/imfs_rmnod.c
+++ b/cpukit/libfs/src/imfs/imfs_rmnod.c
@@ -26,59 +26,52 @@
#include "imfs.h"
-/*
- * IMFS_rmnod
- */
-
-int IMFS_rmnod(
- rtems_filesystem_location_info_t *parent_pathloc, /* IN */
- rtems_filesystem_location_info_t *pathloc /* IN */
-)
+void IMFS_create_orphan( IMFS_jnode_t *jnode )
{
- IMFS_jnode_t *the_jnode;
-
- the_jnode = (IMFS_jnode_t *) pathloc->node_access;
-
- /*
- * Take the node out of the parent's chain that contains this node
- */
-
- if ( the_jnode->Parent != NULL ) {
- rtems_chain_extract( (rtems_chain_node *) the_jnode );
- the_jnode->Parent = NULL;
+ if ( jnode->Parent != NULL ) {
+ rtems_chain_extract( &jnode->Node );
+ jnode->Parent = NULL;
}
- /*
- * Decrement the link counter and see if we can free the space.
- */
+ --jnode->st_nlink;
- the_jnode->st_nlink--;
- IMFS_update_ctime( the_jnode );
+ IMFS_update_ctime( jnode );
+}
- /*
- * The file cannot be open and the link must be less than 1 to free.
- */
+void IMFS_check_node_remove( IMFS_jnode_t *jnode )
+{
+ if ( !rtems_libio_is_file_open( jnode ) && jnode->st_nlink < 1 ) {
+ if ( rtems_filesystem_current.node_access == jnode )
+ rtems_filesystem_current.node_access = NULL;
- if ( !rtems_libio_is_file_open( the_jnode ) && (the_jnode->st_nlink < 1) ) {
+ switch ( jnode->type ) {
+ case IMFS_MEMORY_FILE:
+ IMFS_memfile_remove( jnode );
+ break;
+ case IMFS_SYM_LINK:
+ free( jnode->info.sym_link.name );
+ break;
+ default:
+ break;
+ }
- /*
- * Is rtems_filesystem_current this node?
- */
+ free( jnode );
+ }
+}
- if ( rtems_filesystem_current.node_access == pathloc->node_access )
- rtems_filesystem_current.node_access = NULL;
+/*
+ * IMFS_rmnod
+ */
- /*
- * Free memory associated with a memory file.
- */
+int IMFS_rmnod(
+ rtems_filesystem_location_info_t *parent_pathloc, /* IN */
+ rtems_filesystem_location_info_t *pathloc /* IN */
+)
+{
+ IMFS_jnode_t *jnode = (IMFS_jnode_t *) pathloc->node_access;
- if ( the_jnode->type == IMFS_SYM_LINK ) {
- if ( the_jnode->info.sym_link.name )
- free( (void*) the_jnode->info.sym_link.name );
- }
- free( the_jnode );
- }
+ IMFS_create_orphan( jnode );
+ IMFS_check_node_remove( jnode );
return 0;
-
}