Changeset 7fe1f75 in mainline
- Timestamp:
- 2008-02-28T21:30:50Z (17 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- ee68e4bc
- Parents:
- 2c448fb
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/vfs/vfs_ops.c
r2c448fb r7fe1f75 52 52 #include <atomic.h> 53 53 #include "vfs.h" 54 55 /* Forward declarations of static functions. */ 56 static int vfs_truncate_internal(int, int, unsigned long, size_t); 54 57 55 58 /** … … 350 353 } 351 354 352 /* *Path is no longer needed. */355 /* Path is no longer needed. */ 353 356 free(path); 354 357 … … 358 361 else 359 362 rwlock_read_unlock(&namespace_rwlock); 363 364 /* Truncate the file if requested and if necessary. */ 365 if (oflag & O_TRUNC) { 366 futex_down(&node->contents_rwlock); 367 if (node->size) { 368 rc = vfs_truncate_internal(node->fs_handle, 369 node->dev_handle, node->index, 0); 370 if (rc) { 371 futex_up(&node->contents_rwlock); 372 vfs_node_put(node); 373 ipc_answer_0(rid, rc); 374 return; 375 } 376 node->size = 0; 377 } 378 futex_up(&node->contents_rwlock); 379 } 360 380 361 381 /* … … 561 581 } 562 582 583 int vfs_truncate_internal(int fs_handle, int dev_handle, unsigned long index, 584 size_t size) 585 { 586 ipcarg_t rc; 587 int fs_phone; 588 589 fs_phone = vfs_grab_phone(fs_handle); 590 rc = async_req_3_0(fs_phone, VFS_TRUNCATE, (ipcarg_t)dev_handle, 591 (ipcarg_t)index, (ipcarg_t)size); 592 vfs_release_phone(fs_phone); 593 return (int)rc; 594 } 595 563 596 void vfs_truncate(ipc_callid_t rid, ipc_call_t *request) 564 597 { 565 598 int fd = IPC_GET_ARG1(*request); 566 599 size_t size = IPC_GET_ARG2(*request); 567 i pcarg_t rc;600 int rc; 568 601 569 602 vfs_file_t *file = vfs_file_get(fd); … … 575 608 576 609 rwlock_write_lock(&file->node->contents_rwlock); 577 int fs_phone = vfs_grab_phone(file->node->fs_handle); 578 rc = async_req_3_0(fs_phone, VFS_TRUNCATE, 579 (ipcarg_t)file->node->dev_handle, (ipcarg_t)file->node->index, 580 (ipcarg_t)size); 581 vfs_release_phone(fs_phone); 610 rc = vfs_truncate_internal(file->node->fs_handle, 611 file->node->dev_handle, file->node->index, size); 582 612 if (rc == EOK) 583 613 file->node->size = size; … … 585 615 586 616 futex_up(&file->lock); 587 ipc_answer_0(rid, rc);617 ipc_answer_0(rid, (ipcarg_t)rc); 588 618 } 589 619
Note:
See TracChangeset
for help on using the changeset viewer.