diff options
Diffstat (limited to 'cpukit/libfs/src/imfs/imfs_rmnod.c')
-rw-r--r-- | cpukit/libfs/src/imfs/imfs_rmnod.c | 65 |
1 files changed, 7 insertions, 58 deletions
diff --git a/cpukit/libfs/src/imfs/imfs_rmnod.c b/cpukit/libfs/src/imfs/imfs_rmnod.c index 748a6f7365..2d7041e341 100644 --- a/cpukit/libfs/src/imfs/imfs_rmnod.c +++ b/cpukit/libfs/src/imfs/imfs_rmnod.c @@ -23,52 +23,6 @@ #include "imfs.h" -static int IMFS_rmnod_directory( - const rtems_filesystem_location_info_t *parentloc, - const rtems_filesystem_location_info_t *loc -) -{ - int rv = 0; - IMFS_jnode_t *node = loc->node_access; - - if ( !rtems_chain_is_empty( &node->info.directory.Entries ) ) { - errno = ENOTEMPTY; - rv = -1; - } else if ( - rtems_filesystem_location_is_root( loc ) - || node->info.directory.mt_fs != NULL - ) { - errno = EBUSY; - rv = -1; - } - - return rv; -} - -static int IMFS_rmnod_hard_link( - const rtems_filesystem_location_info_t *parentloc, - const rtems_filesystem_location_info_t *loc -) -{ - int rv = 0; - IMFS_jnode_t *node = loc->node_access; - IMFS_jnode_t *target = node->info.hard_link.link_node; - - if ( target->st_nlink == 1) { - rtems_filesystem_location_info_t target_loc = *loc; - - target_loc.node_access = target; - IMFS_Set_handlers( &target_loc ); - - rv = (*target_loc.ops->rmnod_h)( parentloc, &target_loc ); - } else { - --target->st_nlink; - IMFS_update_ctime( target ); - } - - return rv; -} - int IMFS_rmnod( const rtems_filesystem_location_info_t *parentloc, const rtems_filesystem_location_info_t *loc @@ -77,23 +31,18 @@ int IMFS_rmnod( int rv = 0; IMFS_jnode_t *node = loc->node_access; - switch ( node->type ) { - case IMFS_DIRECTORY: - rv = IMFS_rmnod_directory( parentloc, loc ); - break; - case IMFS_HARD_LINK: - rv = IMFS_rmnod_hard_link( parentloc, loc ); - break; - default: - break; - } - - if ( rv == 0 ) { + node = (*node->control->node_remove)( + node, + loc->mt_entry->mt_fs_root->location.node_access + ); + if ( node != NULL ) { --node->reference_count; --node->st_nlink; if ( node->Parent != NULL ) { IMFS_remove_from_directory( node ); } + } else { + rv = -1; } return rv; |