Changeset 06256b0 in mainline
- Timestamp:
- 2013-07-30T23:46:26Z (11 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- b8dbe2f
- Parents:
- 4636a60
- Location:
- uspace/lib
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/lib/c/include/ipc/vfs.h
r4636a60 r06256b0 90 90 VFS_OUT_TRUNCATE, 91 91 VFS_OUT_CLOSE, 92 VFS_OUT_MOUNT,93 92 VFS_OUT_MOUNTED, 94 VFS_OUT_UNMOUNT,95 93 VFS_OUT_UNMOUNTED, 96 94 VFS_OUT_GET_SIZE, -
uspace/lib/fs/libfs.c
r4636a60 r06256b0 72 72 static libfs_ops_t *libfs_ops = NULL; 73 73 74 static void libfs_mount(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *);75 static void libfs_unmount(libfs_ops_t *, ipc_callid_t, ipc_call_t *);76 74 static void libfs_link(libfs_ops_t *, fs_handle_t, ipc_callid_t, 77 75 ipc_call_t *); … … 109 107 } 110 108 111 static void vfs_out_mount(ipc_callid_t rid, ipc_call_t *req)112 {113 libfs_mount(libfs_ops, reg.fs_handle, rid, req);114 }115 116 109 static void vfs_out_unmounted(ipc_callid_t rid, ipc_call_t *req) 117 110 { … … 122 115 123 116 async_answer_0(rid, rc); 124 }125 126 static void vfs_out_unmount(ipc_callid_t rid, ipc_call_t *req)127 {128 129 libfs_unmount(libfs_ops, rid, req);130 117 } 131 118 … … 306 293 vfs_out_mounted(callid, &call); 307 294 break; 308 case VFS_OUT_MOUNT:309 vfs_out_mount(callid, &call);310 break;311 295 case VFS_OUT_UNMOUNTED: 312 296 vfs_out_unmounted(callid, &call); 313 break;314 case VFS_OUT_UNMOUNT:315 vfs_out_unmount(callid, &call);316 297 break; 317 298 case VFS_OUT_LINK: … … 446 427 } 447 428 448 void libfs_mount(libfs_ops_t *ops, fs_handle_t fs_handle, ipc_callid_t rid,449 ipc_call_t *req)450 {451 service_id_t mp_service_id = (service_id_t) IPC_GET_ARG1(*req);452 fs_index_t mp_fs_index = (fs_index_t) IPC_GET_ARG2(*req);453 fs_handle_t mr_fs_handle = (fs_handle_t) IPC_GET_ARG3(*req);454 service_id_t mr_service_id = (service_id_t) IPC_GET_ARG4(*req);455 456 async_sess_t *mountee_sess = async_clone_receive(EXCHANGE_PARALLEL);457 if (mountee_sess == NULL) {458 async_answer_0(rid, EINVAL);459 return;460 }461 462 fs_node_t *fn;463 int res = ops->node_get(&fn, mp_service_id, mp_fs_index);464 if ((res != EOK) || (!fn)) {465 async_hangup(mountee_sess);466 async_data_write_void(combine_rc(res, ENOENT));467 async_answer_0(rid, combine_rc(res, ENOENT));468 return;469 }470 471 if (fn->mp_data.mp_active) {472 async_hangup(mountee_sess);473 (void) ops->node_put(fn);474 async_data_write_void(EBUSY);475 async_answer_0(rid, EBUSY);476 return;477 }478 479 async_exch_t *exch = async_exchange_begin(mountee_sess);480 async_sess_t *sess = async_clone_establish(EXCHANGE_PARALLEL, exch);481 482 if (!sess) {483 async_exchange_end(exch);484 async_hangup(mountee_sess);485 (void) ops->node_put(fn);486 async_data_write_void(errno);487 async_answer_0(rid, errno);488 return;489 }490 491 ipc_call_t answer;492 int rc = async_data_write_forward_1_1(exch, VFS_OUT_MOUNTED,493 mr_service_id, &answer);494 async_exchange_end(exch);495 496 if (rc == EOK) {497 fn->mp_data.mp_active = true;498 fn->mp_data.fs_handle = mr_fs_handle;499 fn->mp_data.service_id = mr_service_id;500 fn->mp_data.sess = mountee_sess;501 }502 503 /*504 * Do not release the FS node so that it stays in memory.505 */506 async_answer_4(rid, rc, IPC_GET_ARG1(answer), IPC_GET_ARG2(answer),507 IPC_GET_ARG3(answer), IPC_GET_ARG4(answer));508 }509 510 void libfs_unmount(libfs_ops_t *ops, ipc_callid_t rid, ipc_call_t *req)511 {512 service_id_t mp_service_id = (service_id_t) IPC_GET_ARG1(*req);513 fs_index_t mp_fs_index = (fs_index_t) IPC_GET_ARG2(*req);514 fs_node_t *fn;515 int res;516 517 res = ops->node_get(&fn, mp_service_id, mp_fs_index);518 if ((res != EOK) || (!fn)) {519 async_answer_0(rid, combine_rc(res, ENOENT));520 return;521 }522 523 /*524 * We are clearly expecting to find the mount point active.525 */526 if (!fn->mp_data.mp_active) {527 (void) ops->node_put(fn);528 async_answer_0(rid, EINVAL);529 return;530 }531 532 /*533 * Tell the mounted file system to unmount.534 */535 async_exch_t *exch = async_exchange_begin(fn->mp_data.sess);536 res = async_req_1_0(exch, VFS_OUT_UNMOUNTED, fn->mp_data.service_id);537 async_exchange_end(exch);538 539 /*540 * If everything went well, perform the clean-up on our side.541 */542 if (res == EOK) {543 async_hangup(fn->mp_data.sess);544 fn->mp_data.mp_active = false;545 fn->mp_data.fs_handle = 0;546 fn->mp_data.service_id = 0;547 fn->mp_data.sess = NULL;548 549 /* Drop the reference created in libfs_mount(). */550 (void) ops->node_put(fn);551 }552 553 (void) ops->node_put(fn);554 async_answer_0(rid, res);555 }556 557 429 static char plb_get_char(unsigned pos) 558 430 { … … 662 534 int lflag = IPC_GET_ARG5(*req); 663 535 536 assert((int) index != -1); 537 664 538 DPRINTF("Entered libfs_lookup()\n"); 665 539 … … 677 551 unsigned clen = 0; 678 552 679 if (index == (fs_index_t)-1) { 680 rc = ops->root_get(&cur, service_id); 681 } else { 682 rc = ops->node_get(&cur, service_id, index); 683 } 553 rc = ops->node_get(&cur, service_id, index); 684 554 if (rc != EOK) { 685 555 async_answer_0(rid, rc); … … 689 559 690 560 assert(cur != NULL); 691 692 if (cur->mp_data.mp_active) {693 if (lflag & L_DISABLE_MOUNTS) {694 async_answer_0(rid, EXDEV);695 LOG_EXIT(EXDEV);696 goto out;697 }698 699 async_exch_t *exch = async_exchange_begin(cur->mp_data.sess);700 async_forward_slow(rid, exch, VFS_OUT_LOOKUP, next, last - next,701 cur->mp_data.service_id, (fs_index_t) -1, lflag, IPC_FF_ROUTE_FROM_ME);702 async_exchange_end(exch);703 704 (void) ops->node_put(cur);705 DPRINTF("Passing to another filesystem instance.\n");706 return;707 }708 561 709 562 /* Find the file and its parent. */ … … 745 598 async_answer_0(rid, rc); 746 599 LOG_EXIT(rc); 747 goto out;748 }749 750 /*751 * If the matching component is a mount point, there are two752 * legitimate semantics of the lookup operation. The first is753 * the commonly used one in which the lookup crosses each mount754 * point into the mounted file system. The second semantics is755 * used mostly during unmount() and differs from the first one756 * only in that the last mount point in the looked up path,757 * which is also its last component, is not crossed.758 */759 760 if ((tmp) && (tmp->mp_data.mp_active) &&761 (!(lflag & L_MP) || (next < last))) {762 763 if (lflag & L_DISABLE_MOUNTS) {764 async_answer_0(rid, EXDEV);765 LOG_EXIT(EXDEV);766 goto out;767 }768 769 async_exch_t *exch = async_exchange_begin(tmp->mp_data.sess);770 async_forward_slow(rid, exch, VFS_OUT_LOOKUP, next,771 last - next, tmp->mp_data.service_id, (fs_index_t) -1, lflag,772 IPC_FF_ROUTE_FROM_ME);773 async_exchange_end(exch);774 DPRINTF("Passing to another filesystem instance.\n");775 600 goto out; 776 601 } … … 884 709 ops->index_get(par), last_next, -1, VFS_NODE_DIRECTORY); 885 710 LOG_EXIT(EOK); 886 /*887 async_answer_0(rid, ENOENT);888 LOG_EXIT(ENOENT);889 */890 711 goto out; 891 712 } -
uspace/lib/fs/libfs.h
r4636a60 r06256b0 56 56 57 57 typedef struct { 58 bool mp_active;59 async_sess_t *sess;60 fs_handle_t fs_handle;61 service_id_t service_id;62 } mp_data_t;63 64 typedef struct {65 mp_data_t mp_data; /**< Mount point info. */66 58 void *data; /**< Data of the file system implementation. */ 67 59 } fs_node_t;
Note:
See TracChangeset
for help on using the changeset viewer.