Changeset ee1b8ca in mainline
- Timestamp:
- 2007-12-25T20:02:25Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c1bf5cb
- Parents:
- 1356a04c
- Location:
- uspace/srv
- Files:
-
- 5 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/tmpfs/tmpfs.h
r1356a04c ree1b8ca 63 63 extern void tmpfs_lookup(ipc_callid_t, ipc_call_t *); 64 64 extern void tmpfs_read(ipc_callid_t, ipc_call_t *); 65 extern void tmpfs_write(ipc_callid_t, ipc_call_t *); 65 66 66 67 #endif -
uspace/srv/fs/tmpfs/tmpfs_ops.c
r1356a04c ree1b8ca 316 316 } 317 317 318 void tmpfs_write(ipc_callid_t rid, ipc_call_t *request) 319 { 320 int dev_handle = IPC_GET_ARG1(*request); 321 unsigned long index = IPC_GET_ARG2(*request); 322 off_t pos = IPC_GET_ARG3(*request); 323 324 /* 325 * Lookup the respective dentry. 326 */ 327 link_t *hlp; 328 hlp = hash_table_find(&dentries, &index); 329 if (!hlp) { 330 ipc_answer_0(rid, ENOENT); 331 return; 332 } 333 tmpfs_dentry_t *dentry = hash_table_get_instance(hlp, tmpfs_dentry_t, 334 dh_link); 335 336 /* 337 * Receive the write request. 338 */ 339 ipc_callid_t callid; 340 size_t size; 341 if (!ipc_data_write_receive(&callid, NULL, &size)) { 342 ipc_answer_0(callid, EINVAL); 343 ipc_answer_0(rid, EINVAL); 344 return; 345 } 346 347 /* 348 * At this point, we are deliberately extremely straightforward and 349 * simply realloc the contents of the file on every write. In the end, 350 * the situation might not be as bad as it may look: our heap allocator 351 * can save us and just grow the block whenever possible. 352 */ 353 void *newdata = realloc(dentry->data, size); 354 if (!newdata) { 355 ipc_answer_0(callid, ENOMEM); 356 ipc_answer_1(rid, EOK, 0); 357 return; 358 } 359 dentry->size = size; 360 dentry->data = newdata; 361 (void) ipc_data_write_deliver(callid, dentry->data + pos, size); 362 363 /* 364 * Answer the VFS_WRITE call. 365 */ 366 ipc_answer_1(rid, EOK, size); 367 } 368 318 369 /** 319 370 * @} -
uspace/srv/vfs/Makefile
r1356a04c ree1b8ca 49 49 vfs_mount.c \ 50 50 vfs_open.c \ 51 vfs_r ead.c \51 vfs_rdwr.c \ 52 52 vfs_unlink.c 53 53 -
uspace/srv/vfs/vfs.c
r1356a04c ree1b8ca 97 97 vfs_read(callid, &call); 98 98 break; 99 case VFS_WRITE: 100 vfs_write(callid, &call); 101 break; 99 102 case VFS_UNMOUNT: 100 103 case VFS_CREATE: 101 104 case VFS_CLOSE: 102 case VFS_WRITE:103 105 case VFS_SEEK: 104 106 case VFS_UNLINK: -
uspace/srv/vfs/vfs.h
r1356a04c ree1b8ca 200 200 extern void vfs_open(ipc_callid_t, ipc_call_t *); 201 201 extern void vfs_read(ipc_callid_t, ipc_call_t *); 202 extern void vfs_write(ipc_callid_t, ipc_call_t *); 202 203 203 204 #endif -
uspace/srv/vfs/vfs_rdwr.c
r1356a04c ree1b8ca 32 32 33 33 /** 34 * @file vfs_r ead.c34 * @file vfs_rdwr.c 35 35 * @brief 36 36 */ … … 41 41 #include <errno.h> 42 42 43 void vfs_read(ipc_callid_t rid, ipc_call_t *request)43 static void vfs_rdwr(ipc_callid_t rid, ipc_call_t *request, bool read) 44 44 { 45 45 … … 66 66 67 67 /* 68 * Now we need to receive a call with client's IPC_M_DATA_READ request. 68 * Now we need to receive a call with client's 69 * IPC_M_DATA_READ/IPC_M_DATA_WRITE request. 69 70 */ 70 71 ipc_callid_t callid; 71 if (!ipc_data_read_receive(&callid, NULL)) { 72 int res; 73 if (read) 74 res = ipc_data_read_receive(&callid, NULL); 75 else 76 res = ipc_data_write_receive(&callid, NULL, NULL); 77 if (!res) { 72 78 ipc_answer_0(callid, EINVAL); 73 79 ipc_answer_0(rid, EINVAL); … … 78 84 79 85 /* 80 * Make a VFS_READ request at the destination FS server.86 * Make a VFS_READ/VFS_WRITE request at the destination FS server. 81 87 */ 82 88 aid_t msg; 83 89 ipc_call_t answer; 84 msg = async_send_3(fs_phone, VFS_READ, file->node->dev_handle,85 file->node-> index, file->pos, &answer);90 msg = async_send_3(fs_phone, IPC_GET_METHOD(*request), 91 file->node->dev_handle, file->node->index, file->pos, &answer); 86 92 87 93 /* 88 * Forward the IPC_M_DATA_READ request to the destination FS server. 89 * The call will be routed as if sent by ourselves. Note that call 90 * arguments are immutable in this case so we don't have to bother. 94 * Forward the IPC_M_DATA_READ/IPC_M_DATA_WRITE request to the 95 * destination FS server. The call will be routed as if sent by 96 * ourselves. Note that call arguments are immutable in this case so we 97 * don't have to bother. 91 98 */ 92 99 ipc_forward_fast(callid, fs_phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME); … … 113 120 } 114 121 122 123 void vfs_read(ipc_callid_t rid, ipc_call_t *request) 124 { 125 vfs_rdwr(rid, request, true); 126 } 127 128 void vfs_write(ipc_callid_t rid, ipc_call_t *request) 129 { 130 vfs_rdwr(rid, request, false); 131 } 132 115 133 /** 116 134 * @}
Note:
See TracChangeset
for help on using the changeset viewer.