From adf42886f2bcbe6b933e19d337ceeeddc7b1a382 Mon Sep 17 00:00:00 2001 From: Rene Gollent Date: Sat, 16 Aug 2008 03:06:02 +0000 Subject: [PATCH] Use get_next_image_info to resolve the path to the executable. This fixes the problem that makebootable will not work unless run with an absolute path. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@26987 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../platform/bios_ia32/makebootable.cpp | 27 +++++++++++++------ 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/bin/makebootable/platform/bios_ia32/makebootable.cpp b/src/bin/makebootable/platform/bios_ia32/makebootable.cpp index beaab72710..a0edf70864 100644 --- a/src/bin/makebootable/platform/bios_ia32/makebootable.cpp +++ b/src/bin/makebootable/platform/bios_ia32/makebootable.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -106,17 +107,27 @@ print_usage_and_exit(bool error) // read_boot_code_data static uint8 * -read_boot_code_data(const char* programPath) +read_boot_code_data(void) { - // open our executable + image_info info; + int32 cookie = 0; BFile executableFile; - status_t error = executableFile.SetTo(programPath, B_READ_ONLY); - if (error != B_OK) { - fprintf(stderr, "Error: Failed to open my executable file (\"%s\": " - "%s\n", programPath, strerror(error)); + + status_t error = get_next_image_info(0, &cookie, &info); + if (error == B_OK) { + // open our executable + error = executableFile.SetTo(info.name, B_READ_ONLY); + if (error != B_OK) { + fprintf(stderr, "Error: Failed to open my executable file (\"%s\": " + "%s\n", info.name, strerror(error)); + exit(1); + } + } else { + fprintf(stderr, "Error: Failed to get image info for executable file, " + "error: %s\n", strerror(error)); exit(1); } - + uint8 *bootCodeData = new uint8[kBootCodeSize]; // open our resources @@ -225,7 +236,7 @@ main(int argc, const char *const *argv) print_usage_and_exit(true); // read the boot code - uint8 *bootCodeData = read_boot_code_data(argv[0]); + uint8 *bootCodeData = read_boot_code_data(); if (!bootCodeData) { fprintf(stderr, "Error: Failed to read "); exit(1);