Index: uspace/srv/fs/tmpfs/tmpfs.h
===================================================================
--- uspace/srv/fs/tmpfs/tmpfs.h	(revision cad9c7229b14b0f744c8fbeabc9dfa53ac9bdb4c)
+++ uspace/srv/fs/tmpfs/tmpfs.h	(revision 62da45a052d2336d92cdd681cdde3e0d05b1665a)
@@ -1,4 +1,4 @@
 /*
- * Copyright (c) 2007 Jakub Jermar
+ * Copyright (c) 2008 Jakub Jermar
  * All rights reserved.
  *
@@ -64,4 +64,5 @@
 extern void tmpfs_read(ipc_callid_t, ipc_call_t *);
 extern void tmpfs_write(ipc_callid_t, ipc_call_t *);
+extern void tmpfs_truncate(ipc_callid_t, ipc_call_t *);
 
 #endif
Index: uspace/srv/fs/tmpfs/tmpfs_ops.c
===================================================================
--- uspace/srv/fs/tmpfs/tmpfs_ops.c	(revision cad9c7229b14b0f744c8fbeabc9dfa53ac9bdb4c)
+++ uspace/srv/fs/tmpfs/tmpfs_ops.c	(revision 62da45a052d2336d92cdd681cdde3e0d05b1665a)
@@ -369,5 +369,5 @@
 		return;
 	}
-	/* Clear any newly allocated memory in order to emulate gaps.  */
+	/* Clear any newly allocated memory in order to emulate gaps. */
 	memset(newdata + dentry->size, 0, delta);
 	dentry->size += delta;
@@ -377,4 +377,41 @@
 }
 
+void tmpfs_truncate(ipc_callid_t rid, ipc_call_t *request)
+{
+	int dev_handle = IPC_GET_ARG1(*request);
+	unsigned long index = IPC_GET_ARG2(*request);
+	size_t size = IPC_GET_ARG3(*request);
+
+	/*
+	 * Lookup the respective dentry.
+	 */
+	link_t *hlp;
+	hlp = hash_table_find(&dentries, &index);
+	if (!hlp) {
+		ipc_answer_0(rid, ENOENT);
+		return;
+	}
+	tmpfs_dentry_t *dentry = hash_table_get_instance(hlp, tmpfs_dentry_t,
+	    dh_link);
+
+	if (size == dentry->size) {
+		ipc_answer_0(rid, EOK);
+		return;
+	}
+
+	void *newdata = realloc(dentry->data, size);
+	if (!newdata) {
+		ipc_answer_0(rid, ENOMEM);
+		return;
+	}
+	if (size > dentry->size) {
+		size_t delta = size - dentry->size;
+		memset(newdata + dentry->size, 0, delta);
+	}
+	dentry->size = size;
+	dentry->data = newdata;
+	ipc_answer_0(rid, EOK);
+}
+
 /**
  * @}
