[syslinux:elflink] core: change load_config() to open_config()
syslinux-bot for H. Peter Anvin
hpa at linux.intel.com
Fri May 27 17:48:03 PDT 2011
Commit-ID: ba4fefa9b52b25ca1babd77066e21abef19518c2
Gitweb: http://syslinux.zytor.com/commit/ba4fefa9b52b25ca1babd77066e21abef19518c2
Author: H. Peter Anvin <hpa at linux.intel.com>
AuthorDate: Fri, 27 May 2011 17:45:59 -0700
Committer: H. Peter Anvin <hpa at linux.intel.com>
CommitDate: Fri, 27 May 2011 17:45:59 -0700
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 at linux.intel.com>
---
core/fs/btrfs/btrfs.c | 2 +-
core/fs/ext2/ext2.c | 2 +-
core/fs/fat/fat.c | 2 +-
core/fs/fs.c | 15 ++++-----------
core/fs/iso9660/iso9660.c | 7 ++++---
core/fs/lib/loadconfig.c | 4 ++--
core/fs/lib/searchconfig.c | 9 +++------
core/fs/pxe/pxe.c | 41 ++++++++---------------------------------
core/include/fs.h | 7 ++++---
core/pxelinux.asm | 6 ------
10 files changed, 28 insertions(+), 67 deletions(-)
diff --git a/core/fs/btrfs/btrfs.c b/core/fs/btrfs/btrfs.c
index b6a14e3..bce9deb 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 716670c..4c183e5 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 d307926..6343b01 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 ad2fb37..39ba09e 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 3cd3ac4..792cd99 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 c9652b6..100500c 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 24bfde3..8e53ebc 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 21d27e5..3e5d172 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,
};
diff --git a/core/include/fs.h b/core/include/fs.h
index fb416ee..e9e4548 100644
--- a/core/include/fs.h
+++ b/core/include/fs.h
@@ -61,7 +61,7 @@ struct fs_ops {
void (*mangle_name)(char *, const char *);
size_t (*realpath)(struct fs_info *, char *, const char *, size_t);
int (*chdir)(struct fs_info *, const char *);
- int (*load_config)(void);
+ int (*open_config)(struct com32_filedata *);
struct inode * (*iget_root)(struct fs_info *);
struct inode * (*iget)(const char *, struct inode *);
@@ -211,8 +211,9 @@ char *core_getcwd(char *buf, size_t size);
void generic_mangle_name(char *, const char *);
/* loadconfig.c */
-int search_config(const char *search_directores[], const char *filenames[]);
-int generic_load_config(void);
+int search_config(struct com32_filedata *filedata,
+ const char *search_directores[], const char *filenames[]);
+int generic_open_config(struct com32_filedata *filedata);
/* close.c */
void generic_close_file(struct file *file);
diff --git a/core/pxelinux.asm b/core/pxelinux.asm
index e8818a6..de380e8 100644
--- a/core/pxelinux.asm
+++ b/core/pxelinux.asm
@@ -264,12 +264,6 @@ ROOT_FS_OPS:
%endmacro
;
-; Load configuration file
-;
- pm_call pm_load_config
- jz no_config_file
-
-;
; Now we have the config file open. Parse the config file and
; run the user interface.
;
More information about the Syslinux-commits
mailing list