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; }