Index: uspace/srv/devmap/devmap.c
===================================================================
--- uspace/srv/devmap/devmap.c	(revision fc02cc41db04c79320221b96cb18bb2f916994a7)
+++ uspace/srv/devmap/devmap.c	(revision e3fa92aaa41787bed20718704bd6b84b16ec69f4)
@@ -46,4 +46,5 @@
 #include <string.h>
 #include <ipc/devmap.h>
+#include <assert.h>
 
 #define NAME  "devmap"
@@ -95,4 +96,7 @@
 LIST_INITIALIZE(pending_req);
 
+static bool pending_new_dev = false;
+static FIBRIL_CONDVAR_INITIALIZE(pending_cv);
+
 /* Locking order:
  *  drivers_list_mutex
@@ -175,8 +179,6 @@
 
 /**
- *
  * Unregister device and free it. It's assumed that driver's device list is
  * already locked.
- *
  */
 static int devmap_device_unregister_core(devmap_device_t *device)
@@ -192,8 +194,6 @@
 
 /**
- *
  * Read info about new driver and add it into linked list of registered
  * drivers.
- *
  */
 static void devmap_driver_register(devmap_driver_t **odriver)
@@ -350,6 +350,10 @@
 {
 	link_t *cur;
-	
+
 loop:
+	fibril_mutex_lock(&devices_list_mutex);
+	while (!pending_new_dev)
+		fibril_condvar_wait(&pending_cv, &devices_list_mutex);
+rescan:
 	for (cur = pending_req.next; cur != &pending_req; cur = cur->next) {
 		pending_req_t *pr = list_get_instance(cur, pending_req_t, link);
@@ -365,6 +369,9 @@
 		free(pr);
 		
-		goto loop;
-	}
+		goto rescan;
+	}
+	pending_new_dev = false;
+	fibril_mutex_unlock(&devices_list_mutex);
+	goto loop;
 }
 
@@ -446,4 +453,6 @@
 	
 	fibril_mutex_unlock(&device->driver->devices_mutex);
+	pending_new_dev = true;
+	fibril_condvar_signal(&pending_cv);
 	fibril_mutex_unlock(&devices_list_mutex);
 	
@@ -531,4 +540,6 @@
 	name[size] = '\0';
 	
+	fibril_mutex_lock(&devices_list_mutex);
+
 	/*
 	 * Find device name in linked list of known devices.
@@ -544,4 +555,5 @@
 			pending_req_t *pr = (pending_req_t *) malloc(sizeof(pending_req_t));
 			if (!pr) {
+				fibril_mutex_unlock(&devices_list_mutex);
 				ipc_answer_0(iid, ENOMEM);
 				free(name);
@@ -552,4 +564,5 @@
 			pr->callid = iid;
 			list_append(&pr->link, &pending_req);
+			fibril_mutex_unlock(&devices_list_mutex);
 			return;
 		}
@@ -557,6 +570,8 @@
 		ipc_answer_0(iid, ENOENT);
 		free(name);
-		return;
-	}
+		fibril_mutex_unlock(&devices_list_mutex);
+		return;
+	}
+	fibril_mutex_unlock(&devices_list_mutex);
 	
 	ipc_answer_1(iid, EOK, dev->handle);
@@ -660,5 +675,5 @@
  *
  */
-static bool devmap_init()
+static bool devmap_init(void)
 {
 	/* Create NULL device entry */
@@ -819,8 +834,11 @@
 	}
 	
-	/* Set a handler of incomming connections and
-	   pending operations */
-	async_set_pending(process_pending_lookup);
+	/* Set a handler of incomming connections */
 	async_set_client_connection(devmap_connection);
+
+	/* Create a fibril for handling pending device lookups */
+	fid_t fid = fibril_create(process_pending_lookup, NULL);
+	assert(fid);
+	fibril_add_ready(fid);
 	
 	/* Register device mapper at naming service */
