Index: uspace/srv/vfs/vfs_register.c
===================================================================
--- uspace/srv/vfs/vfs_register.c	(revision d9c8c81f21850cb9e08890ce3919e1d8e253e810)
+++ uspace/srv/vfs/vfs_register.c	(revision 0e31a2bc6d1fecb2d1fd60c2eb47eed52130f540)
@@ -46,5 +46,5 @@
 #include <ctype.h>
 #include <bool.h>
-#include <futex.h>
+#include <fibril_sync.h>
 #include <adt/list.h>
 #include <as.h>
@@ -53,5 +53,5 @@
 #include "vfs.h"
 
-atomic_t fs_head_futex = FUTEX_INITIALIZER;
+FIBRIL_MUTEX_INITIALIZE(fs_head_lock);
 link_t fs_head;
 
@@ -160,5 +160,5 @@
 	}
 	link_initialize(&fs_info->fs_link);
-	futex_initialize(&fs_info->phone_futex, 1);
+	fibril_mutex_initialize(&fs_info->phone_lock);
 		
 	rc = ipc_data_write_finalize(callid, &fs_info->vfs_info, size);
@@ -181,6 +181,5 @@
 	}
 		
-	futex_down(&fs_head_futex);
-	fibril_inc_sercount();
+	fibril_mutex_lock(&fs_head_lock);
 
 	/*
@@ -192,6 +191,5 @@
 		 */
 		dprintf("FS is already registered.\n");
-		fibril_dec_sercount();
-		futex_up(&fs_head_futex);
+		fibril_mutex_unlock(&fs_head_lock);
 		free(fs_info);
 		ipc_answer_0(callid, EEXISTS);
@@ -215,6 +213,5 @@
 		dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call));
 		list_remove(&fs_info->fs_link);
-		fibril_dec_sercount();
-		futex_up(&fs_head_futex);
+		fibril_mutex_unlock(&fs_head_lock);
 		free(fs_info);
 		ipc_answer_0(callid, EINVAL);
@@ -234,6 +231,5 @@
 		dprintf("Unexpected call, method = %d\n", IPC_GET_METHOD(call));
 		list_remove(&fs_info->fs_link);
-		fibril_dec_sercount();
-		futex_up(&fs_head_futex);
+		fibril_mutex_unlock(&fs_head_lock);
 		ipc_hangup(fs_info->phone);
 		free(fs_info);
@@ -249,6 +245,5 @@
 		dprintf("Client suggests wrong size of PFB, size = %d\n", size);
 		list_remove(&fs_info->fs_link);
-		fibril_dec_sercount();
-		futex_up(&fs_head_futex);
+		fibril_mutex_unlock(&fs_head_lock);
 		ipc_hangup(fs_info->phone);
 		free(fs_info);
@@ -274,6 +269,5 @@
 	ipc_answer_1(rid, EOK, (ipcarg_t) fs_info->fs_handle);
 	
-	fibril_dec_sercount();
-	futex_up(&fs_head_futex);
+	fibril_mutex_unlock(&fs_head_lock);
 	
 	dprintf("\"%.*s\" filesystem successfully registered, handle=%d.\n",
@@ -298,5 +292,5 @@
 	 * phone_futex and keep it until vfs_release_phone().
 	 */
-	futex_down(&fs_head_futex);
+	fibril_mutex_lock(&fs_head_lock);
 	link_t *cur;
 	fs_info_t *fs;
@@ -304,20 +298,10 @@
 		fs = list_get_instance(cur, fs_info_t, fs_link);
 		if (fs->fs_handle == handle) {
-			futex_up(&fs_head_futex);
-			/*
-			 * For now, take the futex unconditionally.
-			 * Oh yeah, serialization rocks.
-			 * It will be up'ed in vfs_release_phone().
-			 */
-			futex_down(&fs->phone_futex);
-			/*
-			 * Avoid deadlock with other fibrils in the same thread
-			 * by disabling fibril preemption.
-			 */
-			fibril_inc_sercount();
+			fibril_mutex_unlock(&fs_head_lock);
+			fibril_mutex_lock(&fs->phone_lock);
 			return fs->phone;
 		}
 	}
-	futex_up(&fs_head_futex);
+	fibril_mutex_unlock(&fs_head_lock);
 	return 0;
 }
@@ -331,10 +315,5 @@
 	bool found = false;
 
-	/*
-	 * Undo the fibril_inc_sercount() done in vfs_grab_phone().
-	 */
-	fibril_dec_sercount();
-	
-	futex_down(&fs_head_futex);
+	fibril_mutex_lock(&fs_head_lock);
 	link_t *cur;
 	for (cur = fs_head.next; cur != &fs_head; cur = cur->next) {
@@ -342,10 +321,10 @@
 		if (fs->phone == phone) {
 			found = true;
-			futex_up(&fs_head_futex);
-			futex_up(&fs->phone_futex);
+			fibril_mutex_unlock(&fs_head_lock);
+			fibril_mutex_unlock(&fs->phone_lock);
 			return;
 		}
 	}
-	futex_up(&fs_head_futex);
+	fibril_mutex_unlock(&fs_head_lock);
 
 	/*
@@ -358,6 +337,6 @@
  *
  * @param name		File system name.
- * @param lock		If true, the function will down and up the
- * 			fs_head_futex.
+ * @param lock		If true, the function will lock and unlock the
+ * 			fs_head_lock.
  *
  * @return		File system handle or zero if file system not found.
@@ -368,5 +347,5 @@
 	
 	if (lock)
-		futex_down(&fs_head_futex);
+		fibril_mutex_lock(&fs_head_lock);
 	link_t *cur;
 	for (cur = fs_head.next; cur != &fs_head; cur = cur->next) {
@@ -378,5 +357,5 @@
 	}
 	if (lock)
-		futex_up(&fs_head_futex);
+		fibril_mutex_unlock(&fs_head_lock);
 	return handle;
 }
