From 0a0a999076b0f55fbc96e805a256d2038521f9f5 Mon Sep 17 00:00:00 2001 From: Ingo Weinhold Date: Thu, 31 Mar 2005 11:28:33 +0000 Subject: [PATCH] We now also find a boot partition, if nested inside another partition. Booting from logical partitions should now work properly. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@12188 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/core/fs/vfs.cpp | 33 +++++++++++++++------------------ 1 file changed, 15 insertions(+), 18 deletions(-) diff --git a/src/kernel/core/fs/vfs.cpp b/src/kernel/core/fs/vfs.cpp index 08454bd3d1..ce1e7af30a 100644 --- a/src/kernel/core/fs/vfs.cpp +++ b/src/kernel/core/fs/vfs.cpp @@ -17,6 +17,7 @@ #include #include #include +#include #include #include #include @@ -2754,30 +2755,26 @@ vfs_mount_boot_file_system(kernel_args *args) // ToDo: do this for real! It will currently only use the partition offset; // it does not yet use the disk_identifier information. - // It does also only search the first level. KPartition *bootPartition = NULL; + struct BootPartitionVisitor : KPartitionVisitor { + BootPartitionVisitor(off_t offset) : fOffset(offset) {} + + virtual bool VisitPre(KPartition *partition) + { + return (partition->ContainsFileSystem() + && partition->Offset() == fOffset); + } + private: + off_t fOffset; + } visitor(args->boot_disk.partition_offset); + KDiskDevice *device; int32 cookie = 0; while ((device = manager->NextDevice(&cookie)) != NULL) { - if (device->ContainsFileSystem() - && device->Offset() == args->boot_disk.partition_offset) { - bootPartition = device; - break; - } - - for (int32 i = device->CountChildren(); i-- > 0; ) { - KPartition *partition = device->ChildAt(i); - - if (partition->Offset() == args->boot_disk.partition_offset - && partition->ContainsFileSystem()) { - bootPartition = partition; - break; - } - } - - if (bootPartition != NULL) + bootPartition = device->VisitEachDescendant(&visitor); + if (bootPartition) break; }