Index: uspace/srv/vfs/vfs_ops.c
===================================================================
--- uspace/srv/vfs/vfs_ops.c	(revision 4cac2d69158253d6b2ffb0a43fa4dc39390f104f)
+++ uspace/srv/vfs/vfs_ops.c	(revision 827d73f23124302d0257a467a1990e68bd7a15e7)
@@ -38,4 +38,6 @@
 #include "vfs.h"
 #include <ipc/ipc.h>
+#include <macros.h>
+#include <limits.h>
 #include <async.h>
 #include <errno.h>
@@ -53,5 +55,5 @@
 
 /* Forward declarations of static functions. */
-static int vfs_truncate_internal(fs_handle_t, dev_handle_t, fs_index_t, size_t);
+static int vfs_truncate_internal(fs_handle_t, dev_handle_t, fs_index_t, aoff64_t);
 
 /**
@@ -353,5 +355,4 @@
 	vfs_lookup_res_t mp_res;
 	vfs_lookup_res_t mr_res;
-	vfs_node_t *mp_node;
 	vfs_node_t *mr_node;
 	int phone;
@@ -503,5 +504,4 @@
 	int oflag = IPC_GET_ARG2(*request);
 	int mode = IPC_GET_ARG3(*request);
-	size_t len;
 
 	/* Ignore mode for now. */
@@ -887,8 +887,8 @@
 {
 	int fd = (int) IPC_GET_ARG1(*request);
-	off_t off = (off_t) IPC_GET_ARG2(*request);
-	int whence = (int) IPC_GET_ARG3(*request);
-
-
+	off64_t off =
+	    (off64_t) MERGE_LOUP32(IPC_GET_ARG2(*request), IPC_GET_ARG3(*request));
+	int whence = (int) IPC_GET_ARG4(*request);
+	
 	/* Lookup the file structure corresponding to the file descriptor. */
 	vfs_file_t *file = vfs_file_get(fd);
@@ -897,47 +897,69 @@
 		return;
 	}
-
-	off_t newpos;
+	
 	fibril_mutex_lock(&file->lock);
-	if (whence == SEEK_SET) {
-		file->pos = off;
-		fibril_mutex_unlock(&file->lock);
-		ipc_answer_1(rid, EOK, off);
-		return;
-	}
-	if (whence == SEEK_CUR) {
-		if (file->pos + off < file->pos) {
+	
+	off64_t newoff;
+	switch (whence) {
+		case SEEK_SET:
+			if (off >= 0) {
+				file->pos = (aoff64_t) off;
+				fibril_mutex_unlock(&file->lock);
+				ipc_answer_1(rid, EOK, off);
+				return;
+			}
+			break;
+		case SEEK_CUR:
+			if ((off >= 0) && (file->pos + off < file->pos)) {
+				fibril_mutex_unlock(&file->lock);
+				ipc_answer_0(rid, EOVERFLOW);
+				return;
+			}
+			
+			if ((off < 0) && (file->pos < (aoff64_t) -off)) {
+				fibril_mutex_unlock(&file->lock);
+				ipc_answer_0(rid, EOVERFLOW);
+				return;
+			}
+			
+			file->pos += off;
+			newoff = (file->pos > OFF64_MAX) ? OFF64_MAX : file->pos;
+			
 			fibril_mutex_unlock(&file->lock);
-			ipc_answer_0(rid, EOVERFLOW);
+			ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff));
 			return;
-		}
-		file->pos += off;
-		newpos = file->pos;
-		fibril_mutex_unlock(&file->lock);
-		ipc_answer_1(rid, EOK, newpos);
-		return;
-	}
-	if (whence == SEEK_END) {
-		fibril_rwlock_read_lock(&file->node->contents_rwlock);
-		size_t size = file->node->size;
-		fibril_rwlock_read_unlock(&file->node->contents_rwlock);
-		if (size + off < size) {
+		case SEEK_END:
+			fibril_rwlock_read_lock(&file->node->contents_rwlock);
+			aoff64_t size = file->node->size;
+			
+			if ((off >= 0) && (size + off < size)) {
+				fibril_rwlock_read_unlock(&file->node->contents_rwlock);
+				fibril_mutex_unlock(&file->lock);
+				ipc_answer_0(rid, EOVERFLOW);
+				return;
+			}
+			
+			if ((off < 0) && (size < (aoff64_t) -off)) {
+				fibril_rwlock_read_unlock(&file->node->contents_rwlock);
+				fibril_mutex_unlock(&file->lock);
+				ipc_answer_0(rid, EOVERFLOW);
+				return;
+			}
+			
+			file->pos = size + off;
+			newoff = (file->pos > OFF64_MAX) ? OFF64_MAX : file->pos;
+			
+			fibril_rwlock_read_unlock(&file->node->contents_rwlock);
 			fibril_mutex_unlock(&file->lock);
-			ipc_answer_0(rid, EOVERFLOW);
+			ipc_answer_2(rid, EOK, LOWER32(newoff), UPPER32(newoff));
 			return;
-		}
-		newpos = size + off;
-		file->pos = newpos;
-		fibril_mutex_unlock(&file->lock);
-		ipc_answer_1(rid, EOK, newpos);
-		return;
-	}
+	}
+	
 	fibril_mutex_unlock(&file->lock);
 	ipc_answer_0(rid, EINVAL);
 }
 
-int
-vfs_truncate_internal(fs_handle_t fs_handle, dev_handle_t dev_handle,
-    fs_index_t index, size_t size)
+int vfs_truncate_internal(fs_handle_t fs_handle, dev_handle_t dev_handle,
+    fs_index_t index, aoff64_t size)
 {
 	ipcarg_t rc;
@@ -945,6 +967,6 @@
 	
 	fs_phone = vfs_grab_phone(fs_handle);
-	rc = async_req_3_0(fs_phone, VFS_OUT_TRUNCATE, (ipcarg_t)dev_handle,
-	    (ipcarg_t)index, (ipcarg_t)size);
+	rc = async_req_4_0(fs_phone, VFS_OUT_TRUNCATE, (ipcarg_t) dev_handle,
+	    (ipcarg_t) index, LOWER32(size), UPPER32(size));
 	vfs_release_phone(fs_phone);
 	return (int)rc;
@@ -954,5 +976,6 @@
 {
 	int fd = IPC_GET_ARG1(*request);
-	size_t size = IPC_GET_ARG2(*request);
+	aoff64_t size =
+	    (aoff64_t) MERGE_LOUP32(IPC_GET_ARG2(*request), IPC_GET_ARG3(*request));
 	int rc;
 
