/* Load the config file, return 1 if failed, or 0 */
static int iso_load_config(void)
{
- const char *search_directories[] = {
+ static const char *search_directories[] = {
"/boot/isolinux",
"/isolinux",
+ "/boot/syslinux",
+ "/syslinux",
"/",
NULL
};
- com32sys_t regs;
- int i;
-
- for (i = 0; search_directories[i]; i++) {
- memset(®s, 0, sizeof regs);
- snprintf(ConfigName, FILENAME_MAX, "%s/isolinux.cfg",
- search_directories[i]);
- regs.edi.w[0] = OFFS_WRT(ConfigName, 0);
- call16(core_open, ®s, ®s);
- if (!(regs.eflags.l & EFLAGS_ZF))
- break;
- }
- if (!search_directories[i])
- return -1;
-
- /* Set the current working directory */
- chdir(search_directories[i]);
- return 0;
+ static const char *filenames[] = {
+ "isolinux.cfg",
+ "syslinux.cfg",
+ NULL
+ };
+
+ return search_config(search_directories, filenames);
}
static int iso_fs_init(struct fs_info *fs)
#include <core.h>
#include <fs.h>
+int search_config(const char *search_directories[], const char *filenames[])
+{
+ char confignamebuf[FILENAME_MAX];
+ com32sys_t regs;
+ const char *sd, **sdp;
+ const char *sf, **sfp;
+
+ for (sdp = search_directories; (sd = *sdp); sdp++) {
+ for (sfp = filenames; (sf = *sfp); sfp++) {
+ memset(®s, 0, sizeof regs);
+ snprintf(confignamebuf, sizeof confignamebuf,
+ "%s%s%s",
+ sd, (*sd && sd[strlen(sd)-1] == '/') ? "" : "/",
+ sf);
+ realpath(ConfigName, confignamebuf, FILENAME_MAX);
+ regs.edi.w[0] = OFFS_WRT(ConfigName, 0);
+ dprintf("Config search: %s\n", ConfigName);
+ call16(core_open, ®s, ®s);
+ if (!(regs.eflags.l & EFLAGS_ZF)) {
+ chdir(sd);
+ return 0; /* Got it */
+ }
+ }
+ }
+
+ return -1;
+}
+
/*
* Standard version of load_config for extlinux/syslinux filesystems.
*
*/
int generic_load_config(void)
{
- char confignamebuf[FILENAME_MAX];
static const char *search_directories[] = {
NULL, /* CurrentDirName */
"/boot/syslinux",
"syslinux.cfg",
NULL
};
- com32sys_t regs;
- int i, j;
search_directories[0] = CurrentDirName;
dprintf("CurrentDirName: \"%s\"\n", CurrentDirName);
- for (i = *CurrentDirName ? 0 : 1; search_directories[i]; i++) {
- const char *sd = search_directories[i];
- for (j = 0; filenames[j]; j++) {
- memset(®s, 0, sizeof regs);
- snprintf(confignamebuf, sizeof confignamebuf,
- "%s%s%s",
- sd, (*sd && sd[strlen(sd)-1] == '/') ? "" : "/",
- filenames[j]);
- realpath(ConfigName, confignamebuf, FILENAME_MAX);
- regs.edi.w[0] = OFFS_WRT(ConfigName, 0);
- dprintf("Config search: %s\n", ConfigName);
- call16(core_open, ®s, ®s);
- if (!(regs.eflags.l & EFLAGS_ZF)) {
- chdir(search_directories[i]);
- return 0; /* Got it */
- }
- }
- }
-
- return -1;
+ return search_config(search_directories, filenames);
}