Changeset b33ec43 in mainline
- Timestamp:
- 2011-08-18T12:10:23Z (14 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 27b76ca
- Parents:
- 7171760
- Location:
- uspace
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified uspace/lib/c/include/ipc/vfs.h ¶
r7171760 rb33ec43 62 62 typedef enum { 63 63 VFS_IN_OPEN = IPC_FIRST_USER_METHOD, 64 VFS_IN_OPEN_NODE,65 64 VFS_IN_READ, 66 65 VFS_IN_WRITE, … … 82 81 83 82 typedef enum { 84 VFS_OUT_OPEN_NODE = IPC_FIRST_USER_METHOD, 85 VFS_OUT_READ, 83 VFS_OUT_READ = IPC_FIRST_USER_METHOD, 86 84 VFS_OUT_WRITE, 87 85 VFS_OUT_TRUNCATE, -
TabularUnified uspace/lib/fs/libfs.c ¶
r7171760 rb33ec43 72 72 ipc_call_t *); 73 73 static void libfs_stat(libfs_ops_t *, fs_handle_t, ipc_callid_t, ipc_call_t *); 74 static void libfs_open_node(libfs_ops_t *, fs_handle_t, ipc_callid_t,75 ipc_call_t *);76 74 77 75 static void vfs_out_mounted(ipc_callid_t rid, ipc_call_t *req) … … 198 196 } 199 197 200 static void vfs_out_open_node(ipc_callid_t rid, ipc_call_t *req)201 {202 libfs_open_node(libfs_ops, reg.fs_handle, rid, req);203 }204 205 198 static void vfs_out_stat(ipc_callid_t rid, ipc_call_t *req) 206 199 { … … 267 260 case VFS_OUT_DESTROY: 268 261 vfs_out_destroy(callid, &call); 269 break;270 case VFS_OUT_OPEN_NODE:271 vfs_out_open_node(callid, &call);272 262 break; 273 263 case VFS_OUT_STAT: … … 845 835 } 846 836 847 /** Open VFS triplet.848 *849 * @param ops libfs operations structure with function pointers to850 * file system implementation851 * @param rid Request ID of the VFS_OUT_OPEN_NODE request.852 * @param request VFS_OUT_OPEN_NODE request data itself.853 *854 */855 void libfs_open_node(libfs_ops_t *ops, fs_handle_t fs_handle, ipc_callid_t rid,856 ipc_call_t *request)857 {858 devmap_handle_t devmap_handle = IPC_GET_ARG1(*request);859 fs_index_t index = IPC_GET_ARG2(*request);860 861 fs_node_t *fn;862 int rc = ops->node_get(&fn, devmap_handle, index);863 on_error(rc, answer_and_return(rid, rc));864 865 if (fn == NULL) {866 async_answer_0(rid, ENOENT);867 return;868 }869 870 rc = ops->node_open(fn);871 aoff64_t size = ops->size_get(fn);872 async_answer_4(rid, rc, LOWER32(size), UPPER32(size),873 ops->lnkcnt_get(fn),874 (ops->is_file(fn) ? L_FILE : 0) | (ops->is_directory(fn) ? L_DIRECTORY : 0));875 876 (void) ops->node_put(fn);877 }878 879 837 /** @} 880 838 */ -
TabularUnified uspace/srv/vfs/vfs.c ¶
r7171760 rb33ec43 83 83 vfs_open(callid, &call); 84 84 break; 85 case VFS_IN_OPEN_NODE:86 vfs_open_node(callid, &call);87 break;88 85 case VFS_IN_CLOSE: 89 86 vfs_close(callid, &call); -
TabularUnified uspace/srv/vfs/vfs.h ¶
r7171760 rb33ec43 175 175 extern int vfs_lookup_internal(char *, int, vfs_lookup_res_t *, 176 176 vfs_pair_t *, ...); 177 extern int vfs_open_node_internal(vfs_lookup_res_t *);178 177 179 178 extern bool vfs_nodes_init(void); … … 204 203 extern void vfs_unmount(ipc_callid_t, ipc_call_t *); 205 204 extern void vfs_open(ipc_callid_t, ipc_call_t *); 206 extern void vfs_open_node(ipc_callid_t, ipc_call_t *);207 205 extern void vfs_sync(ipc_callid_t, ipc_call_t *); 208 206 extern void vfs_dup(ipc_callid_t, ipc_call_t *); -
TabularUnified uspace/srv/vfs/vfs_lookup.c ¶
r7171760 rb33ec43 201 201 } 202 202 203 /** Perform a node open operation.204 *205 * @return EOK on success or an error code from errno.h.206 *207 */208 int vfs_open_node_internal(vfs_lookup_res_t *result)209 {210 async_exch_t *exch = vfs_exchange_grab(result->triplet.fs_handle);211 212 ipc_call_t answer;213 aid_t req = async_send_2(exch, VFS_OUT_OPEN_NODE,214 (sysarg_t) result->triplet.devmap_handle,215 (sysarg_t) result->triplet.index, &answer);216 217 sysarg_t rc;218 async_wait_for(req, &rc);219 vfs_exchange_release(exch);220 221 if (rc == EOK) {222 result->size =223 MERGE_LOUP32(IPC_GET_ARG1(answer), IPC_GET_ARG2(answer));224 result->lnkcnt = (unsigned int) IPC_GET_ARG3(answer);225 if (IPC_GET_ARG4(answer) & L_FILE)226 result->type = VFS_NODE_FILE;227 else if (IPC_GET_ARG4(answer) & L_DIRECTORY)228 result->type = VFS_NODE_DIRECTORY;229 else230 result->type = VFS_NODE_UNKNOWN;231 }232 233 return rc;234 }235 236 203 /** 237 204 * @} -
TabularUnified uspace/srv/vfs/vfs_ops.c ¶
r7171760 rb33ec43 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.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_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 {
Note:
See TracChangeset
for help on using the changeset viewer.