Changes in / [246e23c:45ada30] in rtems


Ignore:
Files:
7 edited

Legend:

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

    r246e23c r45ada30  
    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;
    14691462};
    14701463
     
    15211514 * @brief Unmounts the file system at @a mount_path.
    15221515 *
    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.
     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.
    15351519 *
    15361520 * @retval 0 Successful operation.
  • cpukit/libcsupport/include/rtems/libio_.h

    r246e23c r45ada30  
    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
    5040
    5141extern rtems_id                          rtems_libio_semaphore;
  • cpukit/libcsupport/src/sup_fs_location.c

    r246e23c r45ada30  
    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 
    225216  free(mt_entry);
    226217}
  • cpukit/libcsupport/src/unmount.c

    r246e23c r45ada30  
    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}
  • testsuites/fstests/fsrdwr/init.c

    r246e23c r45ada30  
    257257  n = write (fd, databuf, len);
    258258  rtems_test_assert (n == len);
    259   status = close (fd);
    260   rtems_test_assert (status == 0);
    261259
    262260  /*
     
    265263
    266264  status = truncate (name01, len / 2);
    267   rtems_test_assert (status == 0);
    268265  status = truncate (name01, len);
    269   rtems_test_assert (status == 0);
    270266
    271267  /*
  • testsuites/psxtests/psxmount/psxmount.scn

    r246e23c r45ada30  
     1
     2
    13*** MOUNT/UNMOUNT TEST ***
    24
     
    2426create c/y/my_mount_point/my_dir/d
    2527Verify c/y/my_mount_point/my_dir/d
    26 Attempting to mount IMFS file system at /c/z/my_mount_point 
    27 2nd file system successfully mounted at /c/z/my_mount_point 
     28Attempting to mount IMFS file system at /c/z/my_mount_point
     292nd file system successfully mounted at /c/z/my_mount_point
    2830
    2931chdir to /c/z/my_mount_point.
     
    3234
    3335Creating a series of directories under /c/z/my_mount_point
    34 Creating:                                              a   0 0    Success
    35 Creating:                                              b   0 0    Success
    36 Creating:                                              c   0 0    Success
    37 Creating:                                              d   0 0    Success
    38 Creating:                                              e   0 0    Success
    39 Creating:                                              f   0 0    Success
    40 Creating:                                            c/y   0 0    Success
    41 Creating:                                            c/z   0 0    Success
    42 Creating:                                            c/x   0 0    Success
    43 Creating:                                      c/y/a3333   0 0    Success
    44 Creating:                                       c/y/j123   0 0    Success
    45 Creating:                             c/y/my_mount_point   0 0    Success
    46 Creating:                      c/y/my_mount_point/my_dir   0 0    Success
    47 Creating:                    c/y/my_mount_point/my_dir/d   0 0    Success
    48 Creating:                             c/z/my_mount_point   0 0    Success
    49 Creating: /c/z/my_mount_point/a/../../my_mount_point/a/g   0 0    Success
     36Creating:                                              a   0 2    Success
     37Creating:                                              b   0 2    Success
     38Creating:                                              c   0 2    Success
     39Creating:                                              d   0 2    Success
     40Creating:                                              e   0 2    Success
     41Creating:                                              f   0 2    Success
     42Creating:                                            c/y   0 2    Success
     43Creating:                                            c/z   0 2    Success
     44Creating:                                            c/x   0 2    Success
     45Creating:                                      c/y/a3333   0 2    Success
     46Creating:                                       c/y/j123   0 2    Success
     47Creating:                             c/y/my_mount_point   0 2    Success
     48Creating:                      c/y/my_mount_point/my_dir   0 2    Success
     49Creating:                    c/y/my_mount_point/my_dir/d   0 2    Success
     50Creating:                             c/z/my_mount_point   0 2    Success
     51Creating: /c/z/my_mount_point/a/../../my_mount_point/a/g   0 2    Success
    5052
    5153chdir to /
     
    5557Mount a NULL file system and verify EINVAL
    5658mount with option of -62 should fail with EINVAL
    57 Mount a Read Only filesystem at /c/y/my_mount_point
    58 Read only file system successfully mounted at /c/y/my_mount_point
    59 create c/y/my_mount_point/../../y/new_dir
    60 Verify a mount point returns EROFS for another mount
    61 Unmount /c/y/my_mount_point
    62 Mount a read-write file system at /c/y/my_mount_point
     59Mount a Read Only filesystem at /c/y/my_mount_point
     60Read only file system successfully mounted at /c/y/my_mount_point
     61create c/y/my_mount_point/../../y/my_mount_point/new_dir
    6362Verify a mount point returns EBUSY for another mount
    6463Mount on a file should fail with ENOTDIR
    6564Create and chdir to /c/y/my_mount_point/mydir
    6665unmount of /c/y/my_mount_point should fail with EBUSY
    67 chroot to /c/y/my_mount_point
    68 unmount of . should fail with EBUSY
    69 chroot to / and verify we can unmount /c/y/my_mount_point
    70 unmount of /c/y/my_mount_point
    71 chdir to /c/y/my_mount_point/my_dir should fail with ENOENT
     66chdir to / and verify we can unmount /c/y/my_mount_point
     67unmount /c/y/my_mount_point
    7268unmount /b/mount_point should fail with EINVAL
    7369Mount /c/y/my_mount_point
    7470Create and open /c/y/my_mount_point/my_file
    7571
    76 mkdir /c/y/my_mount_point/my_sub_fs_dir
    77 open /c/y/my_mount_point/my_sub_fs_dir
    78 close /c/y/my_mount_point/my_sub_fs_dir
    79 mkdir /c/y/my_mount_point/my_sub_fs_dir should fail with EEXIST
    80 unmount /c/y/my_mount_point
    81 mkdir /c/y/my_mount_point/my_sub_fs_dir
    82 rmdir /c/y/my_mount_point/my_sub_fs_dir
     72mkdir /c/y/my_mount_point/my_dir
     73Open /c/y/my_mount_point/my_dir
     74Unmount /c/y/my_mount_point should fail with EBUSY
     75Close /c/y/my_mount_point/my_dir
    8376Unmount /c/y/my_mount_point/my_dir should fail with EACCES
    84 Mount a file system at /c/y/my_mount_point
     77Mount a file system at /c/y/my_mount_point/my_dir
     78unmount /c/y/my_mount_point should fail with EBUSY
    8579Verify a hard link across filesystems fails with EXDEV
    8680Verify a symbolic link across file systems works
     81unmount /c/y/my_mount_point/my_dir
     82Verify the symbolic link now fails
    8783unmount /c/y/my_mount_point
    88 Verify the symbolic link now fails
    8984
    9085
  • testsuites/psxtests/psxmount/test.c

    r246e23c r45ada30  
    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 
    342317  printf("unmount of /c/y/my_mount_point\n");
    343318  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( "/" );
    344332  rtems_test_assert( status == 0 );
    345333
     
    389377  rtems_test_assert( directory );
    390378
     379  printf("mkdir %s should fail with EEXIST\n", my_sub_fs_dir );
     380  status = mkdir( my_sub_fs_dir, S_IRWXU );
     381  rtems_test_assert( status == -1 );
     382  rtems_test_assert( errno == EEXIST );
     383
     384  printf("unmount %s\n", mount_point );
     385  status = unmount( mount_point );
     386  rtems_test_assert( status == 0 );
     387
    391388  printf("close %s\n", my_sub_fs_dir );
    392389  status = closedir( directory );
    393   rtems_test_assert( status == 0 );
    394 
    395   printf("mkdir %s should fail with EEXIST\n", my_sub_fs_dir );
    396   status = mkdir( my_sub_fs_dir, S_IRWXU );
    397   rtems_test_assert( status == -1 );
    398   rtems_test_assert( errno == EEXIST );
    399 
    400   printf("unmount %s\n", mount_point );
    401   status = unmount( mount_point );
    402390  rtems_test_assert( status == 0 );
    403391
Note: See TracChangeset for help on using the changeset viewer.