Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/src/unmount.c

    r847ad44 rda154e14  
    2323#include <rtems/libio_.h>
    2424
    25 static bool contains_root_or_current_directory(
    26   const rtems_filesystem_mount_table_entry_t *mt_entry
    27 )
    28 {
    29   const rtems_filesystem_location_info_t *root =
    30     &rtems_filesystem_root->location;
    31   const rtems_filesystem_location_info_t *current =
    32     &rtems_filesystem_current->location;
    33 
    34   return mt_entry == root->mt_entry || mt_entry == current->mt_entry;
    35 }
    36 
    3725int unmount( const char *path )
    3826{
     
    4533
    4634  if ( rtems_filesystem_location_is_root( currentloc ) ) {
    47     if ( !contains_root_or_current_directory( mt_entry ) ) {
    48       const rtems_filesystem_operations_table *mt_point_ops =
    49         mt_entry->mt_point_node->location.mt_entry->ops;
     35    const rtems_filesystem_operations_table *mt_point_ops =
     36      mt_entry->mt_point_node->location.mt_entry->ops;
    5037
    51       rv = (*mt_point_ops->unmount_h)( mt_entry );
    52       if ( rv == 0 ) {
    53         rtems_id self_task_id = rtems_task_self();
    54         rtems_filesystem_mt_entry_declare_lock_context( lock_context );
     38    rv = (*mt_point_ops->unmount_h)( mt_entry );
     39    if ( rv == 0 ) {
     40      rtems_filesystem_mt_entry_declare_lock_context( lock_context );
    5541
    56         rtems_filesystem_mt_entry_lock( lock_context );
    57         mt_entry->unmount_task = self_task_id;
    58         mt_entry->mounted = false;
    59         rtems_filesystem_mt_entry_unlock( lock_context );
    60       }
    61     } else {
    62       errno = EBUSY;
    63       rv = -1;
     42      rtems_filesystem_mt_entry_lock( lock_context );
     43      mt_entry->mounted = false;
     44      rtems_filesystem_mt_entry_unlock( lock_context );
    6445    }
    6546  } else {
     
    7051  rtems_filesystem_eval_path_cleanup( &ctx );
    7152
    72   if ( rv == 0 ) {
    73     rtems_event_set out;
    74     rtems_status_code sc = rtems_event_receive(
    75       RTEMS_FILESYSTEM_UNMOUNT_EVENT,
    76       RTEMS_EVENT_ALL | RTEMS_WAIT,
    77       RTEMS_NO_TIMEOUT,
    78       &out
    79     );
    80 
    81     if ( sc != RTEMS_SUCCESSFUL ) {
    82       rtems_fatal_error_occurred( 0xdeadbeef );
    83     }
    84   }
    85 
    8653  return rv;
    8754}
Note: See TracChangeset for help on using the changeset viewer.