Subversion Repositories HelenOS

Rev

Rev 2691 | Rev 2698 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 2691 Rev 2693
Line 687... Line 687...
687
    }
687
    }
688
    futex_up(&file->lock);
688
    futex_up(&file->lock);
689
    ipc_answer_0(rid, EINVAL);
689
    ipc_answer_0(rid, EINVAL);
690
}
690
}
691
 
691
 
-
 
692
void vfs_truncate(ipc_callid_t rid, ipc_call_t *request)
-
 
693
{
-
 
694
    int fd = IPC_GET_ARG1(*request);
-
 
695
    size_t size = IPC_GET_ARG2(*request);
-
 
696
    ipcarg_t rc;
-
 
697
 
-
 
698
    vfs_file_t *file = vfs_file_get(fd);
-
 
699
    if (!file) {
-
 
700
        ipc_answer_0(rid, ENOENT);
-
 
701
        return;
-
 
702
    }
-
 
703
    futex_down(&file->lock);
-
 
704
 
-
 
705
    rwlock_write_lock(&file->node->contents_rwlock);
-
 
706
    int fs_phone = vfs_grab_phone(file->node->fs_handle);
-
 
707
    rc = async_req_3_0(fs_phone, VFS_TRUNCATE, (ipcarg_t)file->node->dev_handle,
-
 
708
        (ipcarg_t)file->node->index, (ipcarg_t)size);
-
 
709
    vfs_release_phone(fs_phone);
-
 
710
    if (rc == EOK)
-
 
711
        file->node->size = size;
-
 
712
    rwlock_write_unlock(&file->node->contents_rwlock);
-
 
713
 
-
 
714
    futex_up(&file->lock);
-
 
715
 
-
 
716
    return rc; 
-
 
717
}
-
 
718
 
692
atomic_t fs_head_futex = FUTEX_INITIALIZER;
719
atomic_t fs_head_futex = FUTEX_INITIALIZER;
693
link_t fs_head;
720
link_t fs_head;
694
 
721
 
695
atomic_t fs_handle_next = {
722
atomic_t fs_handle_next = {
696
    .count = 1
723
    .count = 1