Index: uspace/lib/libc/generic/vfs/vfs.c
===================================================================
--- uspace/lib/libc/generic/vfs/vfs.c	(revision a8e9ab8dd2fc2d06e904785bacded96f27319e6c)
+++ uspace/lib/libc/generic/vfs/vfs.c	(revision ca21eb4b0114436f191b23c766e2d2e6187ca7d0)
@@ -40,4 +40,5 @@
 #include <fcntl.h>
 #include <sys/stat.h>
+#include <stdio.h>
 #include <sys/types.h>
 #include <ipc/ipc.h>
@@ -58,5 +59,5 @@
 size_t cwd_len = 0; 
 
-static char *absolutize(const char *path)
+static char *absolutize(const char *path, size_t *retlen)
 {
 	char *ncwd_path;
@@ -86,4 +87,9 @@
 	}
 	strcat(ncwd_path, path);
+	if (!canonify(ncwd_path, retlen)) {
+		futex_up(&cwd_futex);
+		free(ncwd_path);
+		return NULL;
+	}
 	futex_up(&cwd_futex);
 	return ncwd_path;
@@ -103,15 +109,10 @@
 	aid_t req;
 
-	int dev_handle = 0;	/* TODO */
-
-	char *mpa = absolutize(mp);
+	dev_handle_t dev_handle = 0;	/* TODO */
+
+	size_t mpa_len;
+	char *mpa = absolutize(mp, &mpa_len);
 	if (!mpa)
 		return ENOMEM;
-	size_t mpc_len;
-	char *mpc = canonify(mpa, &mpc_len);
-	if (!mpc) {
-		free(mpa);
-		return EINVAL;
-	}
 
 	futex_down(&vfs_phone_futex);
@@ -135,5 +136,5 @@
 		return (int) rc;
 	}
-	rc = ipc_data_write_start(vfs_phone, (void *)mpc, mpc_len);
+	rc = ipc_data_write_start(vfs_phone, (void *)mpa, mpa_len);
 	if (rc != EOK) {
 		async_wait_for(req, NULL);
@@ -157,13 +158,8 @@
 	aid_t req;
 	
-	char *pa = absolutize(path);
+	size_t pa_len;
+	char *pa = absolutize(path, &pa_len);
 	if (!pa)
 		return ENOMEM;
-	size_t pc_len;
-	char *pc = canonify(pa, &pc_len);
-	if (!pc) {
-		free(pa);
-		return EINVAL;
-	}
 	
 	futex_down(&vfs_phone_futex);
@@ -179,5 +175,5 @@
 	}
 	req = async_send_3(vfs_phone, VFS_OPEN, lflag, oflag, 0, &answer);
-	rc = ipc_data_write_start(vfs_phone, pc, pc_len);
+	rc = ipc_data_write_start(vfs_phone, pa, pa_len);
 	if (rc != EOK) {
 		async_wait_for(req, NULL);
@@ -380,13 +376,8 @@
 	aid_t req;
 	
-	char *pa = absolutize(path);
+	size_t pa_len;
+	char *pa = absolutize(path, &pa_len);
 	if (!pa)
 		return ENOMEM;
-	size_t pc_len;
-	char *pc = canonify(pa, &pc_len);
-	if (!pc) {
-		free(pa);
-		return EINVAL;
-	}
 
 	futex_down(&vfs_phone_futex);
@@ -402,5 +393,5 @@
 	}
 	req = async_send_1(vfs_phone, VFS_MKDIR, mode, NULL);
-	rc = ipc_data_write_start(vfs_phone, pc, pc_len);
+	rc = ipc_data_write_start(vfs_phone, pa, pa_len);
 	if (rc != EOK) {
 		async_wait_for(req, NULL);
@@ -423,13 +414,9 @@
 	aid_t req;
 	
-	char *pa = absolutize(path);
+	size_t pa_len;
+	char *pa = absolutize(path, &pa_len);
 	if (!pa)
 		return ENOMEM;
-	size_t pc_len;
-	char *pc = canonify(pa, &pc_len);
-	if (!pc) {
-		free(pa);
-		return EINVAL;
-	}
+
 	futex_down(&vfs_phone_futex);
 	async_serialize_start();
@@ -444,5 +431,5 @@
 	}
 	req = async_send_0(vfs_phone, VFS_UNLINK, NULL);
-	rc = ipc_data_write_start(vfs_phone, pc, pc_len);
+	rc = ipc_data_write_start(vfs_phone, pa, pa_len);
 	if (rc != EOK) {
 		async_wait_for(req, NULL);
@@ -475,49 +462,39 @@
 	aid_t req;
 	
-	char *olda = absolutize(old);
+	size_t olda_len;
+	char *olda = absolutize(old, &olda_len);
 	if (!olda)
 		return ENOMEM;
-	size_t oldc_len;
-	char *oldc = canonify(olda, &oldc_len);
-	if (!oldc) {
-		free(olda);
-		return EINVAL;
-	}
-	char *newa = absolutize(new);
+
+	size_t newa_len;
+	char *newa = absolutize(new, &newa_len);
 	if (!newa) {
 		free(olda);
 		return ENOMEM;
 	}
-	size_t newc_len;
-	char *newc = canonify(newa, &newc_len);
-	if (!newc) {
+
+	futex_down(&vfs_phone_futex);
+	async_serialize_start();
+	if (vfs_phone < 0) {
+		res = vfs_connect();
+		if (res < 0) {
+			async_serialize_end();
+			futex_up(&vfs_phone_futex);
+			free(olda);
+			free(newa);
+			return res;
+		}
+	}
+	req = async_send_0(vfs_phone, VFS_RENAME, NULL);
+	rc = ipc_data_write_start(vfs_phone, olda, olda_len);
+	if (rc != EOK) {
+		async_wait_for(req, NULL);
+		async_serialize_end();
+		futex_up(&vfs_phone_futex);
 		free(olda);
 		free(newa);
-		return EINVAL;
-	}
-
-	futex_down(&vfs_phone_futex);
-	async_serialize_start();
-	if (vfs_phone < 0) {
-		res = vfs_connect();
-		if (res < 0) {
-			async_serialize_end();
-			futex_up(&vfs_phone_futex);
-			free(olda);
-			free(newa);
-			return res;
-		}
-	}
-	req = async_send_0(vfs_phone, VFS_RENAME, NULL);
-	rc = ipc_data_write_start(vfs_phone, oldc, oldc_len);
-	if (rc != EOK) {
-		async_wait_for(req, NULL);
-		async_serialize_end();
-		futex_up(&vfs_phone_futex);
-		free(olda);
-		free(newa);
-		return (int) rc;
-	}
-	rc = ipc_data_write_start(vfs_phone, newc, newc_len);
+		return (int) rc;
+	}
+	rc = ipc_data_write_start(vfs_phone, newa, newa_len);
 	if (rc != EOK) {
 		async_wait_for(req, NULL);
@@ -538,15 +515,10 @@
 int chdir(const char *path)
 {
-	char *pa = absolutize(path);
+	size_t pa_len;
+	char *pa = absolutize(path, &pa_len);
 	if (!pa)
 		return ENOMEM;
-	size_t pc_len;
-	char *pc = canonify(pa, &pc_len);
-	if (!pc) {
-		free(pa);
-		return ENOENT;
-	}
-
-	DIR *d = opendir(pc);
+
+	DIR *d = opendir(pa);
 	if (!d) {
 		free(pa);
@@ -563,6 +535,6 @@
 	}
 	cwd_dir = d;
-	cwd_path = pc;
-	cwd_len = pc_len;
+	cwd_path = pa;
+	cwd_len = pa_len;
 	futex_up(&cwd_futex);
 }
