Index: uspace/lib/libc/generic/vfs/vfs.c
===================================================================
--- uspace/lib/libc/generic/vfs/vfs.c	(revision b39fd4c573be61dbccb170662ee0255e4e8814b1)
+++ uspace/lib/libc/generic/vfs/vfs.c	(revision d44aabd50e603bb6fa7604765bf80addb1023595)
@@ -122,4 +122,5 @@
 	int res;
 	ipcarg_t rc;
+	ipcarg_t rc_orig;
 	aid_t req;
 	dev_handle_t dev_handle;
@@ -141,27 +142,36 @@
 	rc = ipc_data_write_start(vfs_phone, (void *) mpa, mpa_size);
 	if (rc != EOK) {
-		async_wait_for(req, NULL);
+		async_wait_for(req, &rc_orig);
 		async_serialize_end();
 		futex_up(&vfs_phone_futex);
 		free(mpa);
-		return (int) rc;
+		if (rc_orig == EOK)
+			return (int) rc;
+		else
+			return (int) rc_orig;
 	}
 	
 	rc = ipc_data_write_start(vfs_phone, (void *) opts, str_size(opts));
 	if (rc != EOK) {
-		async_wait_for(req, NULL);
+		async_wait_for(req, &rc_orig);
 		async_serialize_end();
 		futex_up(&vfs_phone_futex);
 		free(mpa);
-		return (int) rc;
+		if (rc_orig == EOK)
+			return (int) rc;
+		else
+			return (int) rc_orig;
 	}
 
 	rc = ipc_data_write_start(vfs_phone, (void *) fs_name, str_size(fs_name));
 	if (rc != EOK) {
-		async_wait_for(req, NULL);
+		async_wait_for(req, &rc_orig);
 		async_serialize_end();
 		futex_up(&vfs_phone_futex);
 		free(mpa);
-		return (int) rc;
+		if (rc_orig == EOK)
+			return (int) rc;
+		else
+			return (int) rc_orig;
 	}
 
@@ -169,9 +179,12 @@
 	rc = async_req_0_0(vfs_phone, IPC_M_PING);
 	if (rc != EOK) {
-		async_wait_for(req, NULL);
+		async_wait_for(req, &rc_orig);
 		async_serialize_end();
 		futex_up(&vfs_phone_futex);
 		free(mpa);
-		return (int) rc;
+		if (rc_orig == EOK)
+			return (int) rc;
+		else
+			return (int) rc_orig;
 	}
 	
@@ -202,9 +215,14 @@
 	rc = ipc_data_write_start(vfs_phone, pa, pa_size);
 	if (rc != EOK) {
-		async_wait_for(req, NULL);
+		ipcarg_t rc_orig;
+	
+		async_wait_for(req, &rc_orig);
 		async_serialize_end();
 		futex_up(&vfs_phone_futex);
 		free(pa);
-		return (int) rc;
+		if (rc_orig == EOK)
+			return (int) rc;
+		else
+			return (int) rc_orig;
 	}
 	async_wait_for(req, &rc);
@@ -240,5 +258,5 @@
 	
 	if (rc != EOK)
-	    return (int) rc;
+		return (int) rc;
 	
 	return (int) IPC_GET_ARG1(answer);
@@ -274,8 +292,13 @@
 	rc = ipc_data_read_start(vfs_phone, (void *)buf, nbyte);
 	if (rc != EOK) {
-		async_wait_for(req, NULL);
-		async_serialize_end();
-		futex_up(&vfs_phone_futex);
-		return (ssize_t) rc;
+		ipcarg_t rc_orig;
+	
+		async_wait_for(req, &rc_orig);
+		async_serialize_end();
+		futex_up(&vfs_phone_futex);
+		if (rc_orig == EOK)
+			return (ssize_t) rc;
+		else
+			return (ssize_t) rc_orig;
 	}
 	async_wait_for(req, &rc);
@@ -301,8 +324,13 @@
 	rc = ipc_data_write_start(vfs_phone, (void *)buf, nbyte);
 	if (rc != EOK) {
-		async_wait_for(req, NULL);
-		async_serialize_end();
-		futex_up(&vfs_phone_futex);
-		return (ssize_t) rc;
+		ipcarg_t rc_orig;
+	
+		async_wait_for(req, &rc_orig);
+		async_serialize_end();
+		futex_up(&vfs_phone_futex);
+		if (rc_orig == EOK)
+			return (ssize_t) rc;
+		else
+			return (ssize_t) rc_orig;
 	}
 	async_wait_for(req, &rc);
@@ -376,8 +404,13 @@
 	rc = ipc_data_read_start(vfs_phone, (void *)stat, sizeof(struct stat));
 	if (rc != EOK) {
-		async_wait_for(req, NULL);
-		async_serialize_end();
-		futex_up(&vfs_phone_futex);
-		return (ssize_t) rc;
+		ipcarg_t rc_orig;
+		
+		async_wait_for(req, &rc_orig);
+		async_serialize_end();
+		futex_up(&vfs_phone_futex);
+		if (rc_orig == EOK)
+			return (ssize_t) rc;
+		else
+			return (ssize_t) rc_orig;
 	}
 	async_wait_for(req, &rc);
@@ -391,4 +424,5 @@
 {
 	ipcarg_t rc;
+	ipcarg_t rc_orig;
 	aid_t req;
 	
@@ -405,17 +439,23 @@
 	rc = ipc_data_write_start(vfs_phone, pa, pa_size);
 	if (rc != EOK) {
-		async_wait_for(req, NULL);
+		async_wait_for(req, &rc_orig);
 		async_serialize_end();
 		futex_up(&vfs_phone_futex);
 		free(pa);
-		return (int) rc;
+		if (rc_orig == EOK)
+			return (int) rc;
+		else
+			return (int) rc_orig;
 	}
 	rc = ipc_data_read_start(vfs_phone, stat, sizeof(struct stat));
 	if (rc != EOK) {
-		async_wait_for(req, NULL);
+		async_wait_for(req, &rc_orig);
 		async_serialize_end();
 		futex_up(&vfs_phone_futex);
 		free(pa);
-		return (int) rc;
+		if (rc_orig == EOK)
+			return (int) rc;
+		else
+			return (int) rc_orig;
 	}
 	async_wait_for(req, &rc);
@@ -476,9 +516,14 @@
 	rc = ipc_data_write_start(vfs_phone, pa, pa_size);
 	if (rc != EOK) {
-		async_wait_for(req, NULL);
+		ipcarg_t rc_orig;
+	
+		async_wait_for(req, &rc_orig);
 		async_serialize_end();
 		futex_up(&vfs_phone_futex);
 		free(pa);
-		return (int) rc;
+		if (rc_orig == EOK)
+			return (int) rc;
+		else
+			return (int) rc_orig;
 	}
 	async_wait_for(req, &rc);
@@ -506,9 +551,14 @@
 	rc = ipc_data_write_start(vfs_phone, pa, pa_size);
 	if (rc != EOK) {
-		async_wait_for(req, NULL);
+		ipcarg_t rc_orig;
+
+		async_wait_for(req, &rc_orig);
 		async_serialize_end();
 		futex_up(&vfs_phone_futex);
 		free(pa);
-		return (int) rc;
+		if (rc_orig == EOK)
+			return (int) rc;
+		else
+			return (int) rc_orig;
 	}
 	async_wait_for(req, &rc);
@@ -532,4 +582,5 @@
 {
 	ipcarg_t rc;
+	ipcarg_t rc_orig;
 	aid_t req;
 	
@@ -553,19 +604,25 @@
 	rc = ipc_data_write_start(vfs_phone, olda, olda_size);
 	if (rc != EOK) {
-		async_wait_for(req, NULL);
+		async_wait_for(req, &rc_orig);
 		async_serialize_end();
 		futex_up(&vfs_phone_futex);
 		free(olda);
 		free(newa);
-		return (int) rc;
+		if (rc_orig == EOK)
+			return (int) rc;
+		else
+			return (int) rc_orig;
 	}
 	rc = ipc_data_write_start(vfs_phone, newa, newa_size);
 	if (rc != EOK) {
-		async_wait_for(req, NULL);
+		async_wait_for(req, &rc_orig);
 		async_serialize_end();
 		futex_up(&vfs_phone_futex);
 		free(olda);
 		free(newa);
-		return (int) rc;
+		if (rc_orig == EOK)
+			return (int) rc;
+		else
+			return (int) rc_orig;
 	}
 	async_wait_for(req, &rc);
