Commit ffb04fcf089865952592f1f8855c2848d4514a89
1 parent
e27f01ef
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
Showing
1 changed file
with
29 additions
and
17 deletions
linux-user/path.c
@@ -92,23 +92,6 @@ static void set_parents(struct pathelem *child, struct pathelem *parent) | @@ -92,23 +92,6 @@ static void set_parents(struct pathelem *child, struct pathelem *parent) | ||
92 | set_parents(child->entries[i], child); | 92 | set_parents(child->entries[i], child); |
93 | } | 93 | } |
94 | 94 | ||
95 | -void init_paths(const char *prefix) | ||
96 | -{ | ||
97 | - if (prefix[0] != '/' || | ||
98 | - prefix[0] == '\0' || | ||
99 | - !strcmp(prefix, "/")) | ||
100 | - return; | ||
101 | - | ||
102 | - base = new_entry("", NULL, prefix+1); | ||
103 | - base = add_dir_maybe(base); | ||
104 | - if (base->num_entries == 0) { | ||
105 | - free (base); | ||
106 | - base = NULL; | ||
107 | - } else { | ||
108 | - set_parents(base, base); | ||
109 | - } | ||
110 | -} | ||
111 | - | ||
112 | /* FIXME: Doesn't handle DIR/.. where DIR is not in emulated dir. */ | 95 | /* FIXME: Doesn't handle DIR/.. where DIR is not in emulated dir. */ |
113 | static const char * | 96 | static const char * |
114 | follow_path(const struct pathelem *cursor, const char *name) | 97 | follow_path(const struct pathelem *cursor, const char *name) |
@@ -135,6 +118,35 @@ follow_path(const struct pathelem *cursor, const char *name) | @@ -135,6 +118,35 @@ follow_path(const struct pathelem *cursor, const char *name) | ||
135 | return NULL; | 118 | return NULL; |
136 | } | 119 | } |
137 | 120 | ||
121 | +void init_paths(const char *prefix) | ||
122 | +{ | ||
123 | + char pref_buf[PATH_MAX]; | ||
124 | + | ||
125 | + if (prefix[0] == '\0' || | ||
126 | + !strcmp(prefix, "/")) | ||
127 | + return; | ||
128 | + | ||
129 | + if (prefix[0] != '/') { | ||
130 | + char *cwd = get_current_dir_name(); | ||
131 | + if (!cwd) | ||
132 | + abort(); | ||
133 | + strcpy(pref_buf, cwd); | ||
134 | + strcat(pref_buf, "/"); | ||
135 | + strcat(pref_buf, prefix); | ||
136 | + free(cwd); | ||
137 | + } else | ||
138 | + strcpy(pref_buf,prefix + 1); | ||
139 | + | ||
140 | + base = new_entry("", NULL, pref_buf); | ||
141 | + base = add_dir_maybe(base); | ||
142 | + if (base->num_entries == 0) { | ||
143 | + free (base); | ||
144 | + base = NULL; | ||
145 | + } else { | ||
146 | + set_parents(base, base); | ||
147 | + } | ||
148 | +} | ||
149 | + | ||
138 | /* Look for path in emulation dir, otherwise return name. */ | 150 | /* Look for path in emulation dir, otherwise return name. */ |
139 | const char *path(const char *name) | 151 | const char *path(const char *name) |
140 | { | 152 | { |