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);
