diff options
author | H. Peter Anvin <hpa@linux.intel.com> | 2011-05-27 17:45:59 -0700 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2011-05-27 17:45:59 -0700 |
commit | ba4fefa9b52b25ca1babd77066e21abef19518c2 (patch) | |
tree | e9fd8beb864dc03b9d202add547e16406b9f6497 /core/fs | |
parent | a9af8932758ab714e632cfbb65a45c38cac0bd67 (diff) | |
download | syslinux-ba4fefa9b52b25ca1babd77066e21abef19518c2.tar.gz |
core: change load_config() to open_config()
Change load_config() to open_config(), which is a method that works
just like open_file(). This we can use to get the original
configuration file.
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'core/fs')
-rw-r--r-- | core/fs/btrfs/btrfs.c | 2 | ||||
-rw-r--r-- | core/fs/ext2/ext2.c | 2 | ||||
-rw-r--r-- | core/fs/fat/fat.c | 2 | ||||
-rw-r--r-- | core/fs/fs.c | 15 | ||||
-rw-r--r-- | core/fs/iso9660/iso9660.c | 7 | ||||
-rw-r--r-- | core/fs/lib/loadconfig.c | 4 | ||||
-rw-r--r-- | core/fs/lib/searchconfig.c | 9 | ||||
-rw-r--r-- | core/fs/pxe/pxe.c | 41 |
8 files changed, 24 insertions, 58 deletions
diff --git a/core/fs/btrfs/btrfs.c b/core/fs/btrfs/btrfs.c index b6a14e3b..bce9deb6 100644 --- a/core/fs/btrfs/btrfs.c +++ b/core/fs/btrfs/btrfs.c @@ -670,5 +670,5 @@ const struct fs_ops btrfs_fs_ops = { .mangle_name = generic_mangle_name, .next_extent = btrfs_next_extent, .readdir = btrfs_readdir, - .load_config = generic_load_config + .open_config = generic_open_config }; diff --git a/core/fs/ext2/ext2.c b/core/fs/ext2/ext2.c index 716670c6..4c183e58 100644 --- a/core/fs/ext2/ext2.c +++ b/core/fs/ext2/ext2.c @@ -326,7 +326,7 @@ const struct fs_ops ext2_fs_ops = { .getfssec = generic_getfssec, .close_file = generic_close_file, .mangle_name = generic_mangle_name, - .load_config = generic_load_config, + .open_config = generic_open_config, .iget_root = ext2_iget_root, .iget = ext2_iget, .readlink = ext2_readlink, diff --git a/core/fs/fat/fat.c b/core/fs/fat/fat.c index d3079269..6343b01e 100644 --- a/core/fs/fat/fat.c +++ b/core/fs/fat/fat.c @@ -787,7 +787,7 @@ const struct fs_ops vfat_fs_ops = { .getfssec = generic_getfssec, .close_file = generic_close_file, .mangle_name = vfat_mangle_name, - .load_config = generic_load_config, + .open_config = generic_open_config, .readdir = vfat_readdir, .iget_root = vfat_iget_root, .iget = vfat_iget, diff --git a/core/fs/fs.c b/core/fs/fs.c index ad2fb370..39ba09eb 100644 --- a/core/fs/fs.c +++ b/core/fs/fs.c @@ -2,6 +2,7 @@ #include <stdbool.h> #include <string.h> #include <dprintf.h> +#include "core.h" #include "fs.h" #include "cache.h" @@ -74,19 +75,11 @@ void _close_file(struct file *file) } /* - * Convert between a 16-bit file handle and a file structure + * Find and open the configuration file */ - -void pm_load_config(com32sys_t *regs) +int open_config(struct com32_filedata *filedata) { - int err; - - err = this_fs->fs_ops->load_config(); - - if (err) - printf("ERROR: No configuration file found\n"); - - set_flags(regs, err ? EFLAGS_ZF : 0); + return this_fs->fs_ops->open_config(filedata); } void pm_mangle_name(com32sys_t *regs) diff --git a/core/fs/iso9660/iso9660.c b/core/fs/iso9660/iso9660.c index 3cd3ac46..792cd99f 100644 --- a/core/fs/iso9660/iso9660.c +++ b/core/fs/iso9660/iso9660.c @@ -6,6 +6,7 @@ #include <cache.h> #include <disk.h> #include <fs.h> +#include <stdlib.h> #include "iso9660_fs.h" /* Convert to lower case string */ @@ -226,7 +227,7 @@ static int iso_readdir(struct file *file, struct dirent *dirent) } /* Load the config file, return 1 if failed, or 0 */ -static int iso_load_config(void) +static int iso_open_config(struct com32_filedata *filedata) { static const char *search_directories[] = { "/boot/isolinux", @@ -242,7 +243,7 @@ static int iso_load_config(void) NULL }; - return search_config(search_directories, filenames); + return search_config(filedata, search_directories, filenames); } static int iso_fs_init(struct fs_info *fs) @@ -293,7 +294,7 @@ const struct fs_ops iso_fs_ops = { .getfssec = generic_getfssec, .close_file = generic_close_file, .mangle_name = generic_mangle_name, - .load_config = iso_load_config, + .open_config = iso_open_config, .iget_root = iso_iget_root, .iget = iso_iget, .readdir = iso_readdir, diff --git a/core/fs/lib/loadconfig.c b/core/fs/lib/loadconfig.c index c9652b6c..100500c5 100644 --- a/core/fs/lib/loadconfig.c +++ b/core/fs/lib/loadconfig.c @@ -11,7 +11,7 @@ * directory, followed by a set of fallback directories. If found, * set the current working directory to match. */ -int generic_load_config(void) +int generic_open_config(struct com32_filedata *filedata) { static const char *search_directories[] = { NULL, /* CurrentDirName */ @@ -30,5 +30,5 @@ int generic_load_config(void) dprintf("CurrentDirName: \"%s\"\n", CurrentDirName); - return search_config(search_directories, filenames); + return search_config(filedata, search_directories, filenames); } diff --git a/core/fs/lib/searchconfig.c b/core/fs/lib/searchconfig.c index 24bfde31..8e53ebc5 100644 --- a/core/fs/lib/searchconfig.c +++ b/core/fs/lib/searchconfig.c @@ -11,25 +11,22 @@ * of directories. If found, set the current working directory to * match. */ -int search_config(const char *search_directories[], const char *filenames[]) +int search_config(struct com32_filedata *filedata, + 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)) { + if (!open_file(ConfigName, filedata)) { chdir(sd); return 0; /* Got it */ } diff --git a/core/fs/pxe/pxe.c b/core/fs/pxe/pxe.c index 21d27e5c..3e5d1724 100644 --- a/core/fs/pxe/pxe.c +++ b/core/fs/pxe/pxe.c @@ -1047,33 +1047,8 @@ static int pxe_chdir(struct fs_info *fs, const char *src) return 0; } - /* - * try to load a config file, if found, return 1, or return 0 - * - */ -static int try_load(char *config_name) -{ - com32sys_t regs; - - printf("Trying to load: %-50s ", config_name); - pxe_mangle_name(KernelName, config_name); - - memset(®s, 0, sizeof regs); - regs.edi.w[0] = OFFS_WRT(KernelName, 0); - call16(core_open, ®s, ®s); - if (regs.eflags.l & EFLAGS_ZF) { - strcpy(ConfigName, KernelName); - printf("\r"); - return 0; - } else { - printf("ok\n"); - return 1; - } -} - - -/* Load the config file, return 1 if failed, or 0 */ -static int pxe_load_config(void) +/* Load the config file, return -1 if failed, or 0 */ +static int pxe_open_config(struct com32_filedata *filedata) { const char *cfgprefix = "pxelinux.cfg/"; const char *default_str = "default"; @@ -1084,7 +1059,7 @@ static int pxe_load_config(void) get_prefix(); if (DHCPMagic & 0x02) { /* We got a DHCP option, try it first */ - if (try_load(ConfigName)) + if (!open_file(ConfigName, filedata)) return 0; } @@ -1096,13 +1071,13 @@ static int pxe_load_config(void) /* Try loading by UUID */ if (have_uuid) { strcpy(config_file, UUID_str); - if (try_load(ConfigName)) + if (!open_file(ConfigName, filedata)) return 0; } /* Try loading by MAC address */ strcpy(config_file, MAC_str); - if (try_load(ConfigName)) + if (!open_file(ConfigName, filedata)) return 0; /* Nope, try hexadecimal IP prefixes... */ @@ -1110,7 +1085,7 @@ static int pxe_load_config(void) last = &config_file[8]; while (tries) { *last = '\0'; /* Zero-terminate string */ - if (try_load(ConfigName)) + if (!open_file(ConfigName, filedata)) return 0; last--; /* Drop one character */ tries--; @@ -1118,7 +1093,7 @@ static int pxe_load_config(void) /* Final attempt: "default" string */ strcpy(config_file, default_str); - if (try_load(ConfigName)) + if (!open_file(ConfigName, filedata)) return 0; printf("%-68s\n", "Unable to locate configuration file"); @@ -1749,5 +1724,5 @@ const struct fs_ops pxe_fs_ops = { .getfssec = pxe_getfssec, .close_file = pxe_close_file, .mangle_name = pxe_mangle_name, - .load_config = pxe_load_config, + .open_config = pxe_open_config, }; |