Index: uspace/srv/fs/devfs/devfs_ops.c
===================================================================
--- uspace/srv/fs/devfs/devfs_ops.c	(revision 12956e5768a7adf60aa5e6cc0a70a87007f8ccd4)
+++ uspace/srv/fs/devfs/devfs_ops.c	(revision 2dfd9fabc80d64906587ad9bcece47989019be15)
@@ -42,4 +42,5 @@
 #include <string.h>
 #include <libfs.h>
+#include <fibril_sync.h>
 #include <adt/hash_table.h>
 #include "devfs.h"
@@ -59,4 +60,7 @@
 static hash_table_t devices;
 
+/** Hash table mutex */
+static FIBRIL_MUTEX_INITIALIZE(devices_mutex);
+
 #define DEVICES_KEYS        1
 #define DEVICES_KEY_HANDLE  0
@@ -196,8 +200,10 @@
 				};
 				
+				fibril_mutex_lock(&devices_mutex);
 				link_t *lnk = hash_table_find(&devices, key);
 				if (lnk == NULL) {
 					int phone = devmap_device_connect(handle, 0);
 					if (phone < 0) {
+						fibril_mutex_unlock(&devices_mutex);
 						free(name);
 						ipc_answer_0(rid, ENOENT);
@@ -207,4 +213,5 @@
 					device_t *dev = (device_t *) malloc(sizeof(device_t));
 					if (dev == NULL) {
+						fibril_mutex_unlock(&devices_mutex);
 						free(name);
 						ipc_answer_0(rid, ENOMEM);
@@ -221,4 +228,5 @@
 					dev->refcount++;
 				}
+				fibril_mutex_unlock(&devices_mutex);
 			}
 			
@@ -239,8 +247,10 @@
 	};
 	
+	fibril_mutex_lock(&devices_mutex);
 	link_t *lnk = hash_table_find(&devices, key);
 	if (lnk == NULL) {
 		int phone = devmap_device_connect(handle, 0);
 		if (phone < 0) {
+			fibril_mutex_unlock(&devices_mutex);
 			ipc_answer_0(rid, ENOENT);
 			return;
@@ -249,4 +259,5 @@
 		device_t *dev = (device_t *) malloc(sizeof(device_t));
 		if (dev == NULL) {
+			fibril_mutex_unlock(&devices_mutex);
 			ipc_answer_0(rid, ENOMEM);
 			return;
@@ -262,4 +273,5 @@
 		dev->refcount++;
 	}
+	fibril_mutex_unlock(&devices_mutex);
 	
 	ipc_answer_3(rid, EOK, 0, 1, L_FILE);
@@ -275,9 +287,12 @@
 		};
 		
+		fibril_mutex_lock(&devices_mutex);
 		link_t *lnk = hash_table_find(&devices, key);
 		if (lnk == NULL) {
-			ipc_answer_0(rid, ENOENT);
-			return;
-		}
+			fibril_mutex_unlock(&devices_mutex);
+			ipc_answer_0(rid, ENOENT);
+			return;
+		}
+		fibril_mutex_unlock(&devices_mutex);
 		
 		ipc_answer_1(rid, EOK, (ipcarg_t) index);
@@ -296,6 +311,8 @@
 		};
 		
+		fibril_mutex_lock(&devices_mutex);
 		link_t *lnk = hash_table_find(&devices, key);
 		if (lnk == NULL) {
+			fibril_mutex_unlock(&devices_mutex);
 			ipc_answer_0(rid, ENOENT);
 			return;
@@ -306,4 +323,5 @@
 		ipc_callid_t callid;
 		if (!ipc_data_read_receive(&callid, NULL)) {
+			fibril_mutex_unlock(&devices_mutex);
 			ipc_answer_0(callid, EINVAL);
 			ipc_answer_0(rid, EINVAL);
@@ -319,4 +337,5 @@
 		/* Forward the IPC_M_DATA_READ request to the driver */
 		ipc_forward_fast(callid, dev->phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
+		fibril_mutex_unlock(&devices_mutex);
 		
 		/* Wait for reply from the driver. */
@@ -370,6 +389,8 @@
 		};
 		
+		fibril_mutex_lock(&devices_mutex);
 		link_t *lnk = hash_table_find(&devices, key);
 		if (lnk == NULL) {
+			fibril_mutex_unlock(&devices_mutex);
 			ipc_answer_0(rid, ENOENT);
 			return;
@@ -380,4 +401,5 @@
 		ipc_callid_t callid;
 		if (!ipc_data_write_receive(&callid, NULL)) {
+			fibril_mutex_unlock(&devices_mutex);
 			ipc_answer_0(callid, EINVAL);
 			ipc_answer_0(rid, EINVAL);
@@ -394,4 +416,6 @@
 		ipc_forward_fast(callid, dev->phone, 0, 0, 0, IPC_FF_ROUTE_FROM_ME);
 		
+		fibril_mutex_unlock(&devices_mutex);
+		
 		/* Wait for reply from the driver. */
 		ipcarg_t rc;
@@ -421,6 +445,8 @@
 		};
 		
+		fibril_mutex_lock(&devices_mutex);
 		link_t *lnk = hash_table_find(&devices, key);
 		if (lnk == NULL) {
+			fibril_mutex_unlock(&devices_mutex);
 			ipc_answer_0(rid, ENOENT);
 			return;
@@ -434,4 +460,6 @@
 			hash_table_remove(&devices, key, DEVICES_KEYS);
 		}
+		
+		fibril_mutex_unlock(&devices_mutex);
 		
 		ipc_answer_0(rid, EOK);
@@ -449,6 +477,8 @@
 		};
 		
+		fibril_mutex_lock(&devices_mutex);
 		link_t *lnk = hash_table_find(&devices, key);
 		if (lnk == NULL) {
+			fibril_mutex_unlock(&devices_mutex);
 			ipc_answer_0(rid, ENOENT);
 			return;
@@ -462,4 +492,6 @@
 		    IPC_GET_ARG1(*request), IPC_GET_ARG2(*request), &answer);
 		
+		fibril_mutex_unlock(&devices_mutex);
+		
 		/* Wait for reply from the driver */
 		ipcarg_t rc;
