Changeset 0ee4322 in mainline for uspace/srv/fs/tmpfs/tmpfs_ops.c
- Timestamp:
- 2008-01-13T13:19:37Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- d0dc74ae
- Parents:
- 4fb6bf36
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/fs/tmpfs/tmpfs_ops.c
r4fb6bf36 r0ee4322 369 369 return; 370 370 } 371 /* Clear any newly allocated memory in order to emulate gaps. 371 /* Clear any newly allocated memory in order to emulate gaps. */ 372 372 memset(newdata + dentry->size, 0, delta); 373 373 dentry->size += delta; … … 377 377 } 378 378 379 void tmpfs_truncate(ipc_callid_t rid, ipc_call_t *request) 380 { 381 int dev_handle = IPC_GET_ARG1(*request); 382 unsigned long index = IPC_GET_ARG2(*request); 383 size_t size = IPC_GET_ARG3(*request); 384 385 /* 386 * Lookup the respective dentry. 387 */ 388 link_t *hlp; 389 hlp = hash_table_find(&dentries, &index); 390 if (!hlp) { 391 ipc_answer_0(rid, ENOENT); 392 return; 393 } 394 tmpfs_dentry_t *dentry = hash_table_get_instance(hlp, tmpfs_dentry_t, 395 dh_link); 396 397 if (size == dentry->size) { 398 ipc_answer_0(rid, EOK); 399 return; 400 } 401 402 void *newdata = realloc(dentry->data, size); 403 if (!newdata) { 404 ipc_answer_0(rid, ENOMEM); 405 return; 406 } 407 if (size > dentry->size) { 408 size_t delta = size - dentry->size; 409 memset(newdata + dentry->size, 0, delta); 410 } 411 dentry->size = size; 412 dentry->data = newdata; 413 ipc_answer_0(rid, EOK); 414 } 415 379 416 /** 380 417 * @}
Note:
See TracChangeset
for help on using the changeset viewer.