Subversion Repositories HelenOS

Compare Revisions

Ignore whitespace Rev 2692 → Rev 2693

/trunk/uspace/srv/vfs/vfs.c
1,5 → 1,5
/*
* Copyright (c) 2007 Jakub Jermar
* Copyright (c) 2008 Jakub Jermar
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
103,6 → 103,8
vfs_seek(callid, &call);
break;
case VFS_TRUNCATE:
vfs_truncate(callid, &call);
break;
case VFS_UNMOUNT:
case VFS_CLOSE:
case VFS_UNLINK:
/trunk/uspace/srv/vfs/vfs_ops.c
689,6 → 689,33
ipc_answer_0(rid, EINVAL);
}
 
void vfs_truncate(ipc_callid_t rid, ipc_call_t *request)
{
int fd = IPC_GET_ARG1(*request);
size_t size = IPC_GET_ARG2(*request);
ipcarg_t rc;
 
vfs_file_t *file = vfs_file_get(fd);
if (!file) {
ipc_answer_0(rid, ENOENT);
return;
}
futex_down(&file->lock);
 
rwlock_write_lock(&file->node->contents_rwlock);
int fs_phone = vfs_grab_phone(file->node->fs_handle);
rc = async_req_3_0(fs_phone, VFS_TRUNCATE, (ipcarg_t)file->node->dev_handle,
(ipcarg_t)file->node->index, (ipcarg_t)size);
vfs_release_phone(fs_phone);
if (rc == EOK)
file->node->size = size;
rwlock_write_unlock(&file->node->contents_rwlock);
 
futex_up(&file->lock);
 
return rc;
}
 
atomic_t fs_head_futex = FUTEX_INITIALIZER;
link_t fs_head;
 
/trunk/uspace/srv/vfs/vfs.h
229,6 → 229,7
extern void vfs_read(ipc_callid_t, ipc_call_t *);
extern void vfs_write(ipc_callid_t, ipc_call_t *);
extern void vfs_seek(ipc_callid_t, ipc_call_t *);
extern void vfs_truncate(ipc_callid_t, ipc_call_t *);
 
#endif