aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2012-08-07 10:40:12 +0100
committerMatt Fleming <matt.fleming@intel.com>2012-08-07 10:40:12 +0100
commitd1d03dee6bc961b0afd8dfc68fd35772ecded8be (patch)
tree959159a6c09fa536f640256ac743851644a6ec38
parent2e512282fd37f7dcb6d33e025e389f11d6d6d42f (diff)
downloadsyslinux-d1d03dee6bc961b0afd8dfc68fd35772ecded8be.tar.gz
syslinux-d1d03dee6bc961b0afd8dfc68fd35772ecded8be.tar.xz
syslinux-d1d03dee6bc961b0afd8dfc68fd35772ecded8be.zip
ldlinux: Use findpath() to lookup filenamessyslinux-5.00-pre7
We should use the same method of opening files as the module code when searching for extensions. In particular, we should search all of PATH. Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rw-r--r--com32/elflink/ldlinux/ldlinux.c9
-rw-r--r--com32/include/sys/module.h2
-rw-r--r--com32/lib/sys/module/common.c2
3 files changed, 8 insertions, 5 deletions
diff --git a/com32/elflink/ldlinux/ldlinux.c b/com32/elflink/ldlinux/ldlinux.c
index ade161f3..1c261cd5 100644
--- a/com32/elflink/ldlinux/ldlinux.c
+++ b/com32/elflink/ldlinux/ldlinux.c
@@ -83,19 +83,20 @@ static const char *get_extension(const char *kernel)
for (ext = file_extensions; ext->name; ext++) {
char *str;
int elen = strlen(ext->name);
- int fd;
+ FILE *f;
str = malloc(len + elen + 1);
strncpy(str, kernel, len);
strncpy(str + len, ext->name, elen);
str[len + elen] = '\0';
-
- fd = searchdir(str);
+ f = findpath(str);
free(str);
- if (fd >= 0)
+ if (f) {
+ fclose(f);
return ext->name;
+ }
}
return NULL;
diff --git a/com32/include/sys/module.h b/com32/include/sys/module.h
index 095eb974..ea11a88f 100644
--- a/com32/include/sys/module.h
+++ b/com32/include/sys/module.h
@@ -146,6 +146,8 @@ struct module_dep {
*/
extern struct elf_module *unload_modules_since(const char *name);
+extern FILE *findpath(char *name);
+
#ifdef DYNAMIC_MODULE
diff --git a/com32/lib/sys/module/common.c b/com32/lib/sys/module/common.c
index b120bc73..6e63907d 100644
--- a/com32/lib/sys/module/common.c
+++ b/com32/lib/sys/module/common.c
@@ -57,7 +57,7 @@ void print_elf_symbols(struct elf_module *module) {
}
#endif //ELF_DEBUG
-static FILE *findpath(char *name)
+FILE *findpath(char *name)
{
char path[FILENAME_MAX];
FILE *f;