diff options
author | Matt Fleming <matt.fleming@linux.intel.com> | 2011-07-12 11:52:05 +0100 |
---|---|---|
committer | Matt Fleming <matt.fleming@linux.intel.com> | 2011-07-12 16:24:06 +0100 |
commit | 833f2859a77ed0d14ee197fe6e9d67044d5200c1 (patch) | |
tree | a18d6df2f39611778bd0eb3e825b6196638319f3 /core/fs/fs.c | |
parent | 8ae01800ff9f3d8a3dd199898d4e2d3c7a37b3c9 (diff) | |
download | syslinux-833f2859a77ed0d14ee197fe6e9d67044d5200c1.tar.gz |
core: Fix ldlinux.c32 failing to load when not installed in "/"
Currently, if syslinux is installed in a directory other than "/" we
will fail to load ldlinux.c32.
Because we know where we were installed the simplest fix is to chdir()
to the installation directory before attempting to load
ldlinux.c32. This requires us to add "." to PATH so that we look in
the current working directory when loading ELF modules.
Changing to the install directory needs to handled differently for
different file systems, which is the reason behind the new file system
operation, .chdir_start(). Disk-based Syslinux variants should use
generic_chdir_start() to chdir() to CurrentDirName, which is the
installation path. By using this new fs operation, we can load
ldlinux.c32 when we expand the "." in PATH, without having to search
the entire filesystem for it. However, iso9660 file systems still
require us to search some directories because it has no notion of an
installation directory.
Previously, changing into the install directory was handled when
opening the config file, but because the config file parser is now
part of the ldlinux.c32 ELF module, it needs to be done much earlier.
Reported-by: H. Peter Anvin <hpa@zytor.com>
Signed-off-by: Matt Fleming <matt.fleming@linux.intel.com>
Diffstat (limited to 'core/fs/fs.c')
-rw-r--r-- | core/fs/fs.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/core/fs/fs.c b/core/fs/fs.c index 52bcf5b2..a4fb4f77 100644 --- a/core/fs/fs.c +++ b/core/fs/fs.c @@ -8,7 +8,7 @@ #include "fs.h" #include "cache.h" -char *PATH = "/:/bin/"; +char *PATH = ".:/bin/"; /* The currently mounted filesystem */ struct fs_info *this_fs = NULL; /* Root filesystem */ @@ -78,8 +78,6 @@ void _close_file(struct file *file) free_file(file); } -extern const struct input_dev __file_dev; - /* * Find and open the configuration file */ @@ -490,6 +488,11 @@ void fs_init(com32sys_t *regs) fs.cwd = get_inode(fs.root); } + if (fs.fs_ops->chdir_start) { + if (fs.fs_ops->chdir_start() < 0) + printf("Failed to chdir to start directory\n"); + } + SectorShift = fs.sector_shift; SectorSize = fs.sector_size; } |