Changes in uspace/srv/vfs/vfs_ops.c [27b76ca:5bb9907] in mainline
- File:
-
- 1 edited
-
uspace/srv/vfs/vfs_ops.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_ops.c
r27b76ca r5bb9907 618 618 } 619 619 620 void vfs_open_node(ipc_callid_t rid, ipc_call_t *request) 621 { 622 // FIXME: check for sanity of the supplied fs, dev and index 623 624 /* 625 * The interface is open_node(fs, dev, index, oflag). 626 */ 627 vfs_lookup_res_t lr; 628 629 lr.triplet.fs_handle = IPC_GET_ARG1(*request); 630 lr.triplet.devmap_handle = IPC_GET_ARG2(*request); 631 lr.triplet.index = IPC_GET_ARG3(*request); 632 int oflag = IPC_GET_ARG4(*request); 633 634 fibril_rwlock_read_lock(&namespace_rwlock); 635 636 int rc = vfs_open_node_internal(&lr); 637 if (rc != EOK) { 638 fibril_rwlock_read_unlock(&namespace_rwlock); 639 async_answer_0(rid, rc); 640 return; 641 } 642 643 vfs_node_t *node = vfs_node_get(&lr); 644 fibril_rwlock_read_unlock(&namespace_rwlock); 645 646 /* Truncate the file if requested and if necessary. */ 647 if (oflag & O_TRUNC) { 648 fibril_rwlock_write_lock(&node->contents_rwlock); 649 if (node->size) { 650 rc = vfs_truncate_internal(node->fs_handle, 651 node->devmap_handle, node->index, 0); 652 if (rc) { 653 fibril_rwlock_write_unlock(&node->contents_rwlock); 654 vfs_node_put(node); 655 async_answer_0(rid, rc); 656 return; 657 } 658 node->size = 0; 659 } 660 fibril_rwlock_write_unlock(&node->contents_rwlock); 661 } 662 663 /* 664 * Get ourselves a file descriptor and the corresponding vfs_file_t 665 * structure. 666 */ 667 int fd = vfs_fd_alloc((oflag & O_DESC) != 0); 668 if (fd < 0) { 669 vfs_node_put(node); 670 async_answer_0(rid, fd); 671 return; 672 } 673 vfs_file_t *file = vfs_file_get(fd); 674 file->node = node; 675 if (oflag & O_APPEND) 676 file->append = true; 677 678 /* 679 * The following increase in reference count is for the fact that the 680 * file is being opened and that a file structure is pointing to it. 681 * It is necessary so that the file will not disappear when 682 * vfs_node_put() is called. The reference will be dropped by the 683 * respective VFS_IN_CLOSE. 684 */ 685 vfs_node_addref(node); 686 vfs_node_put(node); 687 vfs_file_put(file); 688 689 /* Success! Return the new file descriptor to the client. */ 690 async_answer_1(rid, EOK, fd); 691 } 692 620 693 void vfs_sync(ipc_callid_t rid, ipc_call_t *request) 621 694 { … … 1276 1349 } 1277 1350 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 1351 /** 1285 1352 * @}
Note:
See TracChangeset
for help on using the changeset viewer.
