core: Fix ldlinux.c32 failing to load when not installed in "/"
authorMatt Fleming <matt.fleming@linux.intel.com>
Tue, 12 Jul 2011 10:52:05 +0000 (11:52 +0100)
committerMatt Fleming <matt.fleming@linux.intel.com>
Tue, 12 Jul 2011 15:24:06 +0000 (16:24 +0100)
commit833f2859a77ed0d14ee197fe6e9d67044d5200c1
treea18d6df2f39611778bd0eb3e825b6196638319f3
parent8ae01800ff9f3d8a3dd199898d4e2d3c7a37b3c9
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>
com32/lib/sys/file.h
com32/lib/sys/module/common.c
core/elflink/load_env32.c
core/fs/btrfs/btrfs.c
core/fs/ext2/ext2.c
core/fs/fat/fat.c
core/fs/fs.c
core/fs/lib/chdir.c [new file with mode: 0644]
core/fs/pxe/pxe.c
core/include/fs.h