Skip to content

Commit

Permalink
Work in progress in getting GPTPartitionHandle working.
Browse files Browse the repository at this point in the history
* 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.
  • Loading branch information
axeld committed Jan 26, 2013
1 parent ab31389 commit 9e8d42a
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build/jam/HaikuImage
Expand Up @@ -678,7 +678,7 @@ AddFilesToHaikuImage system add-ons Screen\ Savers
: $(SYSTEM_ADD_ONS_SCREENSAVERS) ;

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
AddDirectoryToHaikuImage home config add-ons decorators ;
Expand Down
8 changes: 2 additions & 6 deletions src/add-ons/disk_systems/gpt/GPTDiskAddOn.rdef
@@ -1,8 +1,4 @@
/*
* IntelDiskAddOn.rdef
*/

resource app_signature "application/x-vnd.Haiku-IntelDiskAddOn";
resource app_signature "application/x-vnd.Haiku-GPTDiskAddOn";

resource app_version {
major = 1,
Expand All @@ -11,5 +7,5 @@ resource app_version {
variety = 0,
internal = 0,
short_info = "1.0.0",
long_info = "Haiku Intel disk add-on."
long_info = "GUID Partition Table disk add-on."
};
45 changes: 40 additions & 5 deletions src/add-ons/disk_systems/gpt/GPTPartitionHandle.cpp
@@ -1,5 +1,6 @@
/*
* Copyright 2013, Axel Dörfler, axeld@pinc-software.de.
* Copyright 2007, Ingo Weinhold, bonefish@users.sf.net.
* Distributed under the terms of the MIT License.
*/

Expand All @@ -13,6 +14,7 @@
#include <MutablePartition.h>
#include <PartitioningInfo.h>
#include <PartitionParameterEditor.h>
#include <Path.h>

#include <AutoDeleter.h>

Expand Down Expand Up @@ -43,6 +45,23 @@ GPTPartitionHandle::~GPTPartitionHandle()
status_t
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;
}

Expand Down Expand Up @@ -100,10 +119,12 @@ GPTPartitionHandle::GetNextSupportedType(const BMutablePartition* child,
status_t
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();
status_t status = info->SetTo(Partition()->BlockSize(),
size - Partition()->BlockSize());
// TODO: use fHeader
size_t headerSize = Partition()->BlockSize() + 16384;
status_t status = info->SetTo(Partition()->BlockSize() + headerSize,
size - Partition()->BlockSize() - 2 * headerSize);
if (status != B_OK)
return status;

Expand Down Expand Up @@ -141,7 +162,7 @@ status_t
GPTPartitionHandle::ValidateCreateChild(off_t* _offset, off_t* _size,
const char* typeString, BString* name, const char* parameters)
{
return B_BAD_VALUE;
return B_OK;
}


Expand All @@ -150,7 +171,21 @@ GPTPartitionHandle::CreateChild(off_t offset, off_t size,
const char* typeString, const char* name, const char* parameters,
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;
}


Expand Down
5 changes: 5 additions & 0 deletions src/add-ons/disk_systems/gpt/GPTPartitionHandle.h
Expand Up @@ -8,6 +8,8 @@

#include <DiskSystemAddOn.h>

#include "Header.h"


class GPTPartitionHandle : public BPartitionHandle {
public:
Expand Down Expand Up @@ -39,6 +41,9 @@ class GPTPartitionHandle : public BPartitionHandle {
const char* parameters,
BMutablePartition** child);
virtual status_t DeleteChild(BMutablePartition* child);

private:
EFI::Header* fHeader;
};


Expand Down
7 changes: 6 additions & 1 deletion src/add-ons/disk_systems/gpt/Jamfile
@@ -1,6 +1,6 @@
SubDir HAIKU_TOP src add-ons disk_systems gpt ;

UsePrivateHeaders shared storage ;
UsePrivateHeaders interface shared storage ;
UsePrivateSystemHeaders ;

SEARCH_SOURCE
Expand All @@ -13,5 +13,10 @@ Addon <disk_system>gpt :
GPTDiskAddOn.cpp
GPTPartitionHandle.cpp

# from the kernel partitioning system add-on
Header.cpp
crc32.cpp
utility.cpp

: be $(TARGET_LIBSUPC++)
;

0 comments on commit 9e8d42a

Please sign in to comment.