Index: uspace/srv/vfs/vfs_ops.c
===================================================================
--- uspace/srv/vfs/vfs_ops.c	(revision 2c448fb8cf0ba4ec2da96ece59966a2ac34eb7ba)
+++ uspace/srv/vfs/vfs_ops.c	(revision 7fe1f75f70531c93a931eb2ac453b58c55151e62)
@@ -52,4 +52,7 @@
 #include <atomic.h>
 #include "vfs.h"
+
+/* Forward declarations of static functions. */
+static int vfs_truncate_internal(int, int, unsigned long, size_t);
 
 /**
@@ -350,5 +353,5 @@
 	}
 
-	/** Path is no longer needed. */
+	/* Path is no longer needed. */
 	free(path);
 
@@ -358,4 +361,21 @@
 	else
 		rwlock_read_unlock(&namespace_rwlock);
+
+	/* Truncate the file if requested and if necessary. */
+	if (oflag & O_TRUNC) {
+		futex_down(&node->contents_rwlock);
+		if (node->size) {
+			rc = vfs_truncate_internal(node->fs_handle,
+			    node->dev_handle, node->index, 0);
+			if (rc) {
+				futex_up(&node->contents_rwlock);
+				vfs_node_put(node);
+				ipc_answer_0(rid, rc);
+				return;
+			}
+			node->size = 0;
+		}
+		futex_up(&node->contents_rwlock);
+	}
 
 	/*
@@ -561,9 +581,22 @@
 }
 
+int vfs_truncate_internal(int fs_handle, int dev_handle, unsigned long index,
+    size_t size)
+{
+	ipcarg_t rc;
+	int fs_phone;
+	
+	fs_phone = vfs_grab_phone(fs_handle);
+	rc = async_req_3_0(fs_phone, VFS_TRUNCATE, (ipcarg_t)dev_handle,
+	    (ipcarg_t)index, (ipcarg_t)size);
+	vfs_release_phone(fs_phone);
+	return (int)rc;
+}
+
 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;
+	int rc;
 
 	vfs_file_t *file = vfs_file_get(fd);
@@ -575,9 +608,6 @@
 
 	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);
+	rc = vfs_truncate_internal(file->node->fs_handle,
+	    file->node->dev_handle, file->node->index, size);
 	if (rc == EOK)
 		file->node->size = size;
@@ -585,5 +615,5 @@
 
 	futex_up(&file->lock);
-	ipc_answer_0(rid, rc);
+	ipc_answer_0(rid, (ipcarg_t)rc);
 }
 
