* Now checks if the BootMethod allocation succeeds.
* Minor cleanup, reordered header files to go from private/local to public/global. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@21623 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,23 +1,15 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2007, Ingo Weinhold, [email protected].
|
* Copyright 2007, Ingo Weinhold, [email protected].
|
||||||
* Copyright 2002-2006, Axel Dörfler, [email protected].
|
* Copyright 2002-2007, Axel Dörfler, [email protected].
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
* Copyright 2001-2002, Travis Geiselbrecht. All rights reserved.
|
||||||
* Distributed under the terms of the NewOS License.
|
* Distributed under the terms of the NewOS License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
#include "vfs_boot.h"
|
#include "vfs_boot.h"
|
||||||
|
#include "vfs_net_boot.h"
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
#include <OS.h>
|
|
||||||
#include <fs_info.h>
|
|
||||||
|
|
||||||
#include <disk_device_manager/KDiskDevice.h>
|
|
||||||
#include <disk_device_manager/KDiskDeviceManager.h>
|
|
||||||
#include <disk_device_manager/KPartitionVisitor.h>
|
|
||||||
#include <DiskDeviceTypes.h>
|
|
||||||
|
|
||||||
#include <vfs.h>
|
#include <vfs.h>
|
||||||
#include <file_cache.h>
|
#include <file_cache.h>
|
||||||
@@ -27,7 +19,15 @@
|
|||||||
#include <util/KMessage.h>
|
#include <util/KMessage.h>
|
||||||
#include <util/Stack.h>
|
#include <util/Stack.h>
|
||||||
|
|
||||||
#include "vfs_net_boot.h"
|
#include <disk_device_manager/KDiskDevice.h>
|
||||||
|
#include <disk_device_manager/KDiskDeviceManager.h>
|
||||||
|
#include <disk_device_manager/KPartitionVisitor.h>
|
||||||
|
#include <DiskDeviceTypes.h>
|
||||||
|
|
||||||
|
#include <OS.h>
|
||||||
|
#include <fs_info.h>
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
|
||||||
//#define TRACE_VFS
|
//#define TRACE_VFS
|
||||||
@@ -56,7 +56,7 @@ static struct {
|
|||||||
dev_t gBootDevice = -1;
|
dev_t gBootDevice = -1;
|
||||||
|
|
||||||
|
|
||||||
/** No image was chosen - prefer disks with names like "Haiku", or "System"
|
/*! No image was chosen - prefer disks with names like "Haiku", or "System"
|
||||||
*/
|
*/
|
||||||
int
|
int
|
||||||
compare_image_boot(const void *_a, const void *_b)
|
compare_image_boot(const void *_a, const void *_b)
|
||||||
@@ -89,10 +89,10 @@ compare_image_boot(const void *_a, const void *_b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** The system was booted from CD - prefer CDs over other entries. If there
|
/*! The system was booted from CD - prefer CDs over other entries. If there
|
||||||
* is no CD, fall back to the standard mechanism (as implemented by
|
is no CD, fall back to the standard mechanism (as implemented by
|
||||||
* compare_image_boot().
|
compare_image_boot().
|
||||||
*/
|
*/
|
||||||
static int
|
static int
|
||||||
compare_cd_boot(const void *_a, const void *_b)
|
compare_cd_boot(const void *_a, const void *_b)
|
||||||
{
|
{
|
||||||
@@ -110,12 +110,12 @@ compare_cd_boot(const void *_a, const void *_b)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Computes a check sum for the specified block.
|
/*! Computes a check sum for the specified block.
|
||||||
* The check sum is the sum of all data in that block interpreted as an
|
The check sum is the sum of all data in that block interpreted as an
|
||||||
* array of uint32 values.
|
array of uint32 values.
|
||||||
* Note, this must use the same method as the one used in
|
Note, this must use the same method as the one used in
|
||||||
* boot/platform/bios_ia32/devices.cpp (or similar solutions).
|
boot/platform/bios_ia32/devices.cpp (or similar solutions).
|
||||||
*/
|
*/
|
||||||
static uint32
|
static uint32
|
||||||
compute_check_sum(KDiskDevice *device, off_t offset)
|
compute_check_sum(KDiskDevice *device, off_t offset)
|
||||||
{
|
{
|
||||||
@@ -142,8 +142,9 @@ compute_check_sum(KDiskDevice *device, off_t offset)
|
|||||||
|
|
||||||
|
|
||||||
BootMethod::BootMethod(const KMessage& bootVolume, int32 method)
|
BootMethod::BootMethod(const KMessage& bootVolume, int32 method)
|
||||||
: fBootVolume(bootVolume),
|
:
|
||||||
fMethod(method)
|
fBootVolume(bootVolume),
|
||||||
|
fMethod(method)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,12 +278,12 @@ DiskBootMethod::SortPartitions(KPartition** partitions, int32 count)
|
|||||||
// #pragma mark -
|
// #pragma mark -
|
||||||
|
|
||||||
|
|
||||||
/** Make the boot partition (and probably others) available.
|
/*! Make the boot partition (and probably others) available.
|
||||||
* The partitions that are a boot candidate a put into the /a partitions
|
The partitions that are a boot candidate a put into the /a partitions
|
||||||
* stack. If the user selected a boot device, there is will only be one
|
stack. If the user selected a boot device, there is will only be one
|
||||||
* entry in this stack; if not, the most likely is put up first.
|
entry in this stack; if not, the most likely is put up first.
|
||||||
* The boot code should then just try them one by one.
|
The boot code should then just try them one by one.
|
||||||
*/
|
*/
|
||||||
static status_t
|
static status_t
|
||||||
get_boot_partitions(kernel_args *args, PartitionStack &partitions)
|
get_boot_partitions(kernel_args *args, PartitionStack &partitions)
|
||||||
{
|
{
|
||||||
@@ -355,7 +356,7 @@ dprintf("get_boot_partitions(): boot method type: %ld\n", bootMethodType);
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
status_t status = bootMethod->Init();
|
status_t status = bootMethod != NULL ? bootMethod->Init() : B_NO_MEMORY;
|
||||||
if (status != B_OK)
|
if (status != B_OK)
|
||||||
return status;
|
return status;
|
||||||
|
|
||||||
@@ -364,7 +365,8 @@ dprintf("get_boot_partitions(): boot method type: %ld\n", bootMethodType);
|
|||||||
|
|
||||||
status = manager->InitialDeviceScan();
|
status = manager->InitialDeviceScan();
|
||||||
if (status != B_OK) {
|
if (status != B_OK) {
|
||||||
dprintf("KDiskDeviceManager::InitialDeviceScan() failed: %s\n", strerror(status));
|
dprintf("KDiskDeviceManager::InitialDeviceScan() failed: %s\n",
|
||||||
|
strerror(status));
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,10 +48,10 @@ compare_partitions_net_devices(const void *_a, const void *_b)
|
|||||||
KPartition* a = *(KPartition**)_a;
|
KPartition* a = *(KPartition**)_a;
|
||||||
KPartition* b = *(KPartition**)_b;
|
KPartition* b = *(KPartition**)_b;
|
||||||
|
|
||||||
bool aIsCD = is_net_device(a->Device());
|
bool aIsNetDevice = is_net_device(a->Device());
|
||||||
bool bIsCD = is_net_device(b->Device());
|
bool bIsNetDevice = is_net_device(b->Device());
|
||||||
|
|
||||||
int compare = (int)aIsCD - (int)bIsCD;
|
int compare = (int)aIsNetDevice - (int)bIsNetDevice;
|
||||||
if (compare != 0)
|
if (compare != 0)
|
||||||
return compare;
|
return compare;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user