[haiku-commits] haiku: hrev51171 - in src/system/boot: loader platform/efi platform/atari_m68k platform/u-boot platform/pxe_ia32

  • From: jessica.l.hamilton@xxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Wed, 17 May 2017 11:43:07 +0200 (CEST)

hrev51171 adds 1 changeset to branch 'master'
old head: 0fd22aa1bd293b757ee5406e0518e193835c30b1
new head: e888217124fa9fb214ffa790e6a66dca3917f25e
overview: 
http://cgit.haiku-os.org/haiku/log/?qt=range&q=e888217124fa+%5E0fd22aa1bd29

----------------------------------------------------------------------------

e888217124fa: loader: fetch all potential boot partitions for boot device.
  
  This allows the loader to skip BFS partitions that don't contain
  a bootable system. Useful when you have a BFS data partition that
  comes before the system partition when iterated over.
  
  Currently, only the UEFI loader actually returns more than one
  possible partition.

                         [ Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx> ]

----------------------------------------------------------------------------

Revision:    hrev51171
Commit:      e888217124fa9fb214ffa790e6a66dca3917f25e
URL:         http://cgit.haiku-os.org/haiku/commit/?id=e888217124fa
Author:      Jessica Hamilton <jessica.l.hamilton@xxxxxxxxx>
Date:        Sat May 13 19:50:17 2017 UTC

----------------------------------------------------------------------------

10 files changed, 51 insertions(+), 48 deletions(-)
headers/private/kernel/boot/platform.h           |  4 +-
src/system/boot/loader/vfs.cpp                   | 39 +++++++++++---------
src/system/boot/platform/amiga_m68k/devices.cpp  |  4 +-
src/system/boot/platform/atari_m68k/devices.cpp  |  6 +--
src/system/boot/platform/bios_ia32/devices.cpp   |  6 +--
src/system/boot/platform/cfe/devices.cpp         |  6 +--
src/system/boot/platform/efi/devices.cpp         | 16 ++++----
.../boot/platform/openfirmware/devices.cpp       |  6 +--
src/system/boot/platform/pxe_ia32/devices.cpp    |  6 +--
src/system/boot/platform/u-boot/devices.cpp      |  6 +--

----------------------------------------------------------------------------

diff --git a/headers/private/kernel/boot/platform.h 
b/headers/private/kernel/boot/platform.h
index 7d3afda..f343c94 100644
--- a/headers/private/kernel/boot/platform.h
+++ b/headers/private/kernel/boot/platform.h
@@ -58,8 +58,8 @@ namespace boot {
 
 extern status_t platform_add_boot_device(struct stage2_args *args, NodeList 
*devicesList);
 extern status_t platform_add_block_devices(struct stage2_args *args, NodeList 
*devicesList);
-extern status_t platform_get_boot_partition(struct stage2_args *args, Node 
*bootDevice,
-                                       NodeList *partitions, boot::Partition 
**_partition);
+extern status_t platform_get_boot_partitions(struct stage2_args *args, Node 
*bootDevice,
+                                       NodeList *partitions, NodeList 
*bootPartitions);
 extern status_t platform_register_boot_device(Node *device);
 
 /* menu functions */
diff --git a/src/system/boot/loader/vfs.cpp b/src/system/boot/loader/vfs.cpp
index 2a57686..88a3ba6 100644
--- a/src/system/boot/loader/vfs.cpp
+++ b/src/system/boot/loader/vfs.cpp
@@ -659,28 +659,33 @@ get_boot_file_system(stage2_args* args, BootVolume& 
_bootVolume)
                if (error != B_OK)
                        continue;
 
-               Partition *partition;
-               error = platform_get_boot_partition(args, device, &gPartitions, 
&partition);
+               NodeList bootPartitions;
+               error = platform_get_boot_partitions(args, device, 
&gPartitions, &bootPartitions);
                if (error != B_OK)
                        continue;
 
-               Directory *fileSystem;
-               error = partition->Mount(&fileSystem, true);
-               if (error != B_OK) {
-                       // this partition doesn't contain any known file 
system; we
-                       // don't need it anymore
-                       gPartitions.Remove(partition);
-                       delete partition;
-                       continue;
-               }
+               NodeIterator partitionIterator = bootPartitions.GetIterator();
+               while (partitionIterator.HasNext()) {
+                       Partition *partition = 
(Partition*)partitionIterator.Next();
+
+                       Directory *fileSystem;
+                       error = partition->Mount(&fileSystem, true);
+                       if (error != B_OK) {
+                               // this partition doesn't contain any known 
file system; we
+                               // don't need it anymore
+                               gPartitions.Remove(partition);
+                               delete partition;
+                               continue;
+                       }
 
-               // init the BootVolume
-               error = _bootVolume.SetTo(fileSystem);
-               if (error != B_OK)
-                       continue;
+                       // init the BootVolume
+                       error = _bootVolume.SetTo(fileSystem);
+                       if (error != B_OK)
+                               continue;
 
-               sBootDevice = device;
-               return B_OK;
+                       sBootDevice = device;
+                       return B_OK;
+               }
        }
 
        return B_ERROR;
diff --git a/src/system/boot/platform/amiga_m68k/devices.cpp 
b/src/system/boot/platform/amiga_m68k/devices.cpp
index 4030f02..621a803 100644
--- a/src/system/boot/platform/amiga_m68k/devices.cpp
+++ b/src/system/boot/platform/amiga_m68k/devices.cpp
@@ -168,8 +168,8 @@ platform_add_boot_device(struct stage2_args *args, NodeList 
*devicesList)
 
 
 status_t
-platform_get_boot_partition(struct stage2_args *args, Node *bootDevice,
-       NodeList *list, boot::Partition **_partition)
+platform_get_boot_partitions(struct stage2_args *args, Node *bootDevice,
+       NodeList *list, NodeList *partitions)
 {
 
 //TODO
diff --git a/src/system/boot/platform/atari_m68k/devices.cpp 
b/src/system/boot/platform/atari_m68k/devices.cpp
index 002467c..cc9fcef 100644
--- a/src/system/boot/platform/atari_m68k/devices.cpp
+++ b/src/system/boot/platform/atari_m68k/devices.cpp
@@ -1189,8 +1189,8 @@ platform_add_boot_device(struct stage2_args *args, 
NodeList *devicesList)
 
 
 status_t
-platform_get_boot_partition(struct stage2_args *args, Node *bootDevice,
-       NodeList *list, boot::Partition **_partition)
+platform_get_boot_partitions(struct stage2_args *args, Node *bootDevice,
+       NodeList *list, NodeList *partitionList)
 {
        BlockHandle *drive = static_cast<BlockHandle *>(bootDevice);
        off_t offset = (off_t)gBootPartitionOffset * drive->BlockSize();
@@ -1205,7 +1205,7 @@ platform_get_boot_partition(struct stage2_args *args, 
Node *bootDevice,
                // offset as reported by the BFS boot block
                if (offset >= partition->offset
                        && offset < partition->offset + partition->size) {
-                       *_partition = partition;
+                       partitionList->Insert(partition);
                        return B_OK;
                }
        }
diff --git a/src/system/boot/platform/bios_ia32/devices.cpp 
b/src/system/boot/platform/bios_ia32/devices.cpp
index cdb6cc9..7a86f41 100644
--- a/src/system/boot/platform/bios_ia32/devices.cpp
+++ b/src/system/boot/platform/bios_ia32/devices.cpp
@@ -878,8 +878,8 @@ platform_add_boot_device(struct stage2_args *args, NodeList 
*devicesList)
 
 
 status_t
-platform_get_boot_partition(struct stage2_args *args, Node *bootDevice,
-       NodeList *list, boot::Partition **_partition)
+platform_get_boot_partitions(struct stage2_args *args, Node *bootDevice,
+       NodeList *list, NodeList *bootList)
 {
        BIOSDrive *drive = static_cast<BIOSDrive *>(bootDevice);
        off_t offset = (off_t)gBootPartitionOffset * drive->BlockSize();
@@ -894,7 +894,7 @@ platform_get_boot_partition(struct stage2_args *args, Node 
*bootDevice,
                // offset as reported by the BFS boot block
                if (offset >= partition->offset
                        && offset < partition->offset + partition->size) {
-                       *_partition = partition;
+                       bootList->Insert(partition);
                        return B_OK;
                }
        }
diff --git a/src/system/boot/platform/cfe/devices.cpp 
b/src/system/boot/platform/cfe/devices.cpp
index 13e7e6c..36cf258 100644
--- a/src/system/boot/platform/cfe/devices.cpp
+++ b/src/system/boot/platform/cfe/devices.cpp
@@ -34,14 +34,14 @@ platform_add_boot_device(struct stage2_args *args, NodeList 
*devicesList)
 
 
 status_t
-platform_get_boot_partition(struct stage2_args *args, Node *device,
-       NodeList *list, boot::Partition **_partition)
+platform_get_boot_partitions(struct stage2_args *args, Node *device,
+       NodeList *list, NodeList *partitionList)
 {
        NodeIterator iterator = list->GetIterator();
        boot::Partition *partition = NULL;
        while ((partition = (boot::Partition *)iterator.Next()) != NULL) {
                // ToDo: just take the first partition for now
-               *_partition = partition;
+               partitionList->Insert(partition);
                return B_OK;
        }
 
diff --git a/src/system/boot/platform/efi/devices.cpp 
b/src/system/boot/platform/efi/devices.cpp
index 848db37..bc9876b 100644
--- a/src/system/boot/platform/efi/devices.cpp
+++ b/src/system/boot/platform/efi/devices.cpp
@@ -440,7 +440,7 @@ device_contains_partition(EfiDevice *device, 
boot::Partition *partition)
        }
 
        if ((partition->offset + partition->size) <= device->Size())
-                       return true;
+               return true;
 
        return false;
 }
@@ -482,19 +482,17 @@ platform_add_block_devices(struct stage2_args *args, 
NodeList *devicesList)
 
 
 status_t
-platform_get_boot_partition(struct stage2_args *args, Node *bootDevice,
-               NodeList *partitions, boot::Partition **_partition)
+platform_get_boot_partitions(struct stage2_args *args, Node *bootDevice,
+               NodeList *partitions, NodeList *bootPartitions)
 {
        NodeIterator iterator = partitions->GetIterator();
        boot::Partition *partition = NULL;
-       while ((partition = (boot::Partition *)iterator.Next()) != NULL) {
-               if (device_contains_partition((EfiDevice*)bootDevice, 
partition)) {
-                       *_partition = partition;
-                       return B_OK;
-               }
+       while ((partition = (boot::Partition*)iterator.Next()) != NULL) {
+               if (device_contains_partition((EfiDevice*)bootDevice, 
partition))
+                       bootPartitions->Insert(partition);
        }
 
-       return B_ENTRY_NOT_FOUND;
+       return bootPartitions->Count() > 0 ? B_OK : B_ENTRY_NOT_FOUND;
 }
 
 
diff --git a/src/system/boot/platform/openfirmware/devices.cpp 
b/src/system/boot/platform/openfirmware/devices.cpp
index b58e30f..85da5d6 100644
--- a/src/system/boot/platform/openfirmware/devices.cpp
+++ b/src/system/boot/platform/openfirmware/devices.cpp
@@ -125,14 +125,14 @@ platform_add_boot_device(struct stage2_args *args, 
NodeList *devicesList)
 
 
 status_t
-platform_get_boot_partition(struct stage2_args *args, Node *device,
-       NodeList *list, boot::Partition **_partition)
+platform_get_boot_partitions(struct stage2_args *args, Node *device,
+       NodeList *list, NodeList *partitionList)
 {
        NodeIterator iterator = list->GetIterator();
        boot::Partition *partition = NULL;
        while ((partition = (boot::Partition *)iterator.Next()) != NULL) {
                // ToDo: just take the first partition for now
-               *_partition = partition;
+               partitionList->Insert(partition);
                return B_OK;
        }
 
diff --git a/src/system/boot/platform/pxe_ia32/devices.cpp 
b/src/system/boot/platform/pxe_ia32/devices.cpp
index 73a7c8f..8fa1d4d 100644
--- a/src/system/boot/platform/pxe_ia32/devices.cpp
+++ b/src/system/boot/platform/pxe_ia32/devices.cpp
@@ -117,15 +117,15 @@ platform_add_boot_device(struct stage2_args *args, 
NodeList *devicesList)
 
 
 status_t
-platform_get_boot_partition(struct stage2_args *args, Node *device,
-       NodeList *list, boot::Partition **_partition)
+platform_get_boot_partitions(struct stage2_args *args, Node *device,
+       NodeList *list, NodeList *partitionList)
 {
        TRACE("platform_get_boot_partition\n");
        NodeIterator iterator = list->GetIterator();
        boot::Partition *partition = NULL;
        while ((partition = (boot::Partition *)iterator.Next()) != NULL) {
                // ToDo: just take the first partition for now
-               *_partition = partition;
+               partitionList->Insert(partition);
                return B_OK;
        }
 
diff --git a/src/system/boot/platform/u-boot/devices.cpp 
b/src/system/boot/platform/u-boot/devices.cpp
index a1a6916..c9d79fb 100644
--- a/src/system/boot/platform/u-boot/devices.cpp
+++ b/src/system/boot/platform/u-boot/devices.cpp
@@ -47,8 +47,8 @@ platform_add_boot_device(struct stage2_args *args, NodeList 
*devicesList)
 
 
 status_t
-platform_get_boot_partition(struct stage2_args *args, Node *device,
-       NodeList *list, boot::Partition **_partition)
+platform_get_boot_partitions(struct stage2_args *args, Node *device,
+       NodeList *list, NodeList *partitionList)
 {
        TRACE("platform_get_boot_partition\n");
 
@@ -56,7 +56,7 @@ platform_get_boot_partition(struct stage2_args *args, Node 
*device,
        boot::Partition *partition = NULL;
        while ((partition = (boot::Partition *)iterator.Next()) != NULL) {
                // ToDo: just take the first partition for now
-               *_partition = partition;
+               partitionList->Insert(partition);
                return B_OK;
        }
 


Other related posts: