From f191528003d03136fabfde47c4004ccb018fffe8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Axel=20D=C3=B6rfler?= Date: Wed, 25 Aug 2004 15:25:08 +0000 Subject: [PATCH] Added an InitCheck() method; if something goes wrong, the device won't be added to the boot device list anymore. This is currently used to remove devices that don't support the LBA access mechanism (since CHS support has still not been implemented). git-svn-id: file:///srv/svn/repos/haiku/trunk/current@8650 a95241bf-73f2-0310-859d-f6bbb57e9c96 --- .../boot/platform/bios_ia32/devices.cpp | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/kernel/boot/platform/bios_ia32/devices.cpp b/src/kernel/boot/platform/bios_ia32/devices.cpp index ba69ece50c..a1ca7cba53 100644 --- a/src/kernel/boot/platform/bios_ia32/devices.cpp +++ b/src/kernel/boot/platform/bios_ia32/devices.cpp @@ -95,6 +95,8 @@ class BIOSDrive : public Node { BIOSDrive(uint8 driveID); virtual ~BIOSDrive(); + status_t InitCheck() const; + virtual ssize_t ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize); virtual ssize_t WriteAt(void *cookie, off_t pos, const void *buffer, size_t bufferSize); @@ -219,6 +221,14 @@ BIOSDrive::~BIOSDrive() } +status_t +BIOSDrive::InitCheck() const +{ + return fLBA ? B_OK : B_ERROR; + // ToDo: for now... +} + + ssize_t BIOSDrive::ReadAt(void *cookie, off_t pos, void *buffer, size_t bufferSize) { @@ -309,8 +319,12 @@ platform_get_boot_device(struct stage2_args *args, Node **_device) { printf("boot drive ID: %x\n", gBootDriveID); - Node *drive = new BIOSDrive(gBootDriveID); - + BIOSDrive *drive = new BIOSDrive(gBootDriveID); + if (drive->InitCheck() != B_OK) { + puts("no boot drive!"); + return B_ERROR; + } + printf("drive size: %Ld bytes\n", drive->Size()); *_device = drive; @@ -350,6 +364,7 @@ platform_add_block_devices(stage2_args *args, NodeList *devicesList) if (get_number_of_drives(&driveCount) == B_OK) printf("number of drives: %d\n", driveCount); - return B_OK; + return B_OK; } +