Changes in uspace/srv/vfs/vfs_ops.c [27b76ca:b72efe8] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_ops.c
r27b76ca rb72efe8 76 76 vfs_node_t *mr_node; 77 77 fs_index_t rindex; 78 aoff64_t rsize;78 size_t rsize; 79 79 unsigned rlnkcnt; 80 80 async_exch_t *exch; … … 146 146 147 147 rindex = (fs_index_t) IPC_GET_ARG1(answer); 148 rsize = ( aoff64_t) MERGE_LOUP32(IPC_GET_ARG2(answer), IPC_GET_ARG3(answer));149 rlnkcnt = (unsigned) IPC_GET_ARG 4(answer);148 rsize = (size_t) IPC_GET_ARG2(answer); 149 rlnkcnt = (unsigned) IPC_GET_ARG3(answer); 150 150 151 151 mr_res.triplet.fs_handle = fs_handle; … … 229 229 if (rc == EOK) { 230 230 rindex = (fs_index_t) IPC_GET_ARG1(answer); 231 rsize = (aoff64_t) MERGE_LOUP32(IPC_GET_ARG2(answer), 232 IPC_GET_ARG3(answer)); 233 rlnkcnt = (unsigned) IPC_GET_ARG4(answer); 231 rsize = (size_t) IPC_GET_ARG2(answer); 232 rlnkcnt = (unsigned) IPC_GET_ARG3(answer); 234 233 235 234 mr_res.triplet.fs_handle = fs_handle; … … 618 617 } 619 618 619 void vfs_open_node(ipc_callid_t rid, ipc_call_t *request) 620 { 621 // FIXME: check for sanity of the supplied fs, dev and index 622 623 /* 624 * The interface is open_node(fs, dev, index, oflag). 625 */ 626 vfs_lookup_res_t lr; 627 628 lr.triplet.fs_handle = IPC_GET_ARG1(*request); 629 lr.triplet.devmap_handle = IPC_GET_ARG2(*request); 630 lr.triplet.index = IPC_GET_ARG3(*request); 631 int oflag = IPC_GET_ARG4(*request); 632 633 fibril_rwlock_read_lock(&namespace_rwlock); 634 635 int rc = vfs_open_node_internal(&lr); 636 if (rc != EOK) { 637 fibril_rwlock_read_unlock(&namespace_rwlock); 638 async_answer_0(rid, rc); 639 return; 640 } 641 642 vfs_node_t *node = vfs_node_get(&lr); 643 fibril_rwlock_read_unlock(&namespace_rwlock); 644 645 /* Truncate the file if requested and if necessary. */ 646 if (oflag & O_TRUNC) { 647 fibril_rwlock_write_lock(&node->contents_rwlock); 648 if (node->size) { 649 rc = vfs_truncate_internal(node->fs_handle, 650 node->devmap_handle, node->index, 0); 651 if (rc) { 652 fibril_rwlock_write_unlock(&node->contents_rwlock); 653 vfs_node_put(node); 654 async_answer_0(rid, rc); 655 return; 656 } 657 node->size = 0; 658 } 659 fibril_rwlock_write_unlock(&node->contents_rwlock); 660 } 661 662 /* 663 * Get ourselves a file descriptor and the corresponding vfs_file_t 664 * structure. 665 */ 666 int fd = vfs_fd_alloc((oflag & O_DESC) != 0); 667 if (fd < 0) { 668 vfs_node_put(node); 669 async_answer_0(rid, fd); 670 return; 671 } 672 vfs_file_t *file = vfs_file_get(fd); 673 file->node = node; 674 if (oflag & O_APPEND) 675 file->append = true; 676 677 /* 678 * The following increase in reference count is for the fact that the 679 * file is being opened and that a file structure is pointing to it. 680 * It is necessary so that the file will not disappear when 681 * vfs_node_put() is called. The reference will be dropped by the 682 * respective VFS_IN_CLOSE. 683 */ 684 vfs_node_addref(node); 685 vfs_node_put(node); 686 vfs_file_put(file); 687 688 /* Success! Return the new file descriptor to the client. */ 689 async_answer_1(rid, EOK, fd); 690 } 691 620 692 void vfs_sync(ipc_callid_t rid, ipc_call_t *request) 621 693 { … … 723 795 ipc_call_t answer; 724 796 if (read) { 725 rc = async_data_read_forward_ 4_1(fs_exch, VFS_OUT_READ,726 file->node->devmap_handle, file->node->index, 727 LOWER32(file->pos), UPPER32(file->pos),&answer);797 rc = async_data_read_forward_3_1(fs_exch, VFS_OUT_READ, 798 file->node->devmap_handle, file->node->index, file->pos, 799 &answer); 728 800 } else { 729 801 if (file->append) 730 802 file->pos = file->node->size; 731 803 732 rc = async_data_write_forward_ 4_1(fs_exch, VFS_OUT_WRITE,733 file->node->devmap_handle, file->node->index, 734 LOWER32(file->pos), UPPER32(file->pos),&answer);804 rc = async_data_write_forward_3_1(fs_exch, VFS_OUT_WRITE, 805 file->node->devmap_handle, file->node->index, file->pos, 806 &answer); 735 807 } 736 808 … … 749 821 /* Update the cached version of node's size. */ 750 822 if (rc == EOK) 751 file->node->size = MERGE_LOUP32(IPC_GET_ARG2(answer), 752 IPC_GET_ARG3(answer)); 823 file->node->size = IPC_GET_ARG2(answer); 753 824 fibril_rwlock_write_unlock(&file->node->contents_rwlock); 754 825 } … … 1276 1347 } 1277 1348 1278 void vfs_wait_handle(ipc_callid_t rid, ipc_call_t *request)1279 {1280 int fd = vfs_wait_handle_internal();1281 async_answer_1(rid, EOK, fd);1282 }1283 1284 1349 /** 1285 1350 * @}
Note:
See TracChangeset
for help on using the changeset viewer.