--- HelenOS/uspace/lib/c/generic/vfs/vfs.c	2012-03-22 21:23:03.000000000 +0530
+++ /home/ketan/HelenOS/uspace/lib/c/generic/vfs/vfs.c	2012-04-04 14:19:43.373408005 +0530
@@ -63,6 +63,14 @@
 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.
@@ -750,13 +758,23 @@
 	
 	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;
@@ -783,6 +801,25 @@
 	return buf;
 }
 
+
+char *getpwd(char *buf, size_t size)
+{
+	if (size == 0)
+		return NULL;
+
+	fibril_mutex_lock(&pwd_mutex);
+
+	if ((pwd_size == 0) || (size < pwd_size + 1)) {
+		fibril_mutex_unlock(&pwd_mutex);
+		return NULL;
+	}
+
+	str_cpy(buf, size, pwd_path);
+	fibril_mutex_unlock(&pwd_mutex);
+
+	return buf;
+}
+
 async_sess_t *fd_session(exch_mgmt_t mgmt, int fildes)
 {
 	struct stat stat;
