aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatt Fleming <matt.fleming@intel.com>2013-02-19 21:09:55 +0000
committerMatt Fleming <matt.fleming@intel.com>2013-02-20 10:16:55 +0000
commitb208ba467f678ed8e73f8d11fc0609634120cb83 (patch)
treee3b782cfcdb343be36212ee41ec8f61b4ef0b3be
parentaa7dd29db684d73f044b520e8c148f7ddb8c38d5 (diff)
downloadsyslinux-b208ba467f678ed8e73f8d11fc0609634120cb83.tar.gz
syslinux-b208ba467f678ed8e73f8d11fc0609634120cb83.tar.xz
syslinux-b208ba467f678ed8e73f8d11fc0609634120cb83.zip
pxe: Pass absolute path to pxe_chdir()
We may have moved out of the root directory when calling get_prefix() and so need a way to create an absolute path. Historically, in versions prior to 5.xx we would call pxe_open_config() while we were still in the root directory ("::"), and so, we could construct a relative path to the config file. However, because we need to load ldlinux.c32 before opening the config file, which may involve us changing directory, we need a way of constructing an absolute path to the config file in get_prefix(). Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rw-r--r--core/fs/pxe/pxe.c22
1 files changed, 16 insertions, 6 deletions
diff --git a/core/fs/pxe/pxe.c b/core/fs/pxe/pxe.c
index f96c6d06..c07f00ee 100644
--- a/core/fs/pxe/pxe.c
+++ b/core/fs/pxe/pxe.c
@@ -984,6 +984,19 @@ err_reply:
}
+static int __pxe_chdir(struct fs_info *fs, const char *src,
+ enum pxe_path_type path_type)
+{
+ if (path_type == PXE_RELATIVE)
+ strlcat(fs->cwd_name, src, sizeof fs->cwd_name);
+ else if (path_type == PXE_HOMESERVER)
+ snprintf(fs->cwd_name, sizeof fs->cwd_name, "::%s", src);
+ else
+ strlcpy(fs->cwd_name, src, sizeof fs->cwd_name);
+ return 0;
+
+}
+
/*
* Store standard filename prefix
*/
@@ -1018,7 +1031,7 @@ static void get_prefix(void)
}
printf("TFTP prefix: %s\n", path_prefix);
- chdir(path_prefix);
+ __pxe_chdir(this_fs, path_prefix, PXE_HOMESERVER);
}
/*
@@ -1041,10 +1054,7 @@ static int pxe_chdir(struct fs_info *fs, const char *src)
/* The cwd for PXE is just a text prefix */
enum pxe_path_type path_type = pxe_path_type(src);
- if (path_type == PXE_RELATIVE)
- strlcat(fs->cwd_name, src, sizeof fs->cwd_name);
- else
- strlcpy(fs->cwd_name, src, sizeof fs->cwd_name);
+ __pxe_chdir(fs, src, path_type);
dprintf("cwd = \"%s\"\n", fs->cwd_name);
return 0;
@@ -1065,7 +1075,7 @@ static int pxe_open_config(struct com32_filedata *filedata)
char *last;
int tries = 8;
- chdir(path_prefix);
+ get_prefix();
if (DHCPMagic & 0x02) {
/* We got a DHCP option, try it first */
if (open_file(ConfigName, filedata) >= 0)