--- vfs_old.c	2012-04-02 23:59:43.701408004 +0530
+++ vfs.c	2012-04-03 00:34:23.317408003 +0530
@@ -63,6 +63,12 @@
 static char *cwd_path = NULL;
 static size_t cwd_size = 0;
 
+static FIBRIL_MUTEX_INITIALIZE(pwd_mutex);
+
+static int pwd_fd = -1;
+static char *pwd_path = NULL;
+static size_t pwd_size = 0;
+
 /** Start an async exchange on the VFS session.
  *
  * @return New exchange.
@@ -737,6 +743,12 @@
 int chdir(const char *path)
 {
 	size_t abs_size;
+
+	if (path[0] == '-' && pwd_path != NULL)
+		path = pwd_path;
+	else if (path[0] == '-' && pwd_path == NULL)
+		return ENOMEM;
+
 	char *abs = absolutize(path, &abs_size);
 	if (!abs)
 		return ENOMEM;
@@ -749,14 +761,22 @@
 	}
 	
 	fibril_mutex_lock(&cwd_mutex);
-	
-	if (cwd_fd >= 0)
-		close(cwd_fd);
-	
-	
-	if (cwd_path)
-		free(cwd_path);
-	
+
+	fibril_mutex_lock(&pwd_mutex);
+
+	if (pwd_fd >= 0)
+		close(pwd_fd);
+
+
+	if (pwd_path)
+		free(pwd_path);
+
+	pwd_fd = cwd_fd;
+	pwd_path = cwd_path;
+	pwd_size = cwd_size;
+
+	fibril_mutex_unlock(&pwd_mutex);
+
 	cwd_fd = fd;
 	cwd_path = abs;
 	cwd_size = abs_size;
