Work in progress in getting GPTPartitionHandle working.

* Tried to use EFI::Header class, but there doesn't seem to be an easy
  way to actually hit the disk -- which we'll have to do to find out
  how large the GPT table is.
* Initialization of GPT disks is now working which is why I added the disk
  system add-on to the image. However, there is a caveat, as the backup
  header and table aren't written yet.
* Partitions can be deleted.
* Creating partitions does not work yet, but I don't know yet why; in
  theory it could already work.
This commit is contained in:
Axel Dörfler
2013-01-26 01:33:27 +01:00
parent ab31389341
commit 9e8d42ac44
5 changed files with 54 additions and 13 deletions
+1 -1
View File
@@ -678,7 +678,7 @@ AddFilesToHaikuImage system add-ons Screen\ Savers
: $(SYSTEM_ADD_ONS_SCREENSAVERS) ; : $(SYSTEM_ADD_ONS_SCREENSAVERS) ;
AddFilesToHaikuImage system add-ons disk_systems AddFilesToHaikuImage system add-ons disk_systems
: <disk_system>intel <disk_system>bfs <disk_system>ntfs ; : <disk_system>intel <disk_system>gpt <disk_system>bfs <disk_system>ntfs ;
# decorators # decorators
AddDirectoryToHaikuImage home config add-ons decorators ; AddDirectoryToHaikuImage home config add-ons decorators ;
@@ -1,8 +1,4 @@
/* resource app_signature "application/x-vnd.Haiku-GPTDiskAddOn";
* IntelDiskAddOn.rdef
*/
resource app_signature "application/x-vnd.Haiku-IntelDiskAddOn";
resource app_version { resource app_version {
major = 1, major = 1,
@@ -11,5 +7,5 @@ resource app_version {
variety = 0, variety = 0,
internal = 0, internal = 0,
short_info = "1.0.0", short_info = "1.0.0",
long_info = "Haiku Intel disk add-on." long_info = "GUID Partition Table disk add-on."
}; };
@@ -1,5 +1,6 @@
/* /*
* Copyright 2013, Axel Dörfler, [email protected]. * Copyright 2013, Axel Dörfler, [email protected].
* Copyright 2007, Ingo Weinhold, [email protected].
* Distributed under the terms of the MIT License. * Distributed under the terms of the MIT License.
*/ */
@@ -13,6 +14,7 @@
#include <MutablePartition.h> #include <MutablePartition.h>
#include <PartitioningInfo.h> #include <PartitioningInfo.h>
#include <PartitionParameterEditor.h> #include <PartitionParameterEditor.h>
#include <Path.h>
#include <AutoDeleter.h> #include <AutoDeleter.h>
@@ -43,6 +45,23 @@ GPTPartitionHandle::~GPTPartitionHandle()
status_t status_t
GPTPartitionHandle::Init() GPTPartitionHandle::Init()
{ {
// TODO: how to get the path of a BMutablePartition?
//BPath path;
//status_t status = Partition()->GetPath(&path);
//if (status != B_OK)
//return status;
//fd = open(path.Path(), O_RDONLY);
//if (fd < 0)
//return errno;
//fHeader = new EFI::Header(fd, Partition()->BlockSize(),
//Partition()->BlockSize());
//status = fHeader->InitCheck();
//if (status != B_OK)
//return status;
//close(fd);
return B_OK; return B_OK;
} }
@@ -100,10 +119,12 @@ GPTPartitionHandle::GetNextSupportedType(const BMutablePartition* child,
status_t status_t
GPTPartitionHandle::GetPartitioningInfo(BPartitioningInfo* info) GPTPartitionHandle::GetPartitioningInfo(BPartitioningInfo* info)
{ {
// init to the full size (minus the first sector) // init to the full size (minus the GPT table header and entries)
off_t size = Partition()->ContentSize(); off_t size = Partition()->ContentSize();
status_t status = info->SetTo(Partition()->BlockSize(), // TODO: use fHeader
size - Partition()->BlockSize()); size_t headerSize = Partition()->BlockSize() + 16384;
status_t status = info->SetTo(Partition()->BlockSize() + headerSize,
size - Partition()->BlockSize() - 2 * headerSize);
if (status != B_OK) if (status != B_OK)
return status; return status;
@@ -141,7 +162,7 @@ status_t
GPTPartitionHandle::ValidateCreateChild(off_t* _offset, off_t* _size, GPTPartitionHandle::ValidateCreateChild(off_t* _offset, off_t* _size,
const char* typeString, BString* name, const char* parameters) const char* typeString, BString* name, const char* parameters)
{ {
return B_BAD_VALUE; return B_OK;
} }
@@ -150,7 +171,21 @@ GPTPartitionHandle::CreateChild(off_t offset, off_t size,
const char* typeString, const char* name, const char* parameters, const char* typeString, const char* name, const char* parameters,
BMutablePartition** _child) BMutablePartition** _child)
{ {
return B_BAD_VALUE; // create the child
BMutablePartition* partition = Partition();
BMutablePartition* child;
status_t status = partition->CreateChild(0, typeString, name,
parameters, &child);
if (status != B_OK)
return status;
// init the child
child->SetOffset(offset);
child->SetSize(size);
child->SetBlockSize(partition->BlockSize());
*_child = child;
return B_OK;
} }
@@ -8,6 +8,8 @@
#include <DiskSystemAddOn.h> #include <DiskSystemAddOn.h>
#include "Header.h"
class GPTPartitionHandle : public BPartitionHandle { class GPTPartitionHandle : public BPartitionHandle {
public: public:
@@ -39,6 +41,9 @@ public:
const char* parameters, const char* parameters,
BMutablePartition** child); BMutablePartition** child);
virtual status_t DeleteChild(BMutablePartition* child); virtual status_t DeleteChild(BMutablePartition* child);
private:
EFI::Header* fHeader;
}; };
+6 -1
View File
@@ -1,6 +1,6 @@
SubDir HAIKU_TOP src add-ons disk_systems gpt ; SubDir HAIKU_TOP src add-ons disk_systems gpt ;
UsePrivateHeaders shared storage ; UsePrivateHeaders interface shared storage ;
UsePrivateSystemHeaders ; UsePrivateSystemHeaders ;
SEARCH_SOURCE SEARCH_SOURCE
@@ -13,5 +13,10 @@ Addon <disk_system>gpt :
GPTDiskAddOn.cpp GPTDiskAddOn.cpp
GPTPartitionHandle.cpp GPTPartitionHandle.cpp
# from the kernel partitioning system add-on
Header.cpp
crc32.cpp
utility.cpp
: be $(TARGET_LIBSUPC++) : be $(TARGET_LIBSUPC++)
; ;