Read partition table using BDiskDevice from first disk.
git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@24725 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
parent
ebe5326de3
commit
72497a44d7
|
@ -13,9 +13,10 @@
|
|||
#include "DefaultPartitionPage.h"
|
||||
#include "DescriptionPage.h"
|
||||
#include "FileSelectionPage.h"
|
||||
#include "LegacyBootDrive.h"
|
||||
|
||||
// TODO remove
|
||||
#define USE_TEST_BOOT_DRIVE 1
|
||||
|
||||
#define USE_TEST_BOOT_DRIVE 0
|
||||
|
||||
#if USE_TEST_BOOT_DRIVE
|
||||
#include "TestBootDrive.h"
|
||||
|
@ -35,8 +36,7 @@ BootManagerController::BootManagerController()
|
|||
#if USE_TEST_BOOT_DRIVE
|
||||
fBootDrive = new TestBootDrive();
|
||||
#else
|
||||
// TODO implement
|
||||
fBootDrive = NULL;
|
||||
fBootDrive = new LegacyBootDrive();
|
||||
#endif
|
||||
|
||||
// set defaults
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
SubDir HAIKU_TOP src apps bootman ;
|
||||
|
||||
SetSubDirSupportedPlatformsBeOSCompatible ;
|
||||
UsePrivateHeaders shared ;
|
||||
UsePrivateHeaders storage ;
|
||||
|
||||
Application bootman :
|
||||
BootManager.cpp
|
||||
|
@ -10,6 +11,7 @@ Application bootman :
|
|||
DescriptionPage.cpp
|
||||
EntryPage.cpp
|
||||
FileSelectionPage.cpp
|
||||
LegacyBootDrive.cpp
|
||||
PartitionsPage.cpp
|
||||
TestBootDrive.cpp
|
||||
UninstallPage.cpp
|
||||
|
|
|
@ -0,0 +1,155 @@
|
|||
/*
|
||||
* Copyright 2008, Michael Pfeiffer, laplace@users.sourceforge.net. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
|
||||
|
||||
#include "LegacyBootDrive.h"
|
||||
|
||||
|
||||
#include <DiskDevice.h>
|
||||
#include <DiskDeviceRoster.h>
|
||||
#include <DiskDeviceVisitor.h>
|
||||
#include <Partition.h>
|
||||
#include <Path.h>
|
||||
#include <String.h>
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
|
||||
class PartitionRecorder : public BDiskDeviceVisitor
|
||||
{
|
||||
public:
|
||||
PartitionRecorder(BMessage* settings);
|
||||
|
||||
virtual bool Visit(BDiskDevice* device);
|
||||
virtual bool Visit(BPartition* partition, int32 level);
|
||||
|
||||
private:
|
||||
bool _Record(BPartition* partition);
|
||||
|
||||
BMessage* fSettings;
|
||||
int32 fIndex;
|
||||
};
|
||||
|
||||
|
||||
PartitionRecorder::PartitionRecorder(BMessage* settings)
|
||||
: fSettings(settings)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PartitionRecorder::Visit(BDiskDevice* device)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PartitionRecorder::Visit(BPartition* partition, int32 level)
|
||||
{
|
||||
return _Record(partition);
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
PartitionRecorder::_Record(BPartition* partition)
|
||||
{
|
||||
BPath partitionPath;
|
||||
partition->GetPath(&partitionPath);
|
||||
|
||||
BString buffer;
|
||||
const char* name = partition->ContentName();
|
||||
if (name == NULL) {
|
||||
fIndex ++;
|
||||
buffer << "Unnamed " << fIndex;
|
||||
name = buffer.String();
|
||||
}
|
||||
|
||||
const char* type = partition->Type();
|
||||
if (type == NULL)
|
||||
type = "Unknown";
|
||||
|
||||
BMessage message;
|
||||
message.AddBool("show", true);
|
||||
message.AddString("name", name);
|
||||
message.AddString("type", type);
|
||||
message.AddString("path", partitionPath.Path());
|
||||
message.AddInt64("size", partition->ContentSize());
|
||||
fSettings->AddMessage("partition", &message);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
LegacyBootDrive::LegacyBootDrive()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
LegacyBootDrive::~LegacyBootDrive()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool
|
||||
LegacyBootDrive::IsBootMenuInstalled()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
LegacyBootDrive::ReadPartitions(BMessage *message)
|
||||
{
|
||||
BDiskDeviceRoster diskDeviceRoster;
|
||||
BDiskDevice device;
|
||||
// first disk only
|
||||
if (diskDeviceRoster.GetNextDevice(&device) == B_OK) {
|
||||
BPath path;
|
||||
if (device.GetPath(&path) != B_OK)
|
||||
return B_ERROR;
|
||||
|
||||
message->AddString("disk", path.Path());
|
||||
|
||||
|
||||
PartitionRecorder recorder(message);
|
||||
device.VisitEachDescendant(&recorder);
|
||||
}
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
LegacyBootDrive::WriteBootMenu(BMessage *message)
|
||||
{
|
||||
// TODO
|
||||
printf("WriteBootMenu:\n");
|
||||
message->PrintToStream();
|
||||
|
||||
BMessage partition;
|
||||
int32 index = 0;
|
||||
for (; message->FindMessage("partition", index, &partition) == B_OK; index ++) {
|
||||
printf("Partition %d:\n", (int)index);
|
||||
partition.PrintToStream();
|
||||
}
|
||||
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
LegacyBootDrive::SaveMasterBootRecord(BFile *file)
|
||||
{
|
||||
// TODO implement
|
||||
return B_OK;
|
||||
}
|
||||
|
||||
|
||||
status_t
|
||||
LegacyBootDrive::RestoreMasterBootRecord(BFile *file)
|
||||
{
|
||||
// TODO implement
|
||||
return B_OK;
|
||||
}
|
|
@ -0,0 +1,23 @@
|
|||
/*
|
||||
* Copyright 2008, Michael Pfeiffer, laplace@users.sourceforge.net. All rights reserved.
|
||||
* Distributed under the terms of the MIT License.
|
||||
*/
|
||||
#ifndef LEGACY_BOOT_DRIVE_H
|
||||
#define LEGACY_BOOT_DRIVE_H
|
||||
|
||||
#include "BootDrive.h"
|
||||
|
||||
class LegacyBootDrive : public BootDrive
|
||||
{
|
||||
public:
|
||||
LegacyBootDrive();
|
||||
virtual ~LegacyBootDrive();
|
||||
|
||||
virtual bool IsBootMenuInstalled();
|
||||
virtual status_t ReadPartitions(BMessage *message);
|
||||
virtual status_t WriteBootMenu(BMessage *message);
|
||||
virtual status_t SaveMasterBootRecord(BFile *file);
|
||||
virtual status_t RestoreMasterBootRecord(BFile *file);
|
||||
};
|
||||
|
||||
#endif // LEGACY_BOOT_DRIVE_H
|
Loading…
Reference in New Issue