Changeset ee1b8ca in mainline for uspace/srv/fs/tmpfs/tmpfs_ops.c
- Timestamp:
- 2007-12-25T20:02:25Z (18 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- c1bf5cb
- Parents:
- 1356a04c
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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 * @}
Note:
See TracChangeset
for help on using the changeset viewer.