diff --git a/src/bin/makebootable/platform/bios_ia32/makebootable.cpp b/src/bin/makebootable/platform/bios_ia32/makebootable.cpp index 47a677c485..1ee2aafa09 100644 --- a/src/bin/makebootable/platform/bios_ia32/makebootable.cpp +++ b/src/bin/makebootable/platform/bios_ia32/makebootable.cpp @@ -1,8 +1,9 @@ /* - * Copyright 2005-2008, Ingo Weinhold, bonefish@users.sf.net. + * Copyright 2005-2009, Ingo Weinhold, ingo_weinhold@gmx.de. * Distributed under the terms of the MIT License. */ + #include #include #include @@ -25,23 +26,20 @@ # include # include -# include "PartitionMap.h" -# include "PartitionMapParser.h" +# define USE_PARTITION_MAP 1 #elif HAIKU_HOST_PLATFORM_FREEBSD # include # include # include # include -# include "PartitionMap.h" -# include "PartitionMapParser.h" +# define USE_PARTITION_MAP 1 #elif HAIKU_HOST_PLATFORM_DARWIN # include # include # include -# include "PartitionMap.h" -# include "PartitionMapParser.h" +# define USE_PARTITION_MAP 1 #endif #ifdef __HAIKU__ @@ -55,6 +53,11 @@ # include "bfs_control.h" #endif +#if USE_PARTITION_MAP +# include "PartitionMap.h" +# include "PartitionMapParser.h" +#endif + static const char *kCommandName = "makebootable"; @@ -194,6 +197,7 @@ write_boot_code_part(const char *fileName, int fd, off_t imageOffset, #ifdef __HAIKU__ + static status_t find_own_image(image_info *info) { @@ -208,6 +212,36 @@ find_own_image(image_info *info) return B_NAME_NOT_FOUND; } + +#endif + + +#if USE_PARTITION_MAP + +static void +dump_partition_map(const PartitionMap& map) +{ + fprintf(stderr, "partitions:\n"); + int32 count = map.CountPartitions(); + for (int i = 0; i < count; i++) { + const Partition* partition = map.PartitionAt(i); + fprintf(stderr, "%2d: ", i); + if (partition == NULL) { + fprintf(stderr, "\n"); + continue; + } + + if (partition->IsEmpty()) { + fprintf(stderr, "\n"); + continue; + } + + fprintf(stderr, "offset: %16lld, size: %16lld, type: %x%s\n", + (int64)partition->Offset(), (int64)partition->Size(), + partition->Type(), partition->IsExtended() ? " (extended)" : ""); + } +} + #endif @@ -299,7 +333,7 @@ main(int argc, const char *const *argv) int64 partitionOffset = 0; fs_info info; // needs to be here (we use the device name later) if (S_ISDIR(st.st_mode)) { - #if defined(__BEOS__) || defined(__HAIKU__) + #if defined(__BEOS__) || defined(__HAIKU__) // a directory: get the device error = fs_stat_dev(st.st_dev, &info); @@ -400,12 +434,14 @@ main(int argc, const char *const *argv) if (!partition || partition->IsEmpty()) { fprintf(stderr, "Error: Invalid partition index %d.\n", partitionIndex); + dump_partition_map(map); exit(1); } if (partition->IsExtended()) { fprintf(stderr, "Error: Partition %d is an extended " "partition.\n", partitionIndex); + dump_partition_map(map); exit(1); } @@ -483,17 +519,18 @@ main(int argc, const char *const *argv) if (!partition || partition->IsEmpty()) { fprintf(stderr, "Error: Invalid partition index %d.\n", partitionIndex); + dump_partition_map(map); exit(1); } if (partition->IsExtended()) { fprintf(stderr, "Error: Partition %d is an extended " "partition.\n", partitionIndex); + dump_partition_map(map); exit(1); } partitionOffset = partition->Offset(); - } else { // The given device is the base device. We'll write at // offset 0. @@ -554,13 +591,15 @@ main(int argc, const char *const *argv) Partition *partition = map.PartitionAt(partitionIndex - 1); if (!partition || partition->IsEmpty()) { fprintf(stderr, "Error: Invalid partition index %d.\n", - partitionIndex); + partitionIndex); + dump_partition_map(map); exit(1); } if (partition->IsExtended()) { fprintf(stderr, "Error: Partition %d is an extended " - "partition.\n", partitionIndex); + "partition.\n", partitionIndex); + dump_partition_map(map); exit(1); } partitionOffset = partition->Offset();