aboutsummaryrefslogtreecommitdiff
path: root/linux-user/path.c
diff options
context:
space:
mode:
authorths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2007-06-17 15:32:30 +0000
committerths <ths@c046a42c-6fe2-441c-8c8c-71466251a162>2007-06-17 15:32:30 +0000
commitffb04fcf089865952592f1f8855c2848d4514a89 (patch)
tree3b98894d0d4d4c6070818e3131a4cbc22effcd35 /linux-user/path.c
parente27f01ef248ce63b2dc6591c28a275526d2dbc16 (diff)
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
Diffstat (limited to 'linux-user/path.c')
-rw-r--r--linux-user/path.c46
1 files changed, 29 insertions, 17 deletions
diff --git a/linux-user/path.c b/linux-user/path.c
index 76809705a4..7da0a8b27a 100644
--- a/linux-user/path.c
+++ b/linux-user/path.c
@@ -92,23 +92,6 @@ static void set_parents(struct pathelem *child, struct pathelem *parent)
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 @@ follow_path(const struct pathelem *cursor, const char *name)
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)
{