diff options
author | Matt Fleming <matt.fleming@intel.com> | 2012-11-13 15:18:58 +0000 |
---|---|---|
committer | Matt Fleming <matt.fleming@intel.com> | 2012-11-13 15:18:58 +0000 |
commit | 749297b070d1fe3d82fd9e5c4306b4aaf257f2a1 (patch) | |
tree | fbbadfaeafa5b5b5924beafbdff4174fc035f7c1 | |
parent | 0471f367e08e5a205ad8f61b7f17ba389cf74e33 (diff) | |
download | syslinux-749297b070d1fe3d82fd9e5c4306b4aaf257f2a1.tar.gz syslinux-749297b070d1fe3d82fd9e5c4306b4aaf257f2a1.tar.xz syslinux-749297b070d1fe3d82fd9e5c4306b4aaf257f2a1.zip |
efi: Set the current working directory on startup
syslinux.efi may have been installed anywhere on the EFI System
Partition, and so we need to update CurrentDirName accordingly.
Without this patch we fail to load ldlinux.c32 if it was installed in
a directory other than those listed in 'search_directories' in
load_env32().
Signed-off-by: Matt Fleming <matt.fleming@intel.com>
-rw-r--r-- | efi/main.c | 41 |
1 files changed, 40 insertions, 1 deletions
@@ -15,7 +15,7 @@ uint16_t PXERetry; char copyright_str[] = "Copyright (C) 2011\n"; uint8_t SerialNotice = 1; char syslinux_banner[] = "Syslinux 5.x (EFI)\n"; -char CurrentDirName[FILENAME_MAX]; +char CurrentDirName[CURRENTDIR_MAX]; struct com32_sys_args __com32; uint32_t _IdleTimer = 0; @@ -1070,6 +1070,37 @@ char free_high_memory[4096]; extern char __bss_start[]; extern char __bss_end[]; +static void efi_setcwd(CHAR16 *dp) +{ + CHAR16 *c16; + char *c8; + int i, j; + + /* Search for the start of the last path component */ + for (i = StrLen(dp) - 1; i >= 0; i--) { + if (dp[i] == '\\' || dp[i] == '/') + break; + } + + if (i < 0 || i > CURRENTDIR_MAX) { + dp = L"\\"; + i = 1; + } + + c8 = CurrentDirName; + c16 = dp; + + for (j = 0; j < i; j++) { + if (*c16 == '\\') { + *c8++ = '/'; + c16++; + } else + *c8++ = *c16++; + } + + *c8 = '\0'; +} + EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *table) { EFI_LOADED_IMAGE *info; @@ -1109,7 +1140,15 @@ EFI_STATUS efi_main(EFI_HANDLE image, EFI_SYSTEM_TABLE *table) /* XXX figure out what file system we're on */ priv.dev_handle = info->DeviceHandle; + + /* + * Set the current working directory, which should be the + * directory that syslinux.efi resides in. + */ + efi_setcwd(DevicePathToStr(info->FilePath)); + fs_init(ops, &priv); + load_env32(); /* load_env32() failed.. cancel timer and bailout */ |