aboutsummaryrefslogtreecommitdiffstats
path: root/core/elflink/readconfig.c
diff options
context:
space:
mode:
Diffstat (limited to 'core/elflink/readconfig.c')
-rw-r--r--core/elflink/readconfig.c75
1 files changed, 51 insertions, 24 deletions
diff --git a/core/elflink/readconfig.c b/core/elflink/readconfig.c
index 39b5d125..c984fa80 100644
--- a/core/elflink/readconfig.c
+++ b/core/elflink/readconfig.c
@@ -22,6 +22,8 @@
#include <com32.h>
#include <syslinux/adv.h>
#include <syslinux/config.h>
+#include <fs.h>
+#include <core.h>
#include "menu.h"
@@ -1044,31 +1046,56 @@ do_include:
static int parse_one_config(const char *filename)
{
FILE *f;
- int i;
-
- /*
- if (!strcmp(filename, "~"))
- filename = syslinux_config_file();
- */
- f = fopen(filename, "r");
- if (f)
- goto config_found;
+ if (filename) {
+ f = fopen(filename, "r");
+ if (f) {
+ parse_config_file(f);
+ fclose(f);
+ return 0;
+ }
+ }
- /* force to use hard coded config file name */
- f = fopen("extlinux.conf", "r");
- if (f)
- goto config_found;
+ return -1;
+}
- f = fopen("isolinux.cfg", "r");
- if (f)
- goto config_found;
+int load_default_config(void)
+{
+ char name_buf[FILENAME_MAX];
+ char fname[FILENAME_MAX];
+ const char *sd, **sdp;
+ const char *sf, **sfp;
+
+ static const char *def_dirs[] = {
+ "/boot/isolinux",
+ "/isolinux",
+ "/boot/syslinux",
+ "/syslinux",
+ "/",
+ NULL
+ };
+ static const char *def_files[] = {
+ "isolinux.cfg",
+ "extlinux.conf",
+ "syslinux.cfg",
+ NULL
+ };
+
+ for (sdp = def_dirs; (sd = *sdp); sdp++) {
+ for (sfp = def_files; (sf = *sfp); sfp++) {
+ snprintf(name_buf, sizeof name_buf,
+ "%s%s%s",
+ sd, (*sd && sd[strlen(sd)-1] == '/') ? "" : "/",
+ sf);
+ realpath(fname, name_buf, FILENAME_MAX);
+ mp("search: %s", fname);
+
+ if (!parse_one_config(fname))
+ return 0; /* success */
+ }
+ }
return -1;
-config_found:
- parse_config_file(f);
- fclose(f);
- return 0;
}
static void resolve_gotos(void)
@@ -1128,12 +1155,12 @@ void parse_configs(char **argv)
/* Actually process the files */
current_menu = root_menu;
- if (!argv || !*argv) {
- parse_one_config("~");
- } else {
+ if (!argv || !*argv)
+ load_default_config();
+ else {
while ((filename = *argv++)) {
mp("Parsing config: %s", filename);
- parse_one_config(filename);
+ parse_one_config(filename);
}
}