Index: uspace/srv/vfs/vfs_ops.c
===================================================================
--- uspace/srv/vfs/vfs_ops.c	(revision 8e13bfa2344d2b8510e837a480130cd89f361759)
+++ uspace/srv/vfs/vfs_ops.c	(revision c07af370ce0770ecdcd7812570f8670b059c435b)
@@ -67,5 +67,6 @@
 } pending_req_t;
 
-FIBRIL_MUTEX_INITIALIZE(pending_lock);
+FIBRIL_CONDVAR_INITIALIZE(pending_cv);
+bool pending_new_fs = false;	/**< True if a new file system was mounted. */
 LIST_INITIALIZE(pending_req);
 
@@ -264,30 +265,39 @@
 	link_t *cur;
 	
-loop:
-	fibril_mutex_lock(&pending_lock);
-	for (cur = pending_req.next; cur != &pending_req; cur = cur->next) {
-		pending_req_t *pr = list_get_instance(cur, pending_req_t, link);
-
-		fs_handle_t fs_handle = fs_name_to_handle(pr->fs_name, true);
-		if (!fs_handle)
-			continue;
+	while (true) {
+		fibril_mutex_lock(&fs_head_lock);
+		while (!pending_new_fs)
+			fibril_condvar_wait(&pending_cv, &fs_head_lock);
+rescan:
+		for (cur = pending_req.next; cur != &pending_req;
+		    cur = cur->next) {
+			pending_req_t *pr = list_get_instance(cur,
+			    pending_req_t, link);
+			fs_handle_t fs_handle = fs_name_to_handle(pr->fs_name,
+			    false);
+			if (!fs_handle)
+				continue;
 		
-		/* Acknowledge that we know fs_name. */
-		ipc_answer_0(pr->callid, EOK);
+			/* Acknowledge that we know fs_name. */
+			ipc_answer_0(pr->callid, EOK);
 		
-		/* Do the mount */
-		vfs_mount_internal(pr->rid, pr->dev_handle, fs_handle, pr->mp,
-		    pr->opts);
+			list_remove(cur);
+			fibril_mutex_unlock(&fs_head_lock);
+			
+			/* Do the mount */
+			vfs_mount_internal(pr->rid, pr->dev_handle, fs_handle,
+			    pr->mp, pr->opts);
+
+			free(pr->fs_name);
+			free(pr->mp);
+			free(pr->opts);
+			free(pr);
 		
-		free(pr->fs_name);
-		free(pr->mp);
-		free(pr->opts);
-		list_remove(cur);
-		free(pr);
-		fibril_mutex_unlock(&pending_lock);
-		fibril_yield();
-		goto loop;
-	}
-	fibril_mutex_unlock(&pending_lock);
+			fibril_mutex_lock(&fs_head_lock);
+			goto rescan;
+		}
+		pending_new_fs = false;
+		fibril_mutex_unlock(&fs_head_lock);
+	}
 }
 
@@ -445,5 +455,6 @@
 	 * This will also give us its file system handle.
 	 */
-	fs_handle_t fs_handle = fs_name_to_handle(fs_name, true);
+	fibril_mutex_lock(&fs_head_lock);
+	fs_handle_t fs_handle = fs_name_to_handle(fs_name, false);
 	if (!fs_handle) {
 		if (flags & IPC_FLAG_BLOCKING) {
@@ -453,4 +464,5 @@
 			pr = (pending_req_t *) malloc(sizeof(pending_req_t));
 			if (!pr) {
+				fibril_mutex_unlock(&fs_head_lock);
 				ipc_answer_0(callid, ENOMEM);
 				ipc_answer_0(rid, ENOMEM);
@@ -468,10 +480,10 @@
 			pr->dev_handle = dev_handle;
 			link_initialize(&pr->link);
-			fibril_mutex_lock(&pending_lock);
 			list_append(&pr->link, &pending_req);
-			fibril_mutex_unlock(&pending_lock);
+			fibril_mutex_unlock(&fs_head_lock);
 			return;
 		}
 		
+		fibril_mutex_unlock(&fs_head_lock);
 		ipc_answer_0(callid, ENOENT);
 		ipc_answer_0(rid, ENOENT);
@@ -481,4 +493,5 @@
 		return;
 	}
+	fibril_mutex_unlock(&fs_head_lock);
 	
 	/* Acknowledge that we know fs_name. */
