Changeset 42a619b in mainline for uspace/srv/vfs/vfs_ops.c
- Timestamp:
- 2011-08-19T08:58:50Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 7dcb7981, 903bac0a, c2cf033
- Parents:
- ef7052ec (diff), d894fbd (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. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_ops.c
ref7052ec r42a619b 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 index623 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.service_id = 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->service_id, 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_t665 * 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 the680 * file is being opened and that a file structure is pointing to it.681 * It is necessary so that the file will not disappear when682 * vfs_node_put() is called. The reference will be dropped by the683 * 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 693 620 void vfs_sync(ipc_callid_t rid, ipc_call_t *request) 694 621 { … … 1349 1276 } 1350 1277 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 1351 1284 /** 1352 1285 * @}
Note:
See TracChangeset
for help on using the changeset viewer.