diff --git a/src/bin/makebootable/platform/bios_ia32/makebootable.cpp b/src/bin/makebootable/platform/bios_ia32/makebootable.cpp index a0edf70864..47409a2404 100644 --- a/src/bin/makebootable/platform/bios_ia32/makebootable.cpp +++ b/src/bin/makebootable/platform/bios_ia32/makebootable.cpp @@ -16,7 +16,6 @@ #include #include #include -#include #include #include @@ -36,6 +35,8 @@ # include "PartitionMap.h" # include "PartitionMapParser.h" +#elif HAIKU_HOST_PLATFORM_HAIKU +# include #endif @@ -107,27 +108,17 @@ print_usage_and_exit(bool error) // read_boot_code_data static uint8 * -read_boot_code_data(void) +read_boot_code_data(const char* programPath) { - image_info info; - int32 cookie = 0; + // open our executable BFile executableFile; - - 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)); + 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)); exit(1); } - + uint8 *bootCodeData = new uint8[kBootCodeSize]; // open our resources @@ -236,7 +227,15 @@ main(int argc, const char *const *argv) print_usage_and_exit(true); // read the boot code - uint8 *bootCodeData = read_boot_code_data(); + uint8 *bootCodeData = NULL; +#ifndef HAIKU_HOST_PLATFORM_HAIKU + bootCodeData = read_boot_code_data(argv[0]); +#else + image_info info; + int32 cookie = 0; + if (get_next_image_info(0, &cookie, &info) == B_OK) + bootCodeData = read_boot_code_data(info.name); +#endif if (!bootCodeData) { fprintf(stderr, "Error: Failed to read "); exit(1);