From e298faf1adc98fdb5f69debe15569a734d5adfa1 Mon Sep 17 00:00:00 2001 From: Matt Fleming Date: Mon, 6 Jun 2011 22:45:33 +0100 Subject: [PATCH] ldlinux: Use open_config() to open config files Instead of duplicating the logic for finding config files on different filesystems in both ldlinux/readconfig.c and core/fs/* use the open_config() wrapper that calls into the fs-specific open_config(). Signed-off-by: Matt Fleming --- com32/elflink/ldlinux/readconfig.c | 37 +++++++++++++------------------------ 1 file changed, 13 insertions(+), 24 deletions(-) diff --git a/com32/elflink/ldlinux/readconfig.c b/com32/elflink/ldlinux/readconfig.c index 8ded92a..7d0dd67 100644 --- a/com32/elflink/ldlinux/readconfig.c +++ b/com32/elflink/ldlinux/readconfig.c @@ -11,6 +11,7 @@ * * ----------------------------------------------------------------------- */ +#include #include #include #include @@ -23,6 +24,7 @@ #include #include #include +#include #include "menu.h" #include "config.h" @@ -1138,34 +1140,21 @@ do_include: static int parse_one_config(const char *filename) { + const char *mode = "r"; FILE *f; + int fd; - /* - if (!strcmp(filename, "~")) - filename = syslinux_config_file(); - */ - - f = fopen(filename, "r"); - if (f) - goto config_found; - - /* force to use hard coded config file name */ - f = fopen("extlinux.conf", "r"); - if (f) - goto config_found; - - f = fopen("isolinux/isolinux.cfg", "r"); - if (f) - goto config_found; + if (!filename) + fd = open_config(); + else + fd = open(filename, O_RDONLY); - f = fopen("syslinux.cfg", "r"); - if (f) - goto config_found; + if (fd < 0) + return fd; - return -1; -config_found: + f = fdopen(fd, mode); parse_config_file(f); - fclose(f); + return 0; } @@ -1214,7 +1203,7 @@ void parse_configs(char **argv) current_menu = root_menu; if (!argv || !*argv) { - parse_one_config("~"); + parse_one_config(NULL); } else { while ((filename = *argv++)) { dprintf("Parsing config: %s", filename); -- 2.7.4