Allow relative paths for the interpreter prefix in linux-user emulation.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2984 c046a42c-6fe2-441c-8c8c-71466251a162
diff --git a/linux-user/path.c b/linux-user/path.c
index 7680970..7da0a8b 100644
--- a/linux-user/path.c
+++ b/linux-user/path.c
@@ -92,23 +92,6 @@
 	set_parents(child->entries[i], child);
 }
 
-void init_paths(const char *prefix)
-{
-    if (prefix[0] != '/' ||
-        prefix[0] == '\0' ||
-        !strcmp(prefix, "/"))
-        return;
-
-    base = new_entry("", NULL, prefix+1);
-    base = add_dir_maybe(base);
-    if (base->num_entries == 0) {
-        free (base);
-        base = NULL;
-    } else {
-        set_parents(base, base);
-    }
-}
-
 /* FIXME: Doesn't handle DIR/.. where DIR is not in emulated dir. */
 static const char *
 follow_path(const struct pathelem *cursor, const char *name)
@@ -135,6 +118,35 @@
     return NULL;
 }
 
+void init_paths(const char *prefix)
+{
+    char pref_buf[PATH_MAX];
+
+    if (prefix[0] == '\0' ||
+        !strcmp(prefix, "/"))
+        return;
+
+    if (prefix[0] != '/') {
+        char *cwd = get_current_dir_name();
+	if (!cwd)
+            abort();
+	strcpy(pref_buf, cwd);
+        strcat(pref_buf, "/");
+        strcat(pref_buf, prefix);
+        free(cwd);
+    } else
+        strcpy(pref_buf,prefix + 1);
+
+    base = new_entry("", NULL, pref_buf);
+    base = add_dir_maybe(base);
+    if (base->num_entries == 0) {
+        free (base);
+        base = NULL;
+    } else {
+        set_parents(base, base);
+    }
+}
+
 /* Look for path in emulation dir, otherwise return name. */
 const char *path(const char *name)
 {