Changeset 246e23c in rtems
- Timestamp:
- 05/29/12 10:26:45 (11 years ago)
- 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. - Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
cpukit/libcsupport/include/rtems/libio.h
r45ada30 r246e23c 1460 1460 */ 1461 1461 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; 1462 1469 }; 1463 1470 … … 1514 1521 * @brief Unmounts the file system at @a mount_path. 1515 1522 * 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. 1519 1535 * 1520 1536 * @retval 0 Successful operation. -
cpukit/libcsupport/include/rtems/libio_.h
r45ada30 r246e23c 38 38 #define RTEMS_LIBIO_SEM rtems_build_name('L', 'B', 'I', 'O') 39 39 #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 40 50 41 51 extern rtems_id rtems_libio_semaphore; -
cpukit/libcsupport/src/sup_fs_location.c
r45ada30 r246e23c 214 214 rtems_filesystem_global_location_release(mt_entry->mt_point_node); 215 215 (*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 216 225 free(mt_entry); 217 226 } -
cpukit/libcsupport/src/unmount.c
r45ada30 r246e23c 23 23 #include <rtems/libio_.h> 24 24 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 25 37 int unmount( const char *path ) 26 38 { … … 33 45 34 46 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; 37 50 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 ); 41 55 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; 45 64 } 46 65 } else { … … 51 70 rtems_filesystem_eval_path_cleanup( &ctx ); 52 71 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 53 86 return rv; 54 87 } -
testsuites/fstests/fsrdwr/init.c
r45ada30 r246e23c 257 257 n = write (fd, databuf, len); 258 258 rtems_test_assert (n == len); 259 status = close (fd); 260 rtems_test_assert (status == 0); 259 261 260 262 /* … … 263 265 264 266 status = truncate (name01, len / 2); 267 rtems_test_assert (status == 0); 265 268 status = truncate (name01, len); 269 rtems_test_assert (status == 0); 266 270 267 271 /* -
testsuites/psxtests/psxmount/psxmount.scn
r45ada30 r246e23c 1 2 3 1 *** MOUNT/UNMOUNT TEST *** 4 2 … … 26 24 create c/y/my_mount_point/my_dir/d 27 25 Verify 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 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 30 28 31 29 chdir to /c/z/my_mount_point. … … 34 32 35 33 Creating a series of directories under /c/z/my_mount_point 36 Creating: a 0 2Success37 Creating: b 0 2Success38 Creating: c 0 2Success39 Creating: d 0 2Success40 Creating: e 0 2Success41 Creating: f 0 2Success42 Creating: c/y 0 2Success43 Creating: c/z 0 2Success44 Creating: c/x 0 2Success45 Creating: c/y/a3333 0 2Success46 Creating: c/y/j123 0 2Success47 Creating: c/y/my_mount_point 0 2Success48 Creating: c/y/my_mount_point/my_dir 0 2Success49 Creating: c/y/my_mount_point/my_dir/d 0 2Success50 Creating: c/z/my_mount_point 0 2Success51 Creating: /c/z/my_mount_point/a/../../my_mount_point/a/g 0 2Success34 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 52 50 53 51 chdir to / … … 57 55 Mount a NULL file system and verify EINVAL 58 56 mount 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 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 62 63 Verify a mount point returns EBUSY for another mount 63 64 Mount on a file should fail with ENOTDIR 64 65 Create and chdir to /c/y/my_mount_point/mydir 65 66 unmount 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 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 68 72 unmount /b/mount_point should fail with EINVAL 69 73 Mount /c/y/my_mount_point 70 74 Create and open /c/y/my_mount_point/my_file 71 75 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 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 76 83 Unmount /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 84 Mount a file system at /c/y/my_mount_point 79 85 Verify a hard link across filesystems fails with EXDEV 80 86 Verify a symbolic link across file systems works 81 unmount /c/y/my_mount_point /my_dir87 unmount /c/y/my_mount_point 82 88 Verify the symbolic link now fails 83 unmount /c/y/my_mount_point84 89 85 90 -
testsuites/psxtests/psxmount/test.c
r45ada30 r246e23c 315 315 rtems_test_assert( status == 0 ); 316 316 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 317 342 printf("unmount of /c/y/my_mount_point\n"); 318 343 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( "/" );332 344 rtems_test_assert( status == 0 ); 333 345 … … 377 389 rtems_test_assert( directory ); 378 390 391 printf("close %s\n", my_sub_fs_dir ); 392 status = closedir( directory ); 393 rtems_test_assert( status == 0 ); 394 379 395 printf("mkdir %s should fail with EEXIST\n", my_sub_fs_dir ); 380 396 status = mkdir( my_sub_fs_dir, S_IRWXU ); … … 384 400 printf("unmount %s\n", mount_point ); 385 401 status = unmount( mount_point ); 386 rtems_test_assert( status == 0 );387 388 printf("close %s\n", my_sub_fs_dir );389 status = closedir( directory );390 402 rtems_test_assert( status == 0 ); 391 403
Note: See TracChangeset
for help on using the changeset viewer.