From abb0fbc167f8fae2506cc23f84aa8872c45fa000 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Mon, 15 Nov 2004 20:02:04 +0000 Subject: [PATCH] vfs_mount_boot_file_system() now at least checks for the right partition offset to recognize the boot volume. This should work well enough for now (as long as you don't have too many disks in your system). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@9965 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- src/kernel/core/fs/vfs.cpp | 53 +++++++++++++++++++++++++++++--------- 1 file changed, 41 insertions(+), 12 deletions(-) diff --git a/src/kernel/core/fs/vfs.cpp b/src/kernel/core/fs/vfs.cpp index 6606442d80..634cbf319d 100755 --- a/src/kernel/core/fs/vfs.cpp +++ b/src/kernel/core/fs/vfs.cpp @@ -1,10 +1,10 @@ /* -** Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de. All rights reserved. -** Distributed under the terms of the Haiku License. -** -** Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. -** Distributed under the terms of the NewOS License. -*/ + * Copyright 2002-2004, Axel Dörfler, axeld@pinc-software.de. + * Distributed under the terms of the MIT License. + * + * Copyright 2001-2002, Travis Geiselbrecht. All rights reserved. + * Distributed under the terms of the NewOS License. + */ /* Virtual File System and File System Interface Layer */ @@ -2217,7 +2217,7 @@ vfs_bootstrap_file_systems(void) status_t -vfs_mount_boot_file_system() +vfs_mount_boot_file_system(kernel_args *args) { // make the boot partition (and probably others) available KDiskDeviceManager::CreateDefault(); @@ -2238,11 +2238,40 @@ vfs_mount_boot_file_system() if ((bootfs = get_file_system("bootfs")) == NULL) { // no bootfs there, yet - // ToDo: do this for real! - status_t status = _kern_mount("/boot", "/dev/disk/scsi/0/0/0/raw", - "bfs", 0, NULL); - if (status < B_OK) - panic("could not get boot device: %s!\n", strerror(status)); + // 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; + + 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) + break; + } + + KPath path; + if (bootPartition == NULL + || bootPartition->GetPath(&path) != B_OK + || _kern_mount("/boot", path.Path(), "bfs", 0, NULL) < B_OK) + panic("could not get boot device!\n"); } else put_file_system(bootfs);