Changeset 246e23c in rtems


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'

Files:
7 edited

Legend:

Unmodified
Added
Removed
  • cpukit/libcsupport/include/rtems/libio.h

    r45ada30 r246e23c  
    14601460   */
    14611461  char                                  *dev;
     1462
     1463  /**
     1464   * The task that initiated the unmount process.  After unmount process
     1465   * completion this task will be notified via the
     1466   * @ref RTEMS_FILESYSTEM_UNMOUNT_EVENT.
     1467   */
     1468  rtems_id                               unmount_task;
    14621469};
    14631470
     
    15141521 * @brief Unmounts the file system at @a mount_path.
    15151522 *
    1516  * @todo Due to file system implementation shortcomings it is possible to
    1517  * unmount file systems in use.  This likely leads to heap corruption.  Unmount
    1518  * only file systems which are not in use by the application.
     1523 * The function waits for the unmount process completion.  In case the calling
     1524 * thread uses resources of the unmounted file system the function may never
     1525 * return.  In case the calling thread has its root or current directory in the
     1526 * unmounted file system the function returns with an error status and errno is
     1527 * set to EBUSY.
     1528 *
     1529 * The unmount process completion notification uses the RTEMS classic API
     1530 * event @ref RTEMS_FILESYSTEM_UNMOUNT_EVENT.  It is a fatal error to terminate
     1531 * the calling thread while waiting for this event.
     1532 *
     1533 * A concurrent unmount request for the same file system instance has
     1534 * unpredictable effects.
    15191535 *
    15201536 * @retval 0 Successful operation.
  • cpukit/libcsupport/include/rtems/libio_.h

    r45ada30 r246e23c  
    3838#define RTEMS_LIBIO_SEM         rtems_build_name('L', 'B', 'I', 'O')
    3939#define RTEMS_LIBIO_IOP_SEM(n)  rtems_build_name('L', 'B', 'I', n)
     40
     41/**
     42 * @brief Event to signal an unmount process completion.
     43 *
     44 * This event should equal the RTEMS_BDBUF_TRANSFER_SYNC event to avoid too
     45 * many events reserved for the file system.
     46 *
     47 * @see rtems_filesystem_do_unmount() and unmount().
     48 */
     49#define RTEMS_FILESYSTEM_UNMOUNT_EVENT RTEMS_EVENT_1
    4050
    4151extern rtems_id                          rtems_libio_semaphore;
  • cpukit/libcsupport/src/sup_fs_location.c

    r45ada30 r246e23c  
    214214  rtems_filesystem_global_location_release(mt_entry->mt_point_node);
    215215  (*mt_entry->ops->fsunmount_me_h)(mt_entry);
     216
     217  if (mt_entry->unmount_task != 0) {
     218    rtems_status_code sc =
     219      rtems_event_send(mt_entry->unmount_task, RTEMS_FILESYSTEM_UNMOUNT_EVENT);
     220    if (sc != RTEMS_SUCCESSFUL) {
     221      rtems_fatal_error_occurred(0xdeadbeef);
     222    }
     223  }
     224
    216225  free(mt_entry);
    217226}
  • 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}
  • testsuites/fstests/fsrdwr/init.c

    r45ada30 r246e23c  
    257257  n = write (fd, databuf, len);
    258258  rtems_test_assert (n == len);
     259  status = close (fd);
     260  rtems_test_assert (status == 0);
    259261
    260262  /*
     
    263265
    264266  status = truncate (name01, len / 2);
     267  rtems_test_assert (status == 0);
    265268  status = truncate (name01, len);
     269  rtems_test_assert (status == 0);
    266270
    267271  /*
  • testsuites/psxtests/psxmount/psxmount.scn

    r45ada30 r246e23c  
    1 
    2 
    31*** MOUNT/UNMOUNT TEST ***
    42
     
    2624create c/y/my_mount_point/my_dir/d
    2725Verify c/y/my_mount_point/my_dir/d
    28 Attempting to mount IMFS file system at /c/z/my_mount_point
    29 2nd file system successfully mounted at /c/z/my_mount_point
     26Attempting to mount IMFS file system at /c/z/my_mount_point 
     272nd file system successfully mounted at /c/z/my_mount_point 
    3028
    3129chdir to /c/z/my_mount_point.
     
    3432
    3533Creating a series of directories under /c/z/my_mount_point
    36 Creating:                                              a   0 2    Success
    37 Creating:                                              b   0 2    Success
    38 Creating:                                              c   0 2    Success
    39 Creating:                                              d   0 2    Success
    40 Creating:                                              e   0 2    Success
    41 Creating:                                              f   0 2    Success
    42 Creating:                                            c/y   0 2    Success
    43 Creating:                                            c/z   0 2    Success
    44 Creating:                                            c/x   0 2    Success
    45 Creating:                                      c/y/a3333   0 2    Success
    46 Creating:                                       c/y/j123   0 2    Success
    47 Creating:                             c/y/my_mount_point   0 2    Success
    48 Creating:                      c/y/my_mount_point/my_dir   0 2    Success
    49 Creating:                    c/y/my_mount_point/my_dir/d   0 2    Success
    50 Creating:                             c/z/my_mount_point   0 2    Success
    51 Creating: /c/z/my_mount_point/a/../../my_mount_point/a/g   0 2    Success
     34Creating:                                              a   0 0    Success
     35Creating:                                              b   0 0    Success
     36Creating:                                              c   0 0    Success
     37Creating:                                              d   0 0    Success
     38Creating:                                              e   0 0    Success
     39Creating:                                              f   0 0    Success
     40Creating:                                            c/y   0 0    Success
     41Creating:                                            c/z   0 0    Success
     42Creating:                                            c/x   0 0    Success
     43Creating:                                      c/y/a3333   0 0    Success
     44Creating:                                       c/y/j123   0 0    Success
     45Creating:                             c/y/my_mount_point   0 0    Success
     46Creating:                      c/y/my_mount_point/my_dir   0 0    Success
     47Creating:                    c/y/my_mount_point/my_dir/d   0 0    Success
     48Creating:                             c/z/my_mount_point   0 0    Success
     49Creating: /c/z/my_mount_point/a/../../my_mount_point/a/g   0 0    Success
    5250
    5351chdir to /
     
    5755Mount a NULL file system and verify EINVAL
    5856mount with option of -62 should fail with EINVAL
    59 Mount a Read Only filesystem at /c/y/my_mount_point
    60 Read only file system successfully mounted at /c/y/my_mount_point
    61 create c/y/my_mount_point/../../y/my_mount_point/new_dir
     57Mount a Read Only filesystem at /c/y/my_mount_point
     58Read only file system successfully mounted at /c/y/my_mount_point
     59create c/y/my_mount_point/../../y/new_dir
     60Verify a mount point returns EROFS for another mount
     61Unmount /c/y/my_mount_point
     62Mount a read-write file system at /c/y/my_mount_point
    6263Verify a mount point returns EBUSY for another mount
    6364Mount on a file should fail with ENOTDIR
    6465Create and chdir to /c/y/my_mount_point/mydir
    6566unmount of /c/y/my_mount_point should fail with EBUSY
    66 chdir to / and verify we can unmount /c/y/my_mount_point
    67 unmount /c/y/my_mount_point
     67chroot to /c/y/my_mount_point
     68unmount of . should fail with EBUSY
     69chroot to / and verify we can unmount /c/y/my_mount_point
     70unmount of /c/y/my_mount_point
     71chdir to /c/y/my_mount_point/my_dir should fail with ENOENT
    6872unmount /b/mount_point should fail with EINVAL
    6973Mount /c/y/my_mount_point
    7074Create and open /c/y/my_mount_point/my_file
    7175
    72 mkdir /c/y/my_mount_point/my_dir
    73 Open /c/y/my_mount_point/my_dir
    74 Unmount /c/y/my_mount_point should fail with EBUSY
    75 Close /c/y/my_mount_point/my_dir
     76mkdir /c/y/my_mount_point/my_sub_fs_dir
     77open /c/y/my_mount_point/my_sub_fs_dir
     78close /c/y/my_mount_point/my_sub_fs_dir
     79mkdir /c/y/my_mount_point/my_sub_fs_dir should fail with EEXIST
     80unmount /c/y/my_mount_point
     81mkdir /c/y/my_mount_point/my_sub_fs_dir
     82rmdir /c/y/my_mount_point/my_sub_fs_dir
    7683Unmount /c/y/my_mount_point/my_dir should fail with EACCES
    77 Mount a file system at /c/y/my_mount_point/my_dir
    78 unmount /c/y/my_mount_point should fail with EBUSY
     84Mount a file system at /c/y/my_mount_point
    7985Verify a hard link across filesystems fails with EXDEV
    8086Verify a symbolic link across file systems works
    81 unmount /c/y/my_mount_point/my_dir
     87unmount /c/y/my_mount_point
    8288Verify the symbolic link now fails
    83 unmount /c/y/my_mount_point
    8489
    8590
  • testsuites/psxtests/psxmount/test.c

    r45ada30 r246e23c  
    315315  rtems_test_assert( status == 0 );
    316316
     317  printf("unmount of /c/y/my_mount_point should fail with EBUSY\n");
     318  status = unmount( "/c/y/my_mount_point" );
     319  rtems_test_assert( status == -1 );
     320  rtems_test_assert( errno == EBUSY );
     321
     322  status = chdir( "/" );
     323  rtems_test_assert( status == 0 );
     324
     325  printf("chroot to /c/y/my_mount_point\n");
     326  status = chroot( "/c/y/my_mount_point" );
     327  rtems_test_assert( status == 0 );
     328
     329  printf("unmount of . should fail with EBUSY\n");
     330  status = unmount( "." );
     331  rtems_test_assert( status == -1 );
     332  rtems_test_assert( errno == EBUSY );
     333
     334  /*
     335   * Chdir to root and verify we unmounted the file system now.
     336   */
     337
     338  printf("chroot to / and verify we can unmount /c/y/my_mount_point\n");
     339  status = chroot( "/" );
     340  rtems_test_assert( status == 0 );
     341
    317342  printf("unmount of /c/y/my_mount_point\n");
    318343  status = unmount( "/c/y/my_mount_point" );
    319   rtems_test_assert( status == 0 );
    320 
    321   printf("chdir to .. should fail with ENXIO\n");
    322   status = chdir( ".." );
    323   rtems_test_assert( status == -1 );
    324   rtems_test_assert( errno == ENXIO );
    325 
    326   /*
    327    * Chdir to root and verify we unmounted the file system now.
    328    */
    329 
    330   printf("chdir to / and verify we can unmount /c/y/my_mount_point\n");
    331   status = chdir( "/" );
    332344  rtems_test_assert( status == 0 );
    333345
     
    377389  rtems_test_assert( directory );
    378390
     391  printf("close %s\n", my_sub_fs_dir );
     392  status = closedir( directory );
     393  rtems_test_assert( status == 0 );
     394
    379395  printf("mkdir %s should fail with EEXIST\n", my_sub_fs_dir );
    380396  status = mkdir( my_sub_fs_dir, S_IRWXU );
     
    384400  printf("unmount %s\n", mount_point );
    385401  status = unmount( mount_point );
    386   rtems_test_assert( status == 0 );
    387 
    388   printf("close %s\n", my_sub_fs_dir );
    389   status = closedir( directory );
    390402  rtems_test_assert( status == 0 );
    391403
Note: See TracChangeset for help on using the changeset viewer.