Index: uspace/app/bdsh/cmds/modules/bdd/bdd.c
===================================================================
--- uspace/app/bdsh/cmds/modules/bdd/bdd.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/app/bdsh/cmds/modules/bdd/bdd.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -73,5 +73,5 @@
 	size_t block_size;
 	int rc;
-	bn_t ba;
+	aoff64_t ba;
 	uint8_t b;
 
Index: uspace/app/bdsh/cmds/modules/cat/cat.c
===================================================================
--- uspace/app/bdsh/cmds/modules/cat/cat.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/app/bdsh/cmds/modules/cat/cat.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -85,5 +85,5 @@
 {
 	int fd, bytes = 0, count = 0, reads = 0;
-	off_t total = 0;
+	off64_t total = 0;
 	char *buff = NULL;
 
Index: uspace/app/bdsh/cmds/modules/cp/cp.c
===================================================================
--- uspace/app/bdsh/cmds/modules/cp/cp.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/app/bdsh/cmds/modules/cp/cp.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -74,5 +74,5 @@
 {
 	int fd1, fd2, bytes = 0;
-	off_t total = 0;
+	off64_t total = 0;
 	int64_t copied = 0;
 	char *buff = NULL;
Index: uspace/app/mkfat/mkfat.c
===================================================================
--- uspace/app/mkfat/mkfat.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/app/mkfat/mkfat.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -98,5 +98,5 @@
 	size_t block_size;
 	char *endptr;
-	bn_t dev_nblocks;
+	aoff64_t dev_nblocks;
 
 	cfg.total_sectors = 0;
@@ -160,5 +160,5 @@
 		printf(NAME ": Warning, failed to obtain block device size.\n");
 	} else {
-		printf(NAME ": Block device has %" PRIuBN " blocks.\n",
+		printf(NAME ": Block device has %" PRIuOFF64 " blocks.\n",
 		    dev_nblocks);
 		cfg.total_sectors = dev_nblocks;
@@ -236,5 +236,5 @@
 static int fat_blocks_write(struct fat_params const *par, dev_handle_t handle)
 {
-	bn_t addr;
+	aoff64_t addr;
 	uint8_t *buffer;
 	int i;
Index: uspace/app/taskdump/elf_core.c
===================================================================
--- uspace/app/taskdump/elf_core.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/app/taskdump/elf_core.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -62,5 +62,5 @@
 #include "include/elf_core.h"
 
-static off_t align_foff_up(off_t foff, uintptr_t vaddr, size_t page_size);
+static off64_t align_foff_up(off64_t foff, uintptr_t vaddr, size_t page_size);
 static int write_all(int fd, void *data, size_t len);
 static int write_mem_area(int fd, as_area_info_t *area, int phoneid);
@@ -79,8 +79,8 @@
  *			ENOMEM on out of memory, EIO on write error.
  */
-int elf_core_save(const char *file_name, as_area_info_t *ainfo, int n, int phoneid)
+int elf_core_save(const char *file_name, as_area_info_t *ainfo, unsigned int n, int phoneid)
 {
 	elf_header_t elf_hdr;
-	off_t foff;
+	off64_t foff;
 	size_t n_ph;
 	elf_word flags;
@@ -89,5 +89,5 @@
 	int fd;
 	int rc;
-	int i;
+	unsigned int i;
 
 	n_ph = n;
@@ -184,5 +184,5 @@
 
 	for (i = 0; i < n_ph; ++i) {
-		if (lseek(fd, p_hdr[i].p_offset, SEEK_SET) == (off_t) -1) {
+		if (lseek(fd, p_hdr[i].p_offset, SEEK_SET) == (off64_t) -1) {
 			printf("Failed writing memory data.\n");
 			free(p_hdr);
@@ -202,14 +202,13 @@
 
 /** Align file offset up to be congruent with vaddr modulo page size. */
-static off_t align_foff_up(off_t foff, uintptr_t vaddr, size_t page_size)
-{
-	off_t rfo, rva;
-	off_t advance;
-
-	rva = vaddr % page_size;
-	rfo = foff % page_size;
-
-	advance = (rva >= rfo) ? rva - rfo : (page_size + rva - rfo);
-	return foff + advance;
+static off64_t align_foff_up(off64_t foff, uintptr_t vaddr, size_t page_size)
+{
+	off64_t rva = vaddr % page_size;
+	off64_t rfo = foff % page_size;
+	
+	if (rva >= rfo)
+		return (foff + (rva - rfo));
+	
+	return (foff + (page_size + (rva - rfo)));
 }
 
Index: uspace/app/taskdump/include/elf_core.h
===================================================================
--- uspace/app/taskdump/include/elf_core.h	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/app/taskdump/include/elf_core.h	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -36,5 +36,5 @@
 #define ELF_CORE_H_
 
-int elf_core_save(const char *file_name, as_area_info_t *ainfo, int n, int phoneid);
+int elf_core_save(const char *file_name, as_area_info_t *ainfo, unsigned int n, int phoneid);
 
 #endif
Index: uspace/app/taskdump/symtab.c
===================================================================
--- uspace/app/taskdump/symtab.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/app/taskdump/symtab.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -49,5 +49,5 @@
 static int section_hdr_load(int fd, const elf_header_t *ehdr, int idx,
     elf_section_header_t *shdr);
-static int chunk_load(int fd, off_t start, off_t size, void **ptr);
+static int chunk_load(int fd, off64_t start, size_t size, void **ptr);
 static int read_all(int fd, void *buf, size_t len);
 
@@ -65,5 +65,6 @@
 	elf_header_t elf_hdr;
 	elf_section_header_t sec_hdr;
-	off_t shstrt_start, shstrt_size;
+	off64_t shstrt_start;
+	size_t shstrt_size;
 	char *shstrt, *sec_name;
 	void *data;
@@ -307,5 +308,5 @@
 	rc = lseek(fd, elf_hdr->e_shoff + idx * sizeof(elf_section_header_t),
 	    SEEK_SET);
-	if (rc == (off_t) -1)
+	if (rc == (off64_t) -1)
 		return EIO;
 
@@ -328,10 +329,10 @@
  * @return		EOK on success or EIO on failure.
  */
-static int chunk_load(int fd, off_t start, off_t size, void **ptr)
+static int chunk_load(int fd, off64_t start, size_t size, void **ptr)
 {
 	int rc;
 
 	rc = lseek(fd, start, SEEK_SET);
-	if (rc == (off_t) -1) {
+	if (rc == (off64_t) -1) {
 		printf("failed seeking chunk\n");
 		*ptr = NULL;
Index: uspace/lib/libblock/libblock.c
===================================================================
--- uspace/lib/libblock/libblock.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/lib/libblock/libblock.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2008 Jakub Jermar 
- * Copyright (c) 2008 Martin Decky 
+ * Copyright (c) 2008 Jakub Jermar
+ * Copyright (c) 2008 Martin Decky
  * All rights reserved.
  *
@@ -81,13 +81,13 @@
 	size_t comm_size;
 	void *bb_buf;
-	bn_t bb_addr;
+	aoff64_t bb_addr;
 	size_t pblock_size;		/**< Physical block size. */
 	cache_t *cache;
 } devcon_t;
 
-static int read_blocks(devcon_t *devcon, bn_t ba, size_t cnt);
-static int write_blocks(devcon_t *devcon, bn_t ba, size_t cnt);
+static int read_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt);
+static int write_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt);
 static int get_block_size(int dev_phone, size_t *bsize);
-static int get_num_blocks(int dev_phone, bn_t *nblocks);
+static int get_num_blocks(int dev_phone, aoff64_t *nblocks);
 
 static devcon_t *devcon_search(dev_handle_t dev_handle)
@@ -214,5 +214,5 @@
 }
 
-int block_bb_read(dev_handle_t dev_handle, bn_t ba)
+int block_bb_read(dev_handle_t dev_handle, aoff64_t ba)
 {
 	void *bb_buf;
@@ -334,5 +334,5 @@
 		}
 
-		long key = b->boff;
+		unsigned long key = b->boff;
 		hash_table_remove(&cache->block_hash, &key, 1);
 		
@@ -382,5 +382,5 @@
  * @return			EOK on success or a negative error code.
  */
-int block_get(block_t **block, dev_handle_t dev_handle, bn_t boff, int flags)
+int block_get(block_t **block, dev_handle_t dev_handle, aoff64_t boff, int flags)
 {
 	devcon_t *devcon;
@@ -657,8 +657,8 @@
  * @return		EOK on success or a negative return code on failure.
  */
-int block_seqread(dev_handle_t dev_handle, off_t *bufpos, size_t *buflen,
-    off_t *pos, void *dst, size_t size)
-{
-	off_t offset = 0;
+int block_seqread(dev_handle_t dev_handle, size_t *bufpos, size_t *buflen,
+    aoff64_t *pos, void *dst, size_t size)
+{
+	size_t offset = 0;
 	size_t left = size;
 	size_t block_size;
@@ -690,5 +690,5 @@
 		}
 		
-		if (*bufpos == (off_t) *buflen) {
+		if (*bufpos == *buflen) {
 			/* Refill the communication buffer with a new block. */
 			int rc;
@@ -718,5 +718,5 @@
  * @return		EOK on success or negative error code on failure.
  */
-int block_read_direct(dev_handle_t dev_handle, bn_t ba, size_t cnt, void *buf)
+int block_read_direct(dev_handle_t dev_handle, aoff64_t ba, size_t cnt, void *buf)
 {
 	devcon_t *devcon;
@@ -746,5 +746,5 @@
  * @return		EOK on success or negative error code on failure.
  */
-int block_write_direct(dev_handle_t dev_handle, bn_t ba, size_t cnt,
+int block_write_direct(dev_handle_t dev_handle, aoff64_t ba, size_t cnt,
     const void *data)
 {
@@ -789,5 +789,5 @@
  * @return		EOK on success or negative error code on failure.
  */
-int block_get_nblocks(dev_handle_t dev_handle, bn_t *nblocks)
+int block_get_nblocks(dev_handle_t dev_handle, aoff64_t *nblocks)
 {
 	devcon_t *devcon;
@@ -808,5 +808,5 @@
  * @return		EOK on success or negative error code on failure.
  */
-static int read_blocks(devcon_t *devcon, bn_t ba, size_t cnt)
+static int read_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt)
 {
 	int rc;
@@ -816,5 +816,5 @@
 	    UPPER32(ba), cnt);
 	if (rc != EOK) {
-		printf("Error %d reading %d blocks starting at block %" PRIuBN
+		printf("Error %d reading %d blocks starting at block %" PRIuOFF64
 		    " from device handle %d\n", rc, cnt, ba,
 		    devcon->dev_handle);
@@ -835,5 +835,5 @@
  * @return		EOK on success or negative error code on failure.
  */
-static int write_blocks(devcon_t *devcon, bn_t ba, size_t cnt)
+static int write_blocks(devcon_t *devcon, aoff64_t ba, size_t cnt)
 {
 	int rc;
@@ -843,5 +843,5 @@
 	    UPPER32(ba), cnt);
 	if (rc != EOK) {
-		printf("Error %d writing %d blocks starting at block %" PRIuBN
+		printf("Error %d writing %d blocks starting at block %" PRIuOFF64
 		    " to device handle %d\n", rc, cnt, ba, devcon->dev_handle);
 #ifndef NDEBUG
@@ -866,5 +866,5 @@
 
 /** Get total number of blocks on block device. */
-static int get_num_blocks(int dev_phone, bn_t *nblocks)
+static int get_num_blocks(int dev_phone, aoff64_t *nblocks)
 {
 	ipcarg_t nb_l, nb_h;
@@ -873,5 +873,5 @@
 	rc = async_req_0_2(dev_phone, BD_GET_NUM_BLOCKS, &nb_l, &nb_h);
 	if (rc == EOK) {
-		*nblocks = (bn_t) MERGE_LOUP32(nb_l, nb_h);
+		*nblocks = (aoff64_t) MERGE_LOUP32(nb_l, nb_h);
 	}
 
Index: uspace/lib/libblock/libblock.h
===================================================================
--- uspace/lib/libblock/libblock.h	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/lib/libblock/libblock.h	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -74,5 +74,5 @@
 	dev_handle_t dev_handle;
 	/** Block offset on the block device. Counted in 'size'-byte blocks. */
-	bn_t boff;
+	aoff64_t boff;
 	/** Size of the block. */
 	size_t size;
@@ -96,5 +96,5 @@
 extern void block_fini(dev_handle_t);
 
-extern int block_bb_read(dev_handle_t, bn_t);
+extern int block_bb_read(dev_handle_t, aoff64_t);
 extern void *block_bb_get(dev_handle_t);
 
@@ -102,14 +102,14 @@
 extern int block_cache_fini(dev_handle_t);
 
-extern int block_get(block_t **, dev_handle_t, bn_t, int);
+extern int block_get(block_t **, dev_handle_t, aoff64_t, int);
 extern int block_put(block_t *);
 
-extern int block_seqread(dev_handle_t, off_t *, size_t *, off_t *, void *,
+extern int block_seqread(dev_handle_t, size_t *, size_t *, aoff64_t *, void *,
     size_t);
 
 extern int block_get_bsize(dev_handle_t, size_t *);
-extern int block_get_nblocks(dev_handle_t, bn_t *);
-extern int block_read_direct(dev_handle_t, bn_t, size_t, void *);
-extern int block_write_direct(dev_handle_t, bn_t, size_t, const void *);
+extern int block_get_nblocks(dev_handle_t, aoff64_t *);
+extern int block_read_direct(dev_handle_t, aoff64_t, size_t, void *);
+extern int block_write_direct(dev_handle_t, aoff64_t, size_t, const void *);
 
 #endif
Index: uspace/lib/libc/generic/io/io.c
===================================================================
--- uspace/lib/libc/generic/io/io.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/lib/libc/generic/io/io.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -541,9 +541,9 @@
 }
 
-int fseek(FILE *stream, long offset, int origin)
-{
-	off_t rc = lseek(stream->fd, offset, origin);
-	if (rc == (off_t) (-1)) {
-		/* errno has been set by lseek. */
+int fseek(FILE *stream, off64_t offset, int whence)
+{
+	off64_t rc = lseek(stream->fd, offset, whence);
+	if (rc == (off64_t) (-1)) {
+		/* errno has been set by lseek64. */
 		return -1;
 	}
@@ -554,13 +554,7 @@
 }
 
-int ftell(FILE *stream)
-{
-	off_t rc = lseek(stream->fd, 0, SEEK_CUR);
-	if (rc == (off_t) (-1)) {
-		/* errno has been set by lseek. */
-		return -1;
-	}
-
-	return rc;
+off64_t ftell(FILE *stream)
+{
+	return lseek(stream->fd, 0, SEEK_CUR);
 }
 
Index: uspace/lib/libc/generic/mman.c
===================================================================
--- uspace/lib/libc/generic/mman.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/lib/libc/generic/mman.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -39,5 +39,5 @@
 
 void *mmap(void *start, size_t length, int prot, int flags, int fd,
-    off_t offset)
+    aoff64_t offset)
 {
 	if (!start)
Index: uspace/lib/libc/generic/vfs/vfs.c
===================================================================
--- uspace/lib/libc/generic/vfs/vfs.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/lib/libc/generic/vfs/vfs.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -35,4 +35,5 @@
 #include <vfs/vfs.h>
 #include <vfs/canonify.h>
+#include <macros.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -434,36 +435,38 @@
 }
 
-off_t lseek(int fildes, off_t offset, int whence)
-{
-	ipcarg_t rc;
-
-	futex_down(&vfs_phone_futex);
-	async_serialize_start();
-	vfs_connect();
-	
-	ipcarg_t newoffs;
-	rc = async_req_3_1(vfs_phone, VFS_IN_SEEK, fildes, offset, whence,
-	    &newoffs);
-
-	async_serialize_end();
-	futex_up(&vfs_phone_futex);
-
+off64_t lseek(int fildes, off64_t offset, int whence)
+{
+	futex_down(&vfs_phone_futex);
+	async_serialize_start();
+	vfs_connect();
+	
+	ipcarg_t newoff_lo;
+	ipcarg_t newoff_hi;
+	ipcarg_t rc = async_req_4_2(vfs_phone, VFS_IN_SEEK, fildes,
+	    LOWER32(offset), UPPER32(offset), whence,
+	    &newoff_lo, &newoff_hi);
+	
+	async_serialize_end();
+	futex_up(&vfs_phone_futex);
+	
 	if (rc != EOK)
-		return (off_t) -1;
-	
-	return (off_t) newoffs;
-}
-
-int ftruncate(int fildes, off_t length)
-{
-	ipcarg_t rc;
-	
-	futex_down(&vfs_phone_futex);
-	async_serialize_start();
-	vfs_connect();
-	
-	rc = async_req_2_0(vfs_phone, VFS_IN_TRUNCATE, fildes, length);
-	async_serialize_end();
-	futex_up(&vfs_phone_futex);
+		return (off64_t) -1;
+	
+	return (off64_t) MERGE_LOUP32(newoff_lo, newoff_hi);
+}
+
+int ftruncate(int fildes, aoff64_t length)
+{
+	ipcarg_t rc;
+	
+	futex_down(&vfs_phone_futex);
+	async_serialize_start();
+	vfs_connect();
+	
+	rc = async_req_3_0(vfs_phone, VFS_IN_TRUNCATE, fildes,
+	    LOWER32(length), UPPER32(length));
+	async_serialize_end();
+	futex_up(&vfs_phone_futex);
+	
 	return (int) rc;
 }
@@ -479,5 +482,5 @@
 	
 	req = async_send_1(vfs_phone, VFS_IN_FSTAT, fildes, NULL);
-	rc = async_data_read_start(vfs_phone, (void *)stat, sizeof(struct stat));
+	rc = async_data_read_start(vfs_phone, (void *) stat, sizeof(struct stat));
 	if (rc != EOK) {
 		ipcarg_t rc_orig;
@@ -553,5 +556,5 @@
 	if (!abs) {
 		free(dirp);
-		return ENOMEM;
+		return NULL;
 	}
 	
Index: uspace/lib/libc/include/limits.h
===================================================================
--- uspace/lib/libc/include/limits.h	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/lib/libc/include/limits.h	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -46,9 +46,9 @@
 
 #ifdef __CHAR_UNSIGNED__
-# define CHAR_MIN UCHAR_MIN
-# define CHAR_MAX UCHAR_MAX
+	#define CHAR_MIN UCHAR_MIN
+	#define CHAR_MAX UCHAR_MAX
 #else
-# define CHAR_MIN SCHAR_MIN
-# define CHAR_MAX SCHAR_MAX
+	#define CHAR_MIN SCHAR_MIN
+	#define CHAR_MAX SCHAR_MAX
 #endif
 
@@ -59,4 +59,5 @@
 #define USHRT_MAX MAX_UINT16
 
+/* int */
 #define INT_MIN MIN_INT32
 #define INT_MAX MAX_INT32
@@ -64,4 +65,5 @@
 #define UINT_MAX MAX_UINT32
 
+/* long long int */
 #define LLONG_MIN MIN_INT64
 #define LLONG_MAX MAX_INT64
@@ -69,4 +71,12 @@
 #define ULLONG_MAX MAX_UINT64
 
+/* off64_t */
+#define OFF64_MIN MIN_INT64
+#define OFF64_MAX MAX_INT64
+
+/* aoff64_t */
+#define AOFF64_MIN MIN_UINT64
+#define AOFF64_MAX MAX_UINT64
+
 #endif
 
Index: uspace/lib/libc/include/stdio.h
===================================================================
--- uspace/lib/libc/include/stdio.h	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/lib/libc/include/stdio.h	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -46,5 +46,5 @@
 #define BUFSIZ  4096
 
-#define DEBUG(fmt, ...) \
+#define DEBUG(fmt, ...)se\
 	{ \
 		char _buf[256]; \
@@ -56,5 +56,11 @@
 #ifndef SEEK_SET
 	#define SEEK_SET  0
+#endif
+
+#ifndef SEEK_CUR
 	#define SEEK_CUR  1
+#endif
+
+#ifndef SEEK_END
 	#define SEEK_END  2
 #endif
@@ -135,7 +141,7 @@
 extern size_t fwrite(const void *, size_t, size_t, FILE *);
 
-extern int fseek(FILE *, long, int);
+extern int fseek(FILE *, off64_t, int);
 extern void rewind(FILE *);
-extern int ftell(FILE *);
+extern off64_t ftell(FILE *);
 extern int feof(FILE *);
 
Index: uspace/lib/libc/include/sys/mman.h
===================================================================
--- uspace/lib/libc/include/sys/mman.h	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/lib/libc/include/sys/mman.h	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -41,8 +41,8 @@
 #define MAP_FAILED  ((void *) -1)
 
-#define MAP_SHARED       (1 << 0)
-#define MAP_PRIVATE      (1 << 1)
-#define MAP_FIXED        (1 << 2)
-#define MAP_ANONYMOUS    (1 << 3)
+#define MAP_SHARED     (1 << 0)
+#define MAP_PRIVATE    (1 << 1)
+#define MAP_FIXED      (1 << 2)
+#define MAP_ANONYMOUS  (1 << 3)
 
 #define PROTO_READ   AS_AREA_READ
@@ -50,6 +50,6 @@
 #define PROTO_EXEC   AS_AREA_EXEC
 
-extern void *mmap(void  *start, size_t length, int prot, int flags, int fd,
-    off_t offset);
+extern void *mmap(void *start, size_t length, int prot, int flags, int fd,
+    aoff64_t offset);
 extern int munmap(void *start, size_t length);
 
Index: uspace/lib/libc/include/sys/stat.h
===================================================================
--- uspace/lib/libc/include/sys/stat.h	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/lib/libc/include/sys/stat.h	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -31,5 +31,5 @@
  */
 /** @file
- */ 
+ */
 
 #ifndef LIBC_SYS_STAT_H_
@@ -48,5 +48,5 @@
 	bool is_file;
 	bool is_directory;
-	off_t size;
+	aoff64_t size;
 	dev_handle_t device;
 };
Index: uspace/lib/libc/include/sys/typefmt.h
===================================================================
--- uspace/lib/libc/include/sys/typefmt.h	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/lib/libc/include/sys/typefmt.h	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -39,15 +39,9 @@
 #include <inttypes.h>
 
-/* off_t */
-#define PRIdOFF "ld"
-#define PRIuOFF "lu"
-#define PRIxOFF "lx"
-#define PRIXOFF "lX"
-
-/* bn_t */
-#define PRIdBN PRId64
-#define PRIuBN PRIu64
-#define PRIxBN PRIx64
-#define PRIXBN PRIX64
+/* off64_t */
+#define PRIdOFF64 PRId64
+#define PRIuOFF64 PRIu64
+#define PRIxOFF64 PRIx64
+#define PRIXOFF64 PRIX64
 
 /* (s)size_t */
Index: uspace/lib/libc/include/sys/types.h
===================================================================
--- uspace/lib/libc/include/sys/types.h	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/lib/libc/include/sys/types.h	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -38,8 +38,13 @@
 #include <libarch/types.h>
 
-typedef long off_t;
-typedef int mode_t;
-typedef uint64_t bn_t;	/**< Block number type. */
+typedef unsigned int mode_t;
 
+/** Relative offset */
+typedef int64_t off64_t;
+
+/** Absolute offset */
+typedef uint64_t aoff64_t;
+
+/** Unicode code point */
 typedef int32_t wchar_t;
 
Index: uspace/lib/libc/include/unistd.h
===================================================================
--- uspace/lib/libc/include/unistd.h	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/lib/libc/include/unistd.h	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -47,5 +47,11 @@
 #ifndef SEEK_SET
 	#define SEEK_SET  0
+#endif
+
+#ifndef SEEK_CUR
 	#define SEEK_CUR  1
+#endif
+
+#ifndef SEEK_END
 	#define SEEK_END  2
 #endif
@@ -58,6 +64,6 @@
 extern ssize_t read(int, void *, size_t);
 
-extern off_t lseek(int, off_t, int);
-extern int ftruncate(int, off_t);
+extern off64_t lseek(int, off64_t, int);
+extern int ftruncate(int, aoff64_t);
 
 extern int close(int);
@@ -69,7 +75,7 @@
 extern int chdir(const char *);
 
-extern void _exit(int status) __attribute__ ((noreturn));
-extern int usleep(useconds_t uses);
-extern unsigned int sleep(unsigned int se);
+extern void _exit(int) __attribute__((noreturn));
+extern int usleep(useconds_t);
+extern unsigned int sleep(unsigned int);
 
 #endif
Index: uspace/lib/libfs/libfs.c
===================================================================
--- uspace/lib/libfs/libfs.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/lib/libfs/libfs.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -37,4 +37,5 @@
 #include "libfs.h"
 #include "../../srv/vfs/vfs.h"
+#include <macros.h>
 #include <errno.h>
 #include <async.h>
@@ -398,8 +399,10 @@
 						ipc_answer_0(rid, rc);
 					} else {
-						ipc_answer_5(rid, EOK,
-						    fs_handle, dev_handle,
+						aoff64_t size = ops->size_get(fn);
+						ipc_answer_5(rid, fs_handle,
+						    dev_handle,
 						    ops->index_get(fn),
-						    ops->size_get(fn),
+						    LOWER32(size),
+						    UPPER32(size),
 						    ops->lnkcnt_get(fn));
 						(void) ops->node_put(fn);
@@ -478,8 +481,10 @@
 					ipc_answer_0(rid, rc);
 				} else {
-					ipc_answer_5(rid, EOK,
-					    fs_handle, dev_handle,
+					aoff64_t size = ops->size_get(fn);
+					ipc_answer_5(rid, fs_handle,
+					    dev_handle,
 					    ops->index_get(fn),
-					    ops->size_get(fn),
+					    LOWER32(size),
+					    UPPER32(size),
 					    ops->lnkcnt_get(fn));
 					(void) ops->node_put(fn);
@@ -501,6 +506,13 @@
 		unsigned int old_lnkcnt = ops->lnkcnt_get(cur);
 		rc = ops->unlink(par, cur, component);
-		ipc_answer_5(rid, (ipcarg_t) rc, fs_handle, dev_handle,
-		    ops->index_get(cur), ops->size_get(cur), old_lnkcnt);
+		
+		if (rc == EOK) {
+			aoff64_t size = ops->size_get(cur);
+			ipc_answer_5(rid, fs_handle, dev_handle,
+			    ops->index_get(cur), LOWER32(size), UPPER32(size),
+			    old_lnkcnt);
+		} else
+			ipc_answer_0(rid, rc);
+		
 		goto out;
 	}
@@ -533,7 +545,12 @@
 			rc = ops->node_open(cur);
 		
-		ipc_answer_5(rid, rc, fs_handle, dev_handle,
-		    ops->index_get(cur), ops->size_get(cur),
-		    ops->lnkcnt_get(cur));
+		if (rc == EOK) {
+			aoff64_t size = ops->size_get(cur);
+			ipc_answer_5(rid, fs_handle, dev_handle,
+			    ops->index_get(cur), LOWER32(size), UPPER32(size),
+			    ops->lnkcnt_get(cur));
+		} else
+			ipc_answer_0(rid, rc);
+		
 	} else
 		ipc_answer_0(rid, rc);
@@ -602,8 +619,7 @@
 	dev_handle_t dev_handle = IPC_GET_ARG1(*request);
 	fs_index_t index = IPC_GET_ARG2(*request);
+	
 	fs_node_t *fn;
-	int rc;
-	
-	rc = ops->node_get(&fn, dev_handle, index);
+	int rc = ops->node_get(&fn, dev_handle, index);
 	on_error(rc, answer_and_return(rid, rc));
 	
@@ -614,5 +630,6 @@
 	
 	rc = ops->node_open(fn);
-	ipc_answer_3(rid, rc, ops->size_get(fn), ops->lnkcnt_get(fn),
+	aoff64_t size = ops->size_get(fn);
+	ipc_answer_4(rid, rc, LOWER32(size), UPPER32(size), ops->lnkcnt_get(fn),
 	    (ops->is_file(fn) ? L_FILE : 0) | (ops->is_directory(fn) ? L_DIRECTORY : 0));
 	
Index: uspace/lib/libfs/libfs.h
===================================================================
--- uspace/lib/libfs/libfs.h	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/lib/libfs/libfs.h	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -76,5 +76,5 @@
 	 */
 	fs_index_t (* index_get)(fs_node_t *);
-	size_t (* size_get)(fs_node_t *);
+	aoff64_t (* size_get)(fs_node_t *);
 	unsigned int (* lnkcnt_get)(fs_node_t *);
 	char (* plb_get_char)(unsigned pos);
Index: uspace/srv/bd/file_bd/file_bd.c
===================================================================
--- uspace/srv/bd/file_bd/file_bd.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/srv/bd/file_bd/file_bd.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -57,5 +57,5 @@
 
 static const size_t block_size = 512;
-static bn_t num_blocks;
+static aoff64_t num_blocks;
 static FILE *img;
 
@@ -210,6 +210,6 @@
 	/* Check whether access is within device address bounds. */
 	if (ba + cnt > num_blocks) {
-		printf(NAME ": Accessed blocks %" PRIuBN "-%" PRIuBN ", while "
-		    "max block number is %" PRIuBN ".\n", ba, ba + cnt - 1,
+		printf(NAME ": Accessed blocks %" PRIuOFF64 "-%" PRIuOFF64 ", while "
+		    "max block number is %" PRIuOFF64 ".\n", ba, ba + cnt - 1,
 		    num_blocks - 1);
 		return ELIMIT;
@@ -248,6 +248,6 @@
 	/* Check whether access is within device address bounds. */
 	if (ba + cnt > num_blocks) {
-		printf(NAME ": Accessed blocks %" PRIuBN "-%" PRIuBN ", while "
-		    "max block number is %" PRIuBN ".\n", ba, ba + cnt - 1,
+		printf(NAME ": Accessed blocks %" PRIuOFF64 "-%" PRIuOFF64 ", while "
+		    "max block number is %" PRIuOFF64 ".\n", ba, ba + cnt - 1,
 		    num_blocks - 1);
 		return ELIMIT;
Index: uspace/srv/bd/part/guid_part/guid_part.c
===================================================================
--- uspace/srv/bd/part/guid_part/guid_part.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/srv/bd/part/guid_part/guid_part.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -79,7 +79,7 @@
 	bool present;
 	/** Address of first block */
-	bn_t start_addr;
+	aoff64_t start_addr;
 	/** Number of blocks */
-	bn_t length;
+	aoff64_t length;
 	/** Device representing the partition (outbound device) */
 	dev_handle_t dev;
@@ -101,7 +101,7 @@
 static void gpt_pte_to_part(const gpt_entry_t *pte, part_t *part);
 static void gpt_connection(ipc_callid_t iid, ipc_call_t *icall);
-static int gpt_bd_read(part_t *p, bn_t ba, size_t cnt, void *buf);
-static int gpt_bd_write(part_t *p, bn_t ba, size_t cnt, const void *buf);
-static int gpt_bsa_translate(part_t *p, bn_t ba, size_t cnt, bn_t *gba);
+static int gpt_bd_read(part_t *p, aoff64_t ba, size_t cnt, void *buf);
+static int gpt_bd_write(part_t *p, aoff64_t ba, size_t cnt, const void *buf);
+static int gpt_bsa_translate(part_t *p, aoff64_t ba, size_t cnt, aoff64_t *gba);
 
 int main(int argc, char **argv)
@@ -199,5 +199,5 @@
 		    / (1024 * 1024);
 		printf(NAME ": Registered device %s: %" PRIu64 " blocks "
-		    "%" PRIuBN " MB.\n", name, part->length, size_mb);
+		    "%" PRIuOFF64 " MB.\n", name, part->length, size_mb);
 
 		part->dev = dev;
@@ -319,5 +319,5 @@
 	int flags;
 	int retval;
-	bn_t ba;
+	aoff64_t ba;
 	size_t cnt;
 	part_t *part;
@@ -402,7 +402,7 @@
 
 /** Read blocks from partition. */
-static int gpt_bd_read(part_t *p, bn_t ba, size_t cnt, void *buf)
-{
-	bn_t gba;
+static int gpt_bd_read(part_t *p, aoff64_t ba, size_t cnt, void *buf)
+{
+	aoff64_t gba;
 
 	if (gpt_bsa_translate(p, ba, cnt, &gba) != EOK)
@@ -413,7 +413,7 @@
 
 /** Write blocks to partition. */
-static int gpt_bd_write(part_t *p, bn_t ba, size_t cnt, const void *buf)
-{
-	bn_t gba;
+static int gpt_bd_write(part_t *p, aoff64_t ba, size_t cnt, const void *buf)
+{
+	aoff64_t gba;
 
 	if (gpt_bsa_translate(p, ba, cnt, &gba) != EOK)
@@ -424,5 +424,5 @@
 
 /** Translate block segment address with range checking. */
-static int gpt_bsa_translate(part_t *p, bn_t ba, size_t cnt, bn_t *gba)
+static int gpt_bsa_translate(part_t *p, aoff64_t ba, size_t cnt, aoff64_t *gba)
 {
 	if (ba + cnt > p->length)
Index: uspace/srv/bd/part/mbr_part/mbr_part.c
===================================================================
--- uspace/srv/bd/part/mbr_part/mbr_part.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/srv/bd/part/mbr_part/mbr_part.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -97,7 +97,7 @@
 	bool present;
 	/** Address of first block */
-	bn_t start_addr;
+	aoff64_t start_addr;
 	/** Number of blocks */
-	bn_t length;
+	aoff64_t length;
 	/** Device representing the partition (outbound device) */
 	dev_handle_t dev;
@@ -249,5 +249,5 @@
 		size_mb = (part->length * block_size + 1024 * 1024 - 1)
 		    / (1024 * 1024);
-		printf(NAME ": Registered device %s: %" PRIuBN " blocks "
+		printf(NAME ": Registered device %s: %" PRIuOFF64 " blocks "
 		    "%" PRIu64 " MB.\n", name, part->length, size_mb);
 
Index: uspace/srv/clip/clip.c
===================================================================
--- uspace/srv/clip/clip.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/srv/clip/clip.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -145,5 +145,5 @@
 	
 	fibril_mutex_unlock(&clip_mtx);
-	ipc_answer_2(rid, EOK, (ipcarg_t) size, (ipcarg_t) clip_tag);
+	ipc_answer_2(rid, EOK, (ipcarg_t) size, (ipcarg_t) tag);
 }
 
Index: uspace/srv/fs/devfs/devfs_ops.c
===================================================================
--- uspace/srv/fs/devfs/devfs_ops.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/srv/fs/devfs/devfs_ops.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -37,4 +37,5 @@
 
 #include <ipc/ipc.h>
+#include <macros.h>
 #include <bool.h>
 #include <errno.h>
@@ -337,5 +338,5 @@
 }
 
-static size_t devfs_size_get(fs_node_t *fn)
+static aoff64_t devfs_size_get(fs_node_t *fn)
 {
 	return 0;
@@ -463,5 +464,6 @@
 {
 	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
-	off_t pos = (off_t) IPC_GET_ARG3(*request);
+	aoff64_t pos =
+	    (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request));
 	
 	if (index == 0) {
@@ -597,6 +599,4 @@
 {
 	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
-	off_t pos = (off_t) IPC_GET_ARG3(*request);
-	
 	if (index == 0) {
 		ipc_answer_0(rid, ENOTSUP);
Index: uspace/srv/fs/fat/fat.h
===================================================================
--- uspace/srv/fs/fat/fat.h	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/srv/fs/fat/fat.h	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -89,5 +89,5 @@
 			uint16_t	signature;
 		} __attribute__ ((packed));
-		struct fat32 {
+		struct {
 			/* FAT32 only */
 			/** Sectors per FAT. */
@@ -119,6 +119,6 @@
 			/** Signature. */
 			uint16_t	signature;
-		} __attribute__ ((packed));
-	}; 
+		} fat32 __attribute__ ((packed));
+	};
 } __attribute__ ((packed)) fat_bs_t;
 
@@ -194,5 +194,5 @@
 	/** FAT in-core node free list link. */
 	link_t			ffn_link;
-	size_t			size;
+	aoff64_t		size;
 	unsigned		lnkcnt;
 	unsigned		refcnt;
Index: uspace/srv/fs/fat/fat_dentry.c
===================================================================
--- uspace/srv/fs/fat/fat_dentry.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/srv/fs/fat/fat_dentry.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -82,5 +82,6 @@
 bool fat_dentry_name_verify(const char *name)
 {
-	unsigned i, dot;
+	unsigned int i;
+	unsigned int dot = 0;
 	bool dot_found = false;
 	
Index: uspace/srv/fs/fat/fat_fat.c
===================================================================
--- uspace/srv/fs/fat/fat_fat.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/srv/fs/fat/fat_fat.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -93,5 +93,5 @@
 
 	while (clst < FAT_CLST_LAST1 && clusters < max_clusters) {
-		bn_t fsec;	/* sector offset relative to FAT1 */
+		aoff64_t fsec;	/* sector offset relative to FAT1 */
 		unsigned fidx;	/* FAT1 entry index */
 
@@ -135,5 +135,5 @@
 int
 _fat_block_get(block_t **block, fat_bs_t *bs, dev_handle_t dev_handle,
-    fat_cluster_t firstc, bn_t bn, int flags)
+    fat_cluster_t firstc, aoff64_t bn, int flags)
 {
 	unsigned bps;
@@ -196,10 +196,10 @@
  * @return		EOK on success or a negative error code.
  */
-int fat_fill_gap(fat_bs_t *bs, fat_node_t *nodep, fat_cluster_t mcl, off_t pos)
+int fat_fill_gap(fat_bs_t *bs, fat_node_t *nodep, fat_cluster_t mcl, aoff64_t pos)
 {
 	uint16_t bps;
 	unsigned spc;
 	block_t *b;
-	off_t o, boundary;
+	aoff64_t o, boundary;
 	int rc;
 
Index: uspace/srv/fs/fat/fat_fat.h
===================================================================
--- uspace/srv/fs/fat/fat_fat.h	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/srv/fs/fat/fat_fat.h	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -69,6 +69,6 @@
 
 extern int _fat_block_get(block_t **, struct fat_bs *, dev_handle_t,
-    fat_cluster_t, bn_t, int);
-  
+    fat_cluster_t, aoff64_t, int);
+
 extern int fat_append_clusters(struct fat_bs *, struct fat_node *,
     fat_cluster_t);
@@ -85,5 +85,5 @@
     fat_cluster_t, fat_cluster_t);
 extern int fat_fill_gap(struct fat_bs *, struct fat_node *, fat_cluster_t,
-    off_t);
+    aoff64_t);
 extern int fat_zero_cluster(struct fat_bs *, dev_handle_t, fat_cluster_t);
 extern int fat_sanity_check(struct fat_bs *, dev_handle_t);
Index: uspace/srv/fs/fat/fat_ops.c
===================================================================
--- uspace/srv/fs/fat/fat_ops.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/srv/fs/fat/fat_ops.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -45,4 +45,5 @@
 #include <ipc/services.h>
 #include <ipc/devmap.h>
+#include <macros.h>
 #include <async.h>
 #include <errno.h>
@@ -79,5 +80,5 @@
 static int fat_has_children(bool *, fs_node_t *);
 static fs_index_t fat_index_get(fs_node_t *);
-static size_t fat_size_get(fs_node_t *);
+static aoff64_t fat_size_get(fs_node_t *);
 static unsigned fat_lnkcnt_get(fs_node_t *);
 static char fat_plb_get_char(unsigned);
@@ -738,10 +739,10 @@
 			goto skip_dots;
 		}
-		d = (fat_dentry_t *)b->data;
-		if (fat_classify_dentry(d) == FAT_DENTRY_LAST ||
-		    str_cmp(d->name, FAT_NAME_DOT) == 0) {
+		d = (fat_dentry_t *) b->data;
+		if ((fat_classify_dentry(d) == FAT_DENTRY_LAST) ||
+		    (str_cmp((char *) d->name, FAT_NAME_DOT)) == 0) {
 			memset(d, 0, sizeof(fat_dentry_t));
-			str_cpy(d->name, 8, FAT_NAME_DOT);
-			str_cpy(d->ext, 3, FAT_EXT_PAD);
+			str_cpy((char *) d->name, 8, FAT_NAME_DOT);
+			str_cpy((char *) d->ext, 3, FAT_EXT_PAD);
 			d->attr = FAT_ATTR_SUBDIR;
 			d->firstc = host2uint16_t_le(childp->firstc);
@@ -749,9 +750,9 @@
 		}
 		d++;
-		if (fat_classify_dentry(d) == FAT_DENTRY_LAST ||
-		    str_cmp(d->name, FAT_NAME_DOT_DOT) == 0) {
+		if ((fat_classify_dentry(d) == FAT_DENTRY_LAST) ||
+		    (str_cmp((char *) d->name, FAT_NAME_DOT_DOT) == 0)) {
 			memset(d, 0, sizeof(fat_dentry_t));
-			str_cpy(d->name, 8, FAT_NAME_DOT_DOT);
-			str_cpy(d->ext, 3, FAT_EXT_PAD);
+			str_cpy((char *) d->name, 8, FAT_NAME_DOT_DOT);
+			str_cpy((char *) d->ext, 3, FAT_EXT_PAD);
 			d->attr = FAT_ATTR_SUBDIR;
 			d->firstc = (parentp->firstc == FAT_CLST_ROOT) ?
@@ -915,5 +916,5 @@
 }
 
-size_t fat_size_get(fs_node_t *fn)
+aoff64_t fat_size_get(fs_node_t *fn)
 {
 	return FAT_NODE(fn)->size;
@@ -1157,7 +1158,8 @@
 void fat_read(ipc_callid_t rid, ipc_call_t *request)
 {
-	dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
-	fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
-	off_t pos = (off_t)IPC_GET_ARG3(*request);
+	dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
+	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
+	aoff64_t pos =
+	    (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request));
 	fs_node_t *fn;
 	fat_node_t *nodep;
@@ -1223,5 +1225,5 @@
 	} else {
 		unsigned bnum;
-		off_t spos = pos;
+		aoff64_t spos = pos;
 		char name[FAT_NAME_LEN + 1 + FAT_EXT_LEN + 1];
 		fat_dentry_t *d;
@@ -1239,5 +1241,5 @@
 		bnum = (pos * sizeof(fat_dentry_t)) / bps;
 		while (bnum < nodep->size / bps) {
-			off_t o;
+			aoff64_t o;
 
 			rc = fat_block_get(&b, bs, nodep, bnum,
@@ -1295,7 +1297,8 @@
 void fat_write(ipc_callid_t rid, ipc_call_t *request)
 {
-	dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
-	fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
-	off_t pos = (off_t)IPC_GET_ARG3(*request);
+	dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
+	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
+	aoff64_t pos =
+	    (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request));
 	fs_node_t *fn;
 	fat_node_t *nodep;
@@ -1306,5 +1309,5 @@
 	unsigned spc;
 	unsigned bpc;		/* bytes per cluster */
-	off_t boundary;
+	aoff64_t boundary;
 	int flags = BLOCK_FLAGS_NONE;
 	int rc;
@@ -1452,7 +1455,8 @@
 void fat_truncate(ipc_callid_t rid, ipc_call_t *request)
 {
-	dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
-	fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
-	size_t size = (off_t)IPC_GET_ARG3(*request);
+	dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
+	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
+	aoff64_t size =
+	    (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request));
 	fs_node_t *fn;
 	fat_node_t *nodep;
Index: uspace/srv/fs/tmpfs/tmpfs.h
===================================================================
--- uspace/srv/fs/tmpfs/tmpfs.h	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/srv/fs/tmpfs/tmpfs.h	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -29,5 +29,5 @@
 /** @addtogroup fs
  * @{
- */ 
+ */
 
 #ifndef TMPFS_TMPFS_H_
@@ -40,8 +40,4 @@
 #include <bool.h>
 #include <adt/hash_table.h>
-
-#ifndef dprintf
-#define dprintf(...)	printf(__VA_ARGS__)
-#endif
 
 #define TMPFS_NODE(node)	((node) ? (tmpfs_node_t *)(node)->data : NULL)
Index: uspace/srv/fs/tmpfs/tmpfs_dump.c
===================================================================
--- uspace/srv/fs/tmpfs/tmpfs_dump.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/srv/fs/tmpfs/tmpfs_dump.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -55,6 +55,6 @@
 
 static bool
-tmpfs_restore_recursion(dev_handle_t dev, off_t *bufpos, size_t *buflen,
-    off_t *pos, fs_node_t *pfn)
+tmpfs_restore_recursion(dev_handle_t dev, size_t *bufpos, size_t *buflen,
+    aoff64_t *pos, fs_node_t *pfn)
 {
 	struct rdentry entry;
@@ -171,7 +171,7 @@
 		return false; 
 	
-	off_t bufpos = 0;
+	size_t bufpos = 0;
 	size_t buflen = 0;
-	off_t pos = 0;
+	aoff64_t pos = 0;
 	
 	char tag[6];
Index: uspace/srv/fs/tmpfs/tmpfs_ops.c
===================================================================
--- uspace/srv/fs/tmpfs/tmpfs_ops.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/srv/fs/tmpfs/tmpfs_ops.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -29,5 +29,5 @@
 /** @addtogroup fs
  * @{
- */ 
+ */
 
 /**
@@ -40,4 +40,6 @@
 #include "../../vfs/vfs.h"
 #include <ipc/ipc.h>
+#include <macros.h>
+#include <limits.h>
 #include <async.h>
 #include <errno.h>
@@ -93,5 +95,5 @@
 }
 
-static size_t tmpfs_size_get(fs_node_t *fn)
+static aoff64_t tmpfs_size_get(fs_node_t *fn)
 {
 	return TMPFS_NODE(fn)->size;
@@ -509,8 +511,9 @@
 void tmpfs_read(ipc_callid_t rid, ipc_call_t *request)
 {
-	dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
-	fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
-	off_t pos = (off_t)IPC_GET_ARG3(*request);
-
+	dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
+	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
+	aoff64_t pos =
+	    (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request));
+	
 	/*
 	 * Lookup the respective TMPFS node.
@@ -528,5 +531,5 @@
 	tmpfs_node_t *nodep = hash_table_get_instance(hlp, tmpfs_node_t,
 	    nh_link);
-
+	
 	/*
 	 * Receive the read request.
@@ -535,5 +538,5 @@
 	size_t size;
 	if (!async_data_read_receive(&callid, &size)) {
-		ipc_answer_0(callid, EINVAL);	
+		ipc_answer_0(callid, EINVAL);
 		ipc_answer_0(rid, EINVAL);
 		return;
@@ -542,5 +545,5 @@
 	size_t bytes;
 	if (nodep->type == TMPFS_FILE) {
-		bytes = max(0, min(nodep->size - pos, size));
+		bytes = min(nodep->size - pos, size);
 		(void) async_data_read_finalize(callid, nodep->data + pos,
 		    bytes);
@@ -548,5 +551,5 @@
 		tmpfs_dentry_t *dentryp;
 		link_t *lnk;
-		int i;
+		aoff64_t i;
 		
 		assert(nodep->type == TMPFS_DIRECTORY);
@@ -558,5 +561,5 @@
 		 */
 		for (i = 0, lnk = nodep->cs_head.next;
-		    i < pos && lnk != &nodep->cs_head;
+		    (i < pos) && (lnk != &nodep->cs_head);
 		    i++, lnk = lnk->next)
 			;
@@ -583,8 +586,9 @@
 void tmpfs_write(ipc_callid_t rid, ipc_call_t *request)
 {
-	dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
-	fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
-	off_t pos = (off_t)IPC_GET_ARG3(*request);
-
+	dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
+	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
+	aoff64_t pos =
+	    (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request));
+	
 	/*
 	 * Lookup the respective TMPFS node.
@@ -647,11 +651,61 @@
 void tmpfs_truncate(ipc_callid_t rid, ipc_call_t *request)
 {
+	dev_handle_t dev_handle = (dev_handle_t) IPC_GET_ARG1(*request);
+	fs_index_t index = (fs_index_t) IPC_GET_ARG2(*request);
+	aoff64_t size =
+	    (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(*request), IPC_GET_ARG4(*request));
+	
+	/*
+	 * Lookup the respective TMPFS node.
+	 */
+	unsigned long key[] = {
+		[NODES_KEY_DEV] = dev_handle,
+		[NODES_KEY_INDEX] = index
+	};
+	link_t *hlp = hash_table_find(&nodes, key);
+	if (!hlp) {
+		ipc_answer_0(rid, ENOENT);
+		return;
+	}
+	tmpfs_node_t *nodep = hash_table_get_instance(hlp, tmpfs_node_t,
+	    nh_link);
+	
+	if (size == nodep->size) {
+		ipc_answer_0(rid, EOK);
+		return;
+	}
+	
+	if (size > SIZE_MAX) {
+		ipc_answer_0(rid, ENOMEM);
+		return;
+	}
+	
+	void *newdata = realloc(nodep->data, size);
+	if (!newdata) {
+		ipc_answer_0(rid, ENOMEM);
+		return;
+	}
+	
+	if (size > nodep->size) {
+		size_t delta = size - nodep->size;
+		memset(newdata + nodep->size, 0, delta);
+	}
+	
+	nodep->size = size;
+	nodep->data = newdata;
+	ipc_answer_0(rid, EOK);
+}
+
+void tmpfs_close(ipc_callid_t rid, ipc_call_t *request)
+{
+	ipc_answer_0(rid, EOK);
+}
+
+void tmpfs_destroy(ipc_callid_t rid, ipc_call_t *request)
+{
 	dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
 	fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
-	size_t size = (off_t)IPC_GET_ARG3(*request);
-
-	/*
-	 * Lookup the respective TMPFS node.
-	 */
+	int rc;
+
 	link_t *hlp;
 	unsigned long key[] = {
@@ -666,47 +720,4 @@
 	tmpfs_node_t *nodep = hash_table_get_instance(hlp, tmpfs_node_t,
 	    nh_link);
-
-	if (size == nodep->size) {
-		ipc_answer_0(rid, EOK);
-		return;
-	}
-
-	void *newdata = realloc(nodep->data, size);
-	if (!newdata) {
-		ipc_answer_0(rid, ENOMEM);
-		return;
-	}
-	if (size > nodep->size) {
-		size_t delta = size - nodep->size;
-		memset(newdata + nodep->size, 0, delta);
-	}
-	nodep->size = size;
-	nodep->data = newdata;
-	ipc_answer_0(rid, EOK);
-}
-
-void tmpfs_close(ipc_callid_t rid, ipc_call_t *request)
-{
-	ipc_answer_0(rid, EOK);
-}
-
-void tmpfs_destroy(ipc_callid_t rid, ipc_call_t *request)
-{
-	dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
-	fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
-	int rc;
-
-	link_t *hlp;
-	unsigned long key[] = {
-		[NODES_KEY_DEV] = dev_handle,
-		[NODES_KEY_INDEX] = index
-	};
-	hlp = hash_table_find(&nodes, key);
-	if (!hlp) {
-		ipc_answer_0(rid, ENOENT);
-		return;
-	}
-	tmpfs_node_t *nodep = hash_table_get_instance(hlp, tmpfs_node_t,
-	    nh_link);
 	rc = tmpfs_destroy_node(FS_NODE(nodep));
 	ipc_answer_0(rid, rc);
Index: uspace/srv/vfs/vfs.h
===================================================================
--- uspace/srv/vfs/vfs.h	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/srv/vfs/vfs.h	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -42,8 +42,7 @@
 #include <ipc/vfs.h>
 
-// FIXME: according to CONFIG_DEBUG
-// #define dprintf(...)  printf(__VA_ARGS__)
-
-#define dprintf(...)
+#ifndef dprintf
+	#define dprintf(...)
+#endif
 
 /**
@@ -93,6 +92,6 @@
 	vfs_triplet_t triplet;
 	vfs_node_type_t type;
-	size_t size;
-	unsigned lnkcnt;
+	aoff64_t size;
+	unsigned int lnkcnt;
 } vfs_lookup_res_t;
 
@@ -117,5 +116,5 @@
 	vfs_node_type_t type;	/**< Partial info about the node type. */
 
-	size_t size;		/**< Cached size if the node is a file. */
+	aoff64_t size;		/**< Cached size if the node is a file. */
 
 	/**
@@ -141,6 +140,6 @@
 	bool append;
 
-	/** Current position in the file. */
-	off_t pos;
+	/** Current absolute position in the file. */
+	aoff64_t pos;
 } vfs_file_t;
 
@@ -214,5 +213,4 @@
 extern void vfs_truncate(ipc_callid_t, ipc_call_t *);
 extern void vfs_fstat(ipc_callid_t, ipc_call_t *);
-extern void vfs_fstat(ipc_callid_t, ipc_call_t *);
 extern void vfs_stat(ipc_callid_t, ipc_call_t *);
 extern void vfs_mkdir(ipc_callid_t, ipc_call_t *);
Index: uspace/srv/vfs/vfs_lookup.c
===================================================================
--- uspace/srv/vfs/vfs_lookup.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/srv/vfs/vfs_lookup.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -38,4 +38,5 @@
 #include "vfs.h"
 #include <ipc/ipc.h>
+#include <macros.h>
 #include <async.h>
 #include <errno.h>
@@ -99,6 +100,6 @@
 	entry.len = len;
 
-	off_t first;	/* the first free index */
-	off_t last;	/* the last free index */
+	size_t first;	/* the first free index */
+	size_t last;	/* the last free index */
 
 	if (list_empty(&plb_head)) {
@@ -177,20 +178,23 @@
 	memset(plb, 0, cnt2);
 	fibril_mutex_unlock(&plb_mutex);
-
-	if ((rc == EOK) && (result)) {
-		result->triplet.fs_handle = (fs_handle_t) IPC_GET_ARG1(answer);
-		result->triplet.dev_handle = (dev_handle_t) IPC_GET_ARG2(answer);
-		result->triplet.index = (fs_index_t) IPC_GET_ARG3(answer);
-		result->size = (size_t) IPC_GET_ARG4(answer);
-		result->lnkcnt = (unsigned) IPC_GET_ARG5(answer);
-		if (lflag & L_FILE)
-			result->type = VFS_NODE_FILE;
-		else if (lflag & L_DIRECTORY)
-			result->type = VFS_NODE_DIRECTORY;
-		else
-			result->type = VFS_NODE_UNKNOWN;
-	}
-
-	return rc;
+	
+	if (((int) rc < EOK) || (!result))
+		return (int) rc;
+	
+	result->triplet.fs_handle = (fs_handle_t) rc;
+	result->triplet.dev_handle = (dev_handle_t) IPC_GET_ARG1(answer);
+	result->triplet.index = (fs_index_t) IPC_GET_ARG2(answer);
+	result->size =
+	    (aoff64_t) MERGE_LOUP32(IPC_GET_ARG3(answer), IPC_GET_ARG4(answer));
+	result->lnkcnt = (unsigned int) IPC_GET_ARG5(answer);
+	
+	if (lflag & L_FILE)
+		result->type = VFS_NODE_FILE;
+	else if (lflag & L_DIRECTORY)
+		result->type = VFS_NODE_DIRECTORY;
+	else
+		result->type = VFS_NODE_UNKNOWN;
+	
+	return EOK;
 }
 
@@ -214,9 +218,10 @@
 	
 	if (rc == EOK) {
-		result->size = (size_t) IPC_GET_ARG1(answer);
-		result->lnkcnt = (unsigned) IPC_GET_ARG2(answer);
-		if (IPC_GET_ARG3(answer) & L_FILE)
+		result->size =
+		    MERGE_LOUP32(IPC_GET_ARG1(answer), IPC_GET_ARG2(answer));
+		result->lnkcnt = (unsigned int) IPC_GET_ARG3(answer);
+		if (IPC_GET_ARG4(answer) & L_FILE)
 			result->type = VFS_NODE_FILE;
-		else if (IPC_GET_ARG3(answer) & L_DIRECTORY)
+		else if (IPC_GET_ARG4(answer) & L_DIRECTORY)
 			result->type = VFS_NODE_DIRECTORY;
 		else
Index: uspace/srv/vfs/vfs_node.c
===================================================================
--- uspace/srv/vfs/vfs_node.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/srv/vfs/vfs_node.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -242,5 +242,5 @@
 {
 	vfs_node_t *node = hash_table_get_instance(item, vfs_node_t, nh_link);
-	return (node->fs_handle == key[KEY_FS_HANDLE]) &&
+	return (node->fs_handle == (fs_handle_t) key[KEY_FS_HANDLE]) &&
 	    (node->dev_handle == key[KEY_DEV_HANDLE]) &&
 	    (node->index == key[KEY_INDEX]);
Index: uspace/srv/vfs/vfs_ops.c
===================================================================
--- uspace/srv/vfs/vfs_ops.c	(revision b32c604f4c266680482da12fcd5d10bfc96fa4a6)
+++ uspace/srv/vfs/vfs_ops.c	(revision ed90317444652a29e89501a128d66020aaea52b5)
@@ -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;
 
