Changeset 246e23c in rtems for cpukit/libcsupport/src/unmount.c


Ignore:
Timestamp:
May 29, 2012, 10:26:45 AM (8 years ago)
Author:
Sebastian Huber <sebastian.huber@…>
Children:
486f8b84
Parents:
45ada30 (diff), 847ad44 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'upstream'

File:
1 edited

Legend:

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

    r45ada30 r246e23c  
    2323#include <rtems/libio_.h>
    2424
     25static 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
    2537int unmount( const char *path )
    2638{
     
    3345
    3446  if ( rtems_filesystem_location_is_root( currentloc ) ) {
    35     const rtems_filesystem_operations_table *mt_point_ops =
    36       mt_entry->mt_point_node->location.mt_entry->ops;
     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;
    3750
    38     rv = (*mt_point_ops->unmount_h)( mt_entry );
    39     if ( rv == 0 ) {
    40       rtems_filesystem_mt_entry_declare_lock_context( lock_context );
     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 );
    4155
    42       rtems_filesystem_mt_entry_lock( lock_context );
    43       mt_entry->mounted = false;
    44       rtems_filesystem_mt_entry_unlock( lock_context );
     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;
    4564    }
    4665  } else {
     
    5170  rtems_filesystem_eval_path_cleanup( &ctx );
    5271
     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
    5386  return rv;
    5487}
Note: See TracChangeset for help on using the changeset viewer.