Index: uspace/srv/fs/tmpfs/tmpfs.h
===================================================================
--- uspace/srv/fs/tmpfs/tmpfs.h	(revision 8ad8e497df247137deeedbbf79a2f30e414fdcff)
+++ uspace/srv/fs/tmpfs/tmpfs.h	(revision baac91190efc683948e46ad8fc0384ce74181ea5)
@@ -44,5 +44,5 @@
 
 typedef struct tmpfs_dentry {
-	unsigned long index;	/**< TMPFS node index. */
+	fs_index_t index;	/**< TMPFS node index. */
 	link_t dh_link;		/**< Dentries hash table link. */
 	struct tmpfs_dentry *sibling;
Index: uspace/srv/fs/tmpfs/tmpfs_ops.c
===================================================================
--- uspace/srv/fs/tmpfs/tmpfs_ops.c	(revision 8ad8e497df247137deeedbbf79a2f30e414fdcff)
+++ uspace/srv/fs/tmpfs/tmpfs_ops.c	(revision baac91190efc683948e46ad8fc0384ce74181ea5)
@@ -71,5 +71,5 @@
 /* Forward declarations of static functions. */
 static bool tmpfs_match(void *, void *, const char *);
-static void *tmpfs_node_get(int, int, unsigned long);
+static void *tmpfs_node_get(fs_handle_t, dev_handle_t, fs_index_t);
 static void *tmpfs_create_node(int);
 static bool tmpfs_link_node(void *, void *, const char *);
@@ -78,10 +78,10 @@
 
 /* Implementation of helper functions. */
-static unsigned long tmpfs_index_get(void *nodep)
+static fs_index_t tmpfs_index_get(void *nodep)
 {
 	return ((tmpfs_dentry_t *) nodep)->index;
 }
 
-static unsigned long tmpfs_size_get(void *nodep)
+static size_t tmpfs_size_get(void *nodep)
 {
 	return ((tmpfs_dentry_t *) nodep)->size;
@@ -170,5 +170,5 @@
 };
 
-unsigned tmpfs_next_index = 1;
+fs_index_t tmpfs_next_index = 1;
 
 typedef struct {
@@ -263,7 +263,9 @@
 }
 
-void *tmpfs_node_get(int fs_handle, int dev_handle, unsigned long index)
-{
-	link_t *lnk = hash_table_find(&dentries, &index);
+void *
+tmpfs_node_get(fs_handle_t fs_handle, dev_handle_t dev_handle, fs_index_t index)
+{
+	unsigned long key = index;
+	link_t *lnk = hash_table_find(&dentries, &key);
 	if (!lnk)
 		return NULL;
@@ -290,5 +292,6 @@
 
 	/* Insert the new node into the dentry hash table. */
-	hash_table_insert(&dentries, &node->index, &node->dh_link);
+	unsigned long key = node->index;
+	hash_table_insert(&dentries, &key, &node->dh_link);
 	return (void *) node;
 }
@@ -370,6 +373,6 @@
 	assert(!dentry->sibling);
 
-	unsigned long index = dentry->index;
-	hash_table_remove(&dentries, &index, 1);
+	unsigned long key = dentry->index;
+	hash_table_remove(&dentries, &key, 1);
 
 	hash_table_destroy(&dentry->names);
@@ -392,7 +395,7 @@
 void tmpfs_read(ipc_callid_t rid, ipc_call_t *request)
 {
-	int dev_handle = IPC_GET_ARG1(*request);
-	unsigned long index = IPC_GET_ARG2(*request);
-	off_t pos = 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);
+	off_t pos = (off_t)IPC_GET_ARG3(*request);
 
 	/*
@@ -400,5 +403,6 @@
 	 */
 	link_t *hlp;
-	hlp = hash_table_find(&dentries, &index);
+	unsigned long key = index;
+	hlp = hash_table_find(&dentries, &key);
 	if (!hlp) {
 		ipc_answer_0(rid, ENOENT);
@@ -464,7 +468,7 @@
 void tmpfs_write(ipc_callid_t rid, ipc_call_t *request)
 {
-	int dev_handle = IPC_GET_ARG1(*request);
-	unsigned long index = IPC_GET_ARG2(*request);
-	off_t pos = 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);
+	off_t pos = (off_t)IPC_GET_ARG3(*request);
 
 	/*
@@ -472,5 +476,6 @@
 	 */
 	link_t *hlp;
-	hlp = hash_table_find(&dentries, &index);
+	unsigned long key = index;
+	hlp = hash_table_find(&dentries, &key);
 	if (!hlp) {
 		ipc_answer_0(rid, ENOENT);
@@ -524,7 +529,7 @@
 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);
+	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);
 
 	/*
@@ -532,5 +537,6 @@
 	 */
 	link_t *hlp;
-	hlp = hash_table_find(&dentries, &index);
+	unsigned long key = index;
+	hlp = hash_table_find(&dentries, &key);
 	if (!hlp) {
 		ipc_answer_0(rid, ENOENT);
@@ -561,9 +567,10 @@
 void tmpfs_destroy(ipc_callid_t rid, ipc_call_t *request)
 {
-	int dev_handle = IPC_GET_ARG1(*request);
-	unsigned long index = IPC_GET_ARG2(*request);
+	dev_handle_t dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
+	fs_index_t index = (fs_index_t)IPC_GET_ARG2(*request);
 
 	link_t *hlp;
-	hlp = hash_table_find(&dentries, &index);
+	unsigned long key = index;
+	hlp = hash_table_find(&dentries, &key);
 	if (!hlp) {
 		ipc_answer_0(rid, ENOENT);
Index: uspace/srv/vfs/vfs.h
===================================================================
--- uspace/srv/vfs/vfs.h	(revision 8ad8e497df247137deeedbbf79a2f30e414fdcff)
+++ uspace/srv/vfs/vfs.h	(revision baac91190efc683948e46ad8fc0384ce74181ea5)
@@ -47,4 +47,9 @@
 #define IPC_METHOD_TO_VFS_OP(m)	((m) - VFS_FIRST)	
 
+/* Basic types. */
+typedef int16_t fs_handle_t;
+typedef int16_t dev_handle_t;
+typedef uint32_t fs_index_t;
+
 typedef enum {
 	VFS_READ = VFS_FIRST,
@@ -107,5 +112,5 @@
 	link_t fs_link;
 	vfs_info_t vfs_info;
-	int fs_handle;
+	fs_handle_t fs_handle;
 	futex_t phone_futex;	/**< Phone serializing futex. */
 	ipcarg_t phone;
@@ -115,7 +120,7 @@
  * VFS_PAIR uniquely represents a file system instance.
  */
-#define VFS_PAIR	\
-	int fs_handle;	\
-	int dev_handle;	
+#define VFS_PAIR		\
+	fs_handle_t fs_handle;	\
+	dev_handle_t dev_handle;
 
 /**
@@ -128,5 +133,5 @@
 #define VFS_TRIPLET	\
 	VFS_PAIR;	\
-	uint64_t index;
+	fs_index_t index;
 
 typedef struct {
@@ -257,8 +262,8 @@
 extern rwlock_t namespace_rwlock;
 
-extern int vfs_grab_phone(int);
+extern int vfs_grab_phone(fs_handle_t);
 extern void vfs_release_phone(int);
 
-extern int fs_name_to_handle(char *, bool);
+extern fs_handle_t fs_name_to_handle(char *, bool);
 
 extern int vfs_lookup_internal(char *, int, vfs_lookup_res_t *, vfs_pair_t *,
Index: uspace/srv/vfs/vfs_lookup.c
===================================================================
--- uspace/srv/vfs/vfs_lookup.c	(revision 8ad8e497df247137deeedbbf79a2f30e414fdcff)
+++ uspace/srv/vfs/vfs_lookup.c	(revision baac91190efc683948e46ad8fc0384ce74181ea5)
@@ -83,10 +83,10 @@
 		return EINVAL;
 	
-	uint64_t index = 0;
+	fs_index_t index = 0;
 	if (lflag & L_LINK) {
 		va_list ap;
 
 		va_start(ap, altroot);
-		index = va_arg(ap, uint64_t);
+		index = va_arg(ap, fs_index_t);
 		va_end(ap);
 	}
@@ -178,7 +178,7 @@
 
 	if ((rc == EOK) && result) {
-		result->triplet.fs_handle = (int) IPC_GET_ARG1(answer);
-		result->triplet.dev_handle = (int) IPC_GET_ARG2(answer);
-		result->triplet.index = (uint64_t) IPC_GET_ARG3(answer);
+		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);
Index: uspace/srv/vfs/vfs_ops.c
===================================================================
--- uspace/srv/vfs/vfs_ops.c	(revision 8ad8e497df247137deeedbbf79a2f30e414fdcff)
+++ uspace/srv/vfs/vfs_ops.c	(revision baac91190efc683948e46ad8fc0384ce74181ea5)
@@ -54,5 +54,5 @@
 
 /* Forward declarations of static functions. */
-static int vfs_truncate_internal(int, int, unsigned long, size_t);
+static int vfs_truncate_internal(fs_handle_t, dev_handle_t, fs_index_t, size_t);
 
 /**
@@ -69,5 +69,7 @@
 };
 
-static int lookup_root(int fs_handle, int dev_handle, vfs_lookup_res_t *result)
+static int
+lookup_root(fs_handle_t fs_handle, dev_handle_t dev_handle,
+    vfs_lookup_res_t *result)
 {
 	vfs_pair_t altroot = {
@@ -81,5 +83,5 @@
 void vfs_mount(ipc_callid_t rid, ipc_call_t *request)
 {
-	int dev_handle;
+	dev_handle_t dev_handle;
 	vfs_node_t *mp_node = NULL;
 
@@ -89,5 +91,5 @@
 	 * in the request.
 	 */
-	dev_handle = IPC_GET_ARG1(*request);
+	dev_handle = (dev_handle_t)IPC_GET_ARG1(*request);
 
 	/*
@@ -128,5 +130,5 @@
 	 * This will also give us its file system handle.
 	 */
-	int fs_handle = fs_name_to_handle(fs_name, true);
+	fs_handle_t fs_handle = fs_name_to_handle(fs_name, true);
 	if (!fs_handle) {
 		ipc_answer_0(rid, ENOENT);
@@ -572,6 +574,7 @@
 }
 
-int vfs_truncate_internal(int fs_handle, int dev_handle, unsigned long index,
-    size_t size)
+int
+vfs_truncate_internal(fs_handle_t fs_handle, dev_handle_t dev_handle,
+    fs_index_t index, size_t size)
 {
 	ipcarg_t rc;
Index: uspace/srv/vfs/vfs_register.c
===================================================================
--- uspace/srv/vfs/vfs_register.c	(revision 8ad8e497df247137deeedbbf79a2f30e414fdcff)
+++ uspace/srv/vfs/vfs_register.c	(revision baac91190efc683948e46ad8fc0384ce74181ea5)
@@ -295,5 +295,5 @@
 	 * system a global file system handle.
 	 */
-	fs_info->fs_handle = (int) atomic_postinc(&fs_handle_next);
+	fs_info->fs_handle = (fs_handle_t) atomic_postinc(&fs_handle_next);
 	ipc_answer_1(rid, EOK, (ipcarg_t) fs_info->fs_handle);
 	
@@ -312,5 +312,5 @@
  *			sent. Return 0 if no phone was found.
  */
-int vfs_grab_phone(int handle)
+int vfs_grab_phone(fs_handle_t handle)
 {
 	/*
@@ -387,5 +387,5 @@
  * @return		File system handle or zero if file system not found.
  */
-int fs_name_to_handle(char *name, bool lock)
+fs_handle_t fs_name_to_handle(char *name, bool lock)
 {
 	int handle = 0;
