[haiku-commits] haiku: hrev45207 - src/add-ons/kernel/partitioning_systems/gpt

  • From: axeld@xxxxxxxxxxxxxxxx
  • To: haiku-commits@xxxxxxxxxxxxx
  • Date: Sat, 26 Jan 2013 21:13:12 +0100 (CET)

hrev45207 adds 3 changesets to branch 'master'
old head: ee5f683bd36a783f1072bfad10ca37a784affd3c
new head: 90308ec327dce4e1894b4507f9197ba92512926c
overview: http://cgit.haiku-os.org/haiku/log/?qt=range&q=90308ec+%5Eee5f683

----------------------------------------------------------------------------

959e02a: gpt: for now, always add partitions at the end.

ef2558c: gpt: Fixed a number of remaining issues.
  
  * The header and table is now correctly written; the backup is still
    missing, though.
  * The Header class is now responsible for both, the primary, and the
    backup header.
  * Changed the Header constructors: the block is no longer needed. Also,
    under GCC 4 the initialization code accidentally used the read
    Header constructor.
  * Fixed incorrectly copied GUID - the static_guid cannot be copied
    into a guid_t directly.
  * Fixed copy&paste bug that would overwrite the offset for the child
    partition to be created.
  * With all of this in place I successfully created a BFS partition
    with a GUID partition table. However, I have not yet tested if other
    systems can still read this. Also, creating two partitions doesn't
    seem to work yet, either (luckily I only need a single one ;-)).

90308ec: gpt: Pointer style changed to preferred.

                                   [ Axel Dörfler <axeld@xxxxxxxxxxxxxxxx> ]

----------------------------------------------------------------------------

7 files changed, 160 insertions(+), 129 deletions(-)
.../disk_systems/gpt/GPTPartitionHandle.cpp      |   4 +-
.../kernel/partitioning_systems/gpt/Header.cpp   |  43 +++--
.../kernel/partitioning_systems/gpt/Header.h     |  13 +-
.../kernel/partitioning_systems/gpt/efi_gpt.cpp  | 180 ++++++++++---------
.../partitioning_systems/gpt/gpt_known_guids.h   |  23 ++-
.../kernel/partitioning_systems/gpt/utility.cpp  |  24 +--
.../kernel/partitioning_systems/gpt/utility.h    |   2 +-

############################################################################

Commit:      959e02aa5686ef9293abd15979aa19ccd9e21aa3
URL:         http://cgit.haiku-os.org/haiku/commit/?id=959e02a
Author:      Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date:        Sat Jan 26 19:40:01 2013 UTC

gpt: for now, always add partitions at the end.

----------------------------------------------------------------------------

diff --git a/src/add-ons/disk_systems/gpt/GPTPartitionHandle.cpp 
b/src/add-ons/disk_systems/gpt/GPTPartitionHandle.cpp
index 66227fe..73dfc1c 100644
--- a/src/add-ons/disk_systems/gpt/GPTPartitionHandle.cpp
+++ b/src/add-ons/disk_systems/gpt/GPTPartitionHandle.cpp
@@ -174,8 +174,8 @@ GPTPartitionHandle::CreateChild(off_t offset, off_t size,
        // create the child
        BMutablePartition* partition = Partition();
        BMutablePartition* child;
-       status_t status = partition->CreateChild(0, typeString, name,
-               parameters, &child);
+       status_t status = partition->CreateChild(partition->CountChildren(),
+               typeString, name, parameters, &child);
        if (status != B_OK)
                return status;
 

############################################################################

Commit:      ef2558c0aea88aa525b9ede73710a513dc47de6b
URL:         http://cgit.haiku-os.org/haiku/commit/?id=ef2558c
Author:      Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date:        Sat Jan 26 19:43:59 2013 UTC

gpt: Fixed a number of remaining issues.

* The header and table is now correctly written; the backup is still
  missing, though.
* The Header class is now responsible for both, the primary, and the
  backup header.
* Changed the Header constructors: the block is no longer needed. Also,
  under GCC 4 the initialization code accidentally used the read
  Header constructor.
* Fixed incorrectly copied GUID - the static_guid cannot be copied
  into a guid_t directly.
* Fixed copy&paste bug that would overwrite the offset for the child
  partition to be created.
* With all of this in place I successfully created a BFS partition
  with a GUID partition table. However, I have not yet tested if other
  systems can still read this. Also, creating two partitions doesn't
  seem to work yet, either (luckily I only need a single one ;-)).

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/partitioning_systems/gpt/Header.cpp 
b/src/add-ons/kernel/partitioning_systems/gpt/Header.cpp
index 6bcd288..c47b64c 100644
--- a/src/add-ons/kernel/partitioning_systems/gpt/Header.cpp
+++ b/src/add-ons/kernel/partitioning_systems/gpt/Header.cpp
@@ -38,9 +38,8 @@
 namespace EFI {
 
 
-Header::Header(int fd, off_t block, uint32 blockSize)
+Header::Header(int fd, uint64 lastBlock, uint32 blockSize)
        :
-       fBlock(block),
        fBlockSize(blockSize),
        fStatus(B_NO_INIT),
        fEntries(NULL)
@@ -49,8 +48,8 @@ Header::Header(int fd, off_t block, uint32 blockSize)
 
        // read and check the partition table header
 
-       ssize_t bytesRead = read_pos(fd, block * blockSize, &fHeader,
-               sizeof(efi_table_header));
+       ssize_t bytesRead = read_pos(fd, (uint64)EFI_HEADER_LOCATION * 
blockSize,
+               &fHeader, sizeof(efi_table_header));
        if (bytesRead != (ssize_t)sizeof(efi_table_header)) {
                if (bytesRead < B_OK)
                        fStatus = bytesRead;
@@ -62,7 +61,7 @@ Header::Header(int fd, off_t block, uint32 blockSize)
 
        if (memcmp(fHeader.header, EFI_PARTITION_HEADER, sizeof(fHeader.header))
                || !_ValidateHeaderCRC()
-               || fHeader.AbsoluteBlock() != fBlock) {
+               || fHeader.AbsoluteBlock() != EFI_HEADER_LOCATION) {
                // TODO: check that partition counts are in valid bounds
                fStatus = B_BAD_DATA;
                return;
@@ -105,19 +104,21 @@ Header::Header(int fd, off_t block, uint32 blockSize)
 
 
 #ifndef _BOOT_MODE
-Header::Header(off_t block, off_t lastBlock, uint32 blockSize)
+Header::Header(uint64 lastBlock, uint32 blockSize)
        :
-       fBlock(block),
        fBlockSize(blockSize),
        fStatus(B_NO_INIT),
        fEntries(NULL)
 {
-       // initialize to an empty header
+       TRACE(("EFI::Header: Initialize GPT, block size %" B_PRIu32 "\n",
+               blockSize));
+
+       // Initialize to an empty header
        memcpy(fHeader.header, EFI_PARTITION_HEADER, sizeof(fHeader.header));
        fHeader.SetRevision(EFI_TABLE_REVISION);
        fHeader.SetHeaderSize(sizeof(fHeader));
        fHeader.SetHeaderCRC(0);
-       fHeader.SetAbsoluteBlock(fBlock);
+       fHeader.SetAbsoluteBlock(EFI_HEADER_LOCATION);
        fHeader.SetAlternateBlock(0); // TODO
        // TODO: set disk guid
        fHeader.SetEntriesBlock(EFI_PARTITION_ENTRIES_BLOCK);
@@ -142,9 +143,6 @@ Header::Header(off_t block, off_t lastBlock, uint32 
blockSize)
 #ifdef TRACE_EFI_GPT
        _Dump();
        _DumpPartitions();
-       dprintf("GPT: HERE I AM!\n");
-#else
-       dprintf("GPT: Nope!\n");
 #endif
 
        fStatus = B_OK;
@@ -182,13 +180,27 @@ Header::WriteEntry(int fd, uint32 entryIndex)
        // TODO: write mirror at the end
 
        // Update header, too -- the entries CRC changed
-       return Write(fd);
+       return _WriteHeader(fd);
 }
 
 
 status_t
 Header::Write(int fd)
 {
+       status_t status = _Write(fd, fHeader.EntriesBlock() * fBlockSize, 
fEntries,
+               _EntryArraySize());
+       if (status != B_OK)
+               return status;
+
+       // TODO: write mirror at the end
+
+       return _WriteHeader(fd);
+}
+
+
+status_t
+Header::_WriteHeader(int fd)
+{
        _UpdateCRC();
 
        status_t status = _Write(fd, fHeader.AbsoluteBlock() * fBlockSize,
@@ -200,7 +212,6 @@ Header::Write(int fd)
 
        return B_OK;
 }
-#endif // !_BOOT_MODE
 
 
 status_t
@@ -223,6 +234,7 @@ Header::_UpdateCRC()
        fHeader.SetHeaderCRC(0);
        fHeader.SetHeaderCRC(crc32((uint8*)&fHeader, sizeof(efi_table_header)));
 }
+#endif // !_BOOT_MODE
 
 
 bool
@@ -233,7 +245,6 @@ Header::_ValidateHeaderCRC()
 
        bool matches = originalCRC == crc32((const uint8*)&fHeader,
                sizeof(efi_table_header));
-dprintf("GPT: MATCHES %d!\n", matches);
 
        fHeader.SetHeaderCRC(originalCRC);
        return matches;
@@ -266,7 +277,7 @@ void
 Header::_Dump()
 {
        dprintf("EFI header: %.8s\n", fHeader.header);
-       dprintf("EFI revision: %ld\n", fHeader.Revision());
+       dprintf("EFI revision: %" B_PRIx32 "\n", fHeader.Revision());
        dprintf("header size: %ld\n", fHeader.HeaderSize());
        dprintf("header CRC: %ld\n", fHeader.HeaderCRC());
        dprintf("absolute block: %Ld\n", fHeader.AbsoluteBlock());
diff --git a/src/add-ons/kernel/partitioning_systems/gpt/Header.h 
b/src/add-ons/kernel/partitioning_systems/gpt/Header.h
index d87dd12..486a5e2 100644
--- a/src/add-ons/kernel/partitioning_systems/gpt/Header.h
+++ b/src/add-ons/kernel/partitioning_systems/gpt/Header.h
@@ -16,17 +16,15 @@ namespace EFI {
 
 class Header {
 public:
-                                                               Header(int fd, 
off_t block, uint32 blockSize);
+                                                               Header(int fd, 
uint64 lastBlock,
+                                                                       uint32 
blockSize);
 #ifndef _BOOT_MODE
                                                                // constructor 
for empty header
-                                                               Header(off_t 
block, off_t lastBlock,
-                                                                       uint32 
blockSize);
+                                                               Header(uint64 
lastBlock, uint32 blockSize);
 #endif
                                                                ~Header();
 
                        status_t                        InitCheck() const;
-                       bool                            IsPrimary() const
-                                                                       { 
return fBlock == EFI_HEADER_LOCATION; }
 
                        uint64                          FirstUsableBlock() const
                                                                        { 
return fHeader.FirstUsableBlock(); }
@@ -49,9 +47,13 @@ private:
                        void                            _Dump();
                        void                            _DumpPartitions();
 
+#ifndef _BOOT_MODE
+                       status_t                        _WriteHeader(int fd);
                        status_t                        _Write(int fd, off_t 
offset, const void* data,
                                                                        size_t 
size) const;
                        void                            _UpdateCRC();
+#endif
+
                        bool                            _ValidateHeaderCRC();
                        bool                            _ValidateEntriesCRC() 
const;
                        size_t                          _EntryArraySize() const
@@ -59,7 +61,6 @@ private:
                                                                                
* fHeader.EntryCount(); }
 
 private:
-                       uint64                          fBlock;
                        uint32                          fBlockSize;
                        status_t                        fStatus;
                        efi_table_header        fHeader;
diff --git a/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp 
b/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp
index 12e88c7..3f76591 100644
--- a/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp
+++ b/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp
@@ -71,10 +71,10 @@ efi_gpt_std_ops(int32 op, ...)
 static float
 efi_gpt_identify_partition(int fd, partition_data *partition, void **_cookie)
 {
-       EFI::Header *header = new (std::nothrow) EFI::Header(fd,
-               EFI_HEADER_LOCATION, partition->block_size);
+       EFI::Header* header = new (std::nothrow) EFI::Header(fd,
+               partition->size / partition->block_size, partition->block_size);
        status_t status = header->InitCheck();
-       if (status < B_OK) {
+       if (status != B_OK) {
                delete header;
                return -1;
        }
@@ -323,7 +323,8 @@ efi_gpt_validate_set_content_name(partition_data 
*partition, char *name)
 static bool
 efi_gpt_validate_set_type(partition_data *partition, const char *type)
 {
-       return guid_for_partition_type(type) != NULL;
+       guid_t typeGUID;
+       return get_guid_for_partition_type(type, typeGUID);
 }
 
 
@@ -352,7 +353,7 @@ efi_gpt_validate_create_child(partition_data *partition, 
off_t *start,
                        & B_DISK_SYSTEM_SUPPORTS_CREATING_CHILD) == 0)
                return false;
 
-       if (guid_for_partition_type(type) == NULL)
+       if (!efi_gpt_validate_set_type(partition, type))
                return false;
 
        EFI::Header *header = (EFI::Header *)partition->content_cookie;
@@ -396,7 +397,7 @@ efi_gpt_validate_create_child(partition_data *partition, 
off_t *start,
                        *size = other->offset - *start;
        }
 
-       *start = block_align(partition, *size, true);
+       *start = block_align(partition, *start, true);
        *size = block_align(partition, *size, false);
 
        // TODO: support parameters
@@ -663,14 +664,14 @@ efi_gpt_set_type(int fd, partition_id partitionID, const 
char *type,
        if (entryIndex >= header->EntryCount())
                return B_BAD_VALUE;
 
-       const static_guid *newType = guid_for_partition_type(type);
-       if (newType == NULL)
+       guid_t typeGUID;
+       if (!get_guid_for_partition_type(type, typeGUID))
                return B_BAD_VALUE;
 
        update_disk_device_job_progress(job, 0.0);
 
        efi_partition_entry &entry = header->EntryAt(entryIndex);
-       memcpy(&entry.partition_type, newType, sizeof(entry.partition_type));
+       entry.partition_type = typeGUID;
 
        status_t result = header->WriteEntry(fd, entryIndex);
        if (result != B_OK)
@@ -697,8 +698,8 @@ efi_gpt_initialize(int fd, partition_id partitionID, const 
char *name,
 
        update_disk_device_job_progress(job, 0.0);
 
-       EFI::Header header(EFI_HEADER_LOCATION,
-               partitionSize / partition->block_size, partition->block_size);
+       EFI::Header header(partitionSize / partition->block_size,
+               partition->block_size);
        status_t result = header.InitCheck();
        if (result != B_OK)
                return result;
@@ -745,8 +746,8 @@ efi_gpt_create_child(int fd, partition_id partitionID, 
off_t offset,
                        &validatedSize, type, name, parameters, (int32 
*)&entryIndex))
                return B_BAD_VALUE;
 
-       const static_guid *newType = guid_for_partition_type(type);
-       if (newType == NULL)
+       guid_t typeGUID;
+       if (!get_guid_for_partition_type(type, typeGUID))
                return B_BAD_VALUE;
 
        update_disk_device_job_progress(job, 0.0);
@@ -757,7 +758,8 @@ efi_gpt_create_child(int fd, partition_id partitionID, 
off_t offset,
                return B_ERROR;
 
        efi_partition_entry &entry = header->EntryAt(entryIndex);
-       memcpy(&entry.partition_type, newType, sizeof(entry.partition_type));
+       entry.partition_type = typeGUID;
+       // TODO: set unique partition ID
        to_ucs2(name, strlen(name), entry.name, EFI_PARTITION_NAME_LENGTH);
        entry.SetStartBlock((validatedOffset - partition->offset)
                / partition->block_size);
@@ -844,7 +846,7 @@ partition_module_info gEFIPartitionModule = {
                0,
                efi_gpt_std_ops
        },
-       "efi",                                                                  
// short_name
+       "gpt",                                                                  
// short_name
        EFI_PARTITION_NAME,                                             // 
pretty_name
        0                                                                       
        // flags
        | B_DISK_SYSTEM_SUPPORTS_INITIALIZING
diff --git a/src/add-ons/kernel/partitioning_systems/gpt/gpt_known_guids.h 
b/src/add-ons/kernel/partitioning_systems/gpt/gpt_known_guids.h
index 1fb1cef..249f639 100644
--- a/src/add-ons/kernel/partitioning_systems/gpt/gpt_known_guids.h
+++ b/src/add-ons/kernel/partitioning_systems/gpt/gpt_known_guids.h
@@ -22,24 +22,39 @@ struct static_guid {
        uint16  data3;
        uint64  data4;
 
-       inline bool operator==(const guid &other) const;
+       inline bool operator==(const guid& other) const;
+       inline operator guid_t() const;
 } _PACKED;
 
 
 inline bool
-static_guid::operator==(const guid_t &other) const
+static_guid::operator==(const guid_t& other) const
 {
        return B_HOST_TO_LENDIAN_INT32(data1) == other.data1
                && B_HOST_TO_LENDIAN_INT16(data2) == other.data2
                && B_HOST_TO_LENDIAN_INT16(data3) == other.data3
-               && B_HOST_TO_BENDIAN_INT64(*(uint64 *)&data4) == *(uint64 
*)other.data4;
+               && B_HOST_TO_BENDIAN_INT64(*(uint64*)&data4) == 
*(uint64*)other.data4;
                        // the last 8 bytes are in big-endian order
 }
 
 
+inline
+static_guid::operator guid_t() const
+{
+       guid_t guid;
+       guid.data1 = B_HOST_TO_LENDIAN_INT32(data1);
+       guid.data2 = B_HOST_TO_LENDIAN_INT16(data2);
+       guid.data3 = B_HOST_TO_LENDIAN_INT16(data3);
+       uint64 last = B_HOST_TO_BENDIAN_INT64(*(uint64*)&data4);
+       memcpy(guid.data4, &last, sizeof(uint64));
+
+       return guid;
+}
+
+
 const static struct type_map {
        static_guid     guid;
-       const char      *type;
+       const char*     type;
 } kTypeMap[] = {
        {{0xC12A7328, 0xF81F, 0x11D2, 0xBA4B00A0C93EC93BLL}, "EFI System Data"},
        {{0x21686148, 0x6449, 0x6E6F, 0x744E656564454649LL}, "BIOS Boot Data"},
diff --git a/src/add-ons/kernel/partitioning_systems/gpt/utility.cpp 
b/src/add-ons/kernel/partitioning_systems/gpt/utility.cpp
index c43718d..4564377 100644
--- a/src/add-ons/kernel/partitioning_systems/gpt/utility.cpp
+++ b/src/add-ons/kernel/partitioning_systems/gpt/utility.cpp
@@ -21,7 +21,7 @@ const guid_t kEmptyGUID = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}};
 
 
 static void
-put_utf8_byte(char *&to, size_t &left, char c)
+put_utf8_byte(char*& to, size_t& left, char c)
 {
        if (left <= 1)
                return;
@@ -35,7 +35,7 @@ put_utf8_byte(char *&to, size_t &left, char c)
 
 
 void
-to_utf8(const uint16 *from, size_t maxFromLength, char *to, size_t toSize)
+to_utf8(const uint16* from, size_t maxFromLength, char* to, size_t toSize)
 {
        for (uint32 i = 0; i < maxFromLength; i++) {
                uint16 c = B_LENDIAN_TO_HOST_INT16(from[i]);
@@ -66,10 +66,10 @@ to_utf8(const uint16 *from, size_t maxFromLength, char *to, 
size_t toSize)
 
 #ifndef _BOOT_MODE
 void
-to_ucs2(const char *from, size_t fromLength, uint16 *to, size_t maxToLength)
+to_ucs2(const char* from, size_t fromLength, uint16* to, size_t maxToLength)
 {
        size_t index = 0;
-       while (from[0] && index < maxToLength) {
+       while (from[0] != '\0' && index < maxToLength) {
                // TODO: handle characters that are not representable in UCS-2 
better
                uint32 code = UTF8ToCharCode(&from);
                if (code < 0x10000)
@@ -82,8 +82,8 @@ to_ucs2(const char *from, size_t fromLength, uint16 *to, 
size_t maxToLength)
 #endif // !_BOOT_MODE
 
 
-const char *
-get_partition_type(const guid_t &guid)
+const char*
+get_partition_type(const guid_t& guid)
 {
        for (uint32 i = 0; i < sizeof(kTypeMap) / sizeof(kTypeMap[0]); i++) {
                if (kTypeMap[i].guid == guid)
@@ -95,14 +95,16 @@ get_partition_type(const guid_t &guid)
 
 
 #ifndef _BOOT_MODE
-const static_guid *
-guid_for_partition_type(const char *type)
+bool
+get_guid_for_partition_type(const char* type, guid_t& guid)
 {
        for (uint32 i = 0; i < sizeof(kTypeMap) / sizeof(kTypeMap[0]); i++) {
-               if (strcmp(kTypeMap[i].type, type) == 0)
-                       return &kTypeMap[i].guid;
+               if (strcmp(kTypeMap[i].type, type) == 0) {
+                       guid = kTypeMap[i].guid;
+                       return true;
+               }
        }
 
-       return NULL;
+       return false;
 }
 #endif // !_BOOT_MODE
diff --git a/src/add-ons/kernel/partitioning_systems/gpt/utility.h 
b/src/add-ons/kernel/partitioning_systems/gpt/utility.h
index 17f9fe0..c89db23 100644
--- a/src/add-ons/kernel/partitioning_systems/gpt/utility.h
+++ b/src/add-ons/kernel/partitioning_systems/gpt/utility.h
@@ -24,7 +24,7 @@ const char* get_partition_type(const guid_t& guid);
 #ifndef _BOOT_MODE
 void to_ucs2(const char* from, size_t fromLength, uint16* to,
        size_t maxToLength);
-const static_guid* guid_for_partition_type(const char* type);
+bool get_guid_for_partition_type(const char* type, guid_t& guid);
 #endif // !_BOOT_MODE
 
 

############################################################################

Revision:    hrev45207
Commit:      90308ec327dce4e1894b4507f9197ba92512926c
URL:         http://cgit.haiku-os.org/haiku/commit/?id=90308ec
Author:      Axel Dörfler <axeld@xxxxxxxxxxxxxxxx>
Date:        Sat Jan 26 20:03:50 2013 UTC

gpt: Pointer style changed to preferred.

----------------------------------------------------------------------------

diff --git a/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp 
b/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp
index 3f76591..248de68 100644
--- a/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp
+++ b/src/add-ons/kernel/partitioning_systems/gpt/efi_gpt.cpp
@@ -40,7 +40,7 @@
 
 #ifndef _BOOT_MODE
 static off_t
-block_align(partition_data *partition, off_t offset, bool upwards)
+block_align(partition_data* partition, off_t offset, bool upwards)
 {
        if (upwards) {
                return ((offset + partition->block_size - 1) / 
partition->block_size)
@@ -69,7 +69,7 @@ efi_gpt_std_ops(int32 op, ...)
 
 
 static float
-efi_gpt_identify_partition(int fd, partition_data *partition, void **_cookie)
+efi_gpt_identify_partition(int fd, partition_data* partition, void** _cookie)
 {
        EFI::Header* header = new (std::nothrow) EFI::Header(fd,
                partition->size / partition->block_size, partition->block_size);
@@ -87,10 +87,10 @@ efi_gpt_identify_partition(int fd, partition_data 
*partition, void **_cookie)
 
 
 static status_t
-efi_gpt_scan_partition(int fd, partition_data *partition, void *_cookie)
+efi_gpt_scan_partition(int fd, partition_data* partition, void* _cookie)
 {
        TRACE(("efi_gpt_scan_partition(cookie = %p)\n", _cookie));
-       EFI::Header *header = (EFI::Header *)_cookie;
+       EFI::Header* header = (EFI::Header*)_cookie;
 
        partition->status = B_PARTITION_VALID;
        partition->flags |= B_PARTITION_PARTITIONING_SYSTEM;
@@ -102,7 +102,7 @@ efi_gpt_scan_partition(int fd, partition_data *partition, 
void *_cookie)
        uint32 index = 0;
 
        for (uint32 i = 0; i < header->EntryCount(); i++) {
-               const efi_partition_entry &entry = header->EntryAt(i);
+               const efi_partition_entry& entry = header->EntryAt(i);
 
                if (entry.partition_type == kEmptyGUID)
                        continue;
@@ -115,7 +115,7 @@ efi_gpt_scan_partition(int fd, partition_data *partition, 
void *_cookie)
                        continue;
                }
 
-               partition_data *child = create_child_partition(partition->id, 
index++,
+               partition_data* child = create_child_partition(partition->id, 
index++,
                        partition->offset + entry.StartBlock() * 
partition->block_size,
                        entry.BlockCount() * partition->block_size, -1);
                if (child == NULL) {
@@ -128,7 +128,7 @@ efi_gpt_scan_partition(int fd, partition_data *partition, 
void *_cookie)
                child->name = strdup(name);
                child->type = strdup(get_partition_type(entry.partition_type));
                child->block_size = partition->block_size;
-               child->cookie = (void *)i;
+               child->cookie = (void*)i;
        }
 
        return B_OK;
@@ -136,22 +136,22 @@ efi_gpt_scan_partition(int fd, partition_data *partition, 
void *_cookie)
 
 
 static void
-efi_gpt_free_identify_partition_cookie(partition_data *partition, void 
*_cookie)
+efi_gpt_free_identify_partition_cookie(partition_data* partition, void* 
_cookie)
 {
        // Cookie is freed in efi_gpt_free_partition_content_cookie().
 }
 
 
 static void
-efi_gpt_free_partition_content_cookie(partition_data *partition)
+efi_gpt_free_partition_content_cookie(partition_data* partition)
 {
-       delete (EFI::Header *)partition->content_cookie;
+       delete (EFI::Header*)partition->content_cookie;
 }
 
 
 #ifndef _BOOT_MODE
 static uint32
-efi_gpt_get_supported_operations(partition_data *partition, uint32 mask)
+efi_gpt_get_supported_operations(partition_data* partition, uint32 mask)
 {
        uint32 flags = B_DISK_SYSTEM_SUPPORTS_INITIALIZING
                | B_DISK_SYSTEM_SUPPORTS_SETTING_CONTENT_NAME
@@ -166,8 +166,8 @@ efi_gpt_get_supported_operations(partition_data *partition, 
uint32 mask)
 
 
 static uint32
-efi_gpt_get_supported_child_operations(partition_data *partition,
-       partition_data *child, uint32 mask)
+efi_gpt_get_supported_child_operations(partition_data* partition,
+       partition_data* child, uint32 mask)
 {
        return B_DISK_SYSTEM_SUPPORTS_MOVING_CHILD
                | B_DISK_SYSTEM_SUPPORTS_RESIZING_CHILD
@@ -177,7 +177,7 @@ efi_gpt_get_supported_child_operations(partition_data 
*partition,
 
 
 static bool
-efi_gpt_is_sub_system_for(partition_data *partition)
+efi_gpt_is_sub_system_for(partition_data* partition)
 {
        // a GUID Partition Table doesn't usually live inside another partition
        return false;
@@ -185,7 +185,7 @@ efi_gpt_is_sub_system_for(partition_data *partition)
 
 
 static bool
-efi_gpt_validate_resize(partition_data *partition, off_t *size)
+efi_gpt_validate_resize(partition_data* partition, off_t* size)
 {
        off_t newSize = *size;
        if (newSize == partition->size)
@@ -205,7 +205,7 @@ efi_gpt_validate_resize(partition_data *partition, off_t 
*size)
        // shrinking, only so that no child would be truncated
        off_t newEnd = partition->offset + newSize;
        for (int32 i = 0; i < partition->child_count; i++) {
-               partition_data *child = get_child_partition(partition->id, i);
+               partition_data* child = get_child_partition(partition->id, i);
                if (child == NULL)
                        continue;
 
@@ -220,8 +220,8 @@ efi_gpt_validate_resize(partition_data *partition, off_t 
*size)
 
 
 static bool
-efi_gpt_validate_resize_child(partition_data *partition, partition_data *child,
-       off_t *size)
+efi_gpt_validate_resize_child(partition_data* partition, partition_data* child,
+       off_t* size)
 {
        off_t newSize = *size;
        if (newSize == child->size)
@@ -244,7 +244,7 @@ efi_gpt_validate_resize_child(partition_data *partition, 
partition_data *child,
        // make sure that the child doesn't overlap any sibling partitions
        off_t newEnd = child->offset + newSize;
        for (int32 i = 0; i < partition->child_count; i++) {
-               partition_data *other = get_child_partition(partition->id, i);
+               partition_data* other = get_child_partition(partition->id, i);
                if (other == NULL || other->id == child->id
                        || other->offset < child->offset)
                        continue;
@@ -259,7 +259,7 @@ efi_gpt_validate_resize_child(partition_data *partition, 
partition_data *child,
 
 
 static bool
-efi_gpt_validate_move(partition_data *partition, off_t *start)
+efi_gpt_validate_move(partition_data* partition, off_t* start)
 {
        // nothing to do
        return true;
@@ -267,8 +267,8 @@ efi_gpt_validate_move(partition_data *partition, off_t 
*start)
 
 
 static bool
-efi_gpt_validate_move_child(partition_data *partition, partition_data *child,
-       off_t *start)
+efi_gpt_validate_move_child(partition_data* partition, partition_data* child,
+       off_t* start)
 {
        off_t newStart = *start;
        if (newStart < 0)
@@ -280,7 +280,7 @@ efi_gpt_validate_move_child(partition_data *partition, 
partition_data *child,
        newStart = block_align(partition, newStart, false);
        if (newStart > child->offset) {
                for (int32 i = 0; i < partition->child_count; i++) {
-                       partition_data *other = 
get_child_partition(partition->id, i);
+                       partition_data* other = 
get_child_partition(partition->id, i);
                        if (other == NULL || other->id == child->id
                                || other->offset < child->offset)
                                continue;
@@ -292,7 +292,7 @@ efi_gpt_validate_move_child(partition_data *partition, 
partition_data *child,
                newStart = block_align(partition, newStart, false);
        } else {
                for (int32 i = 0; i < partition->child_count; i++) {
-                       partition_data *other = 
get_child_partition(partition->id, i);
+                       partition_data* other = 
get_child_partition(partition->id, i);
                        if (other == NULL || other->id == child->id
                                || other->offset > child->offset)
                                continue;
@@ -310,7 +310,7 @@ efi_gpt_validate_move_child(partition_data *partition, 
partition_data *child,
 
 
 static bool
-efi_gpt_validate_set_content_name(partition_data *partition, char *name)
+efi_gpt_validate_set_content_name(partition_data* partition, char* name)
 {
        // TODO: should validate that the utf-8 -> ucs-2 is valid
        // TODO: should count actual utf-8 chars
@@ -321,7 +321,7 @@ efi_gpt_validate_set_content_name(partition_data 
*partition, char *name)
 
 
 static bool
-efi_gpt_validate_set_type(partition_data *partition, const char *type)
+efi_gpt_validate_set_type(partition_data* partition, const char* type)
 {
        guid_t typeGUID;
        return get_guid_for_partition_type(type, typeGUID);
@@ -329,8 +329,8 @@ efi_gpt_validate_set_type(partition_data *partition, const 
char *type)
 
 
 static bool
-efi_gpt_validate_initialize(partition_data *partition, char *name,
-       const char *parameters)
+efi_gpt_validate_initialize(partition_data* partition, char* name,
+       const char* parameters)
 {
        if ((efi_gpt_get_supported_operations(partition, ~0)
                & B_DISK_SYSTEM_SUPPORTS_INITIALIZING) == 0)
@@ -345,9 +345,9 @@ efi_gpt_validate_initialize(partition_data *partition, char 
*name,
 
 
 static bool
-efi_gpt_validate_create_child(partition_data *partition, off_t *start,
-       off_t *size, const char *type, const char *name, const char *parameters,
-       int32 *index)
+efi_gpt_validate_create_child(partition_data* partition, off_t* start,
+       off_t* size, const char* type, const char* name, const char* parameters,
+       int32* index)
 {
        if ((efi_gpt_get_supported_operations(partition, ~0)
                        & B_DISK_SYSTEM_SUPPORTS_CREATING_CHILD) == 0)
@@ -356,10 +356,10 @@ efi_gpt_validate_create_child(partition_data *partition, 
off_t *start,
        if (!efi_gpt_validate_set_type(partition, type))
                return false;
 
-       EFI::Header *header = (EFI::Header *)partition->content_cookie;
+       EFI::Header* header = (EFI::Header*)partition->content_cookie;
        int32 entryIndex = -1;
        for (uint32 i = 0; i < header->EntryCount(); i++) {
-               const efi_partition_entry &entry = header->EntryAt(i);
+               const efi_partition_entry& entry = header->EntryAt(i);
                if (entry.partition_type == kEmptyGUID) {
                        entryIndex = i;
                        break;
@@ -386,7 +386,7 @@ efi_gpt_validate_create_child(partition_data *partition, 
off_t *start,
 
        // ensure that we don't overlap any siblings
        for (int32 i = 0; i < partition->child_count; i++) {
-               partition_data *other = get_child_partition(partition->id, i);
+               partition_data* other = get_child_partition(partition->id, i);
                if (other == NULL)
                        continue;
 
@@ -406,8 +406,8 @@ efi_gpt_validate_create_child(partition_data *partition, 
off_t *start,
 
 
 static status_t
-efi_gpt_get_partitionable_spaces(partition_data *partition,
-       partitionable_space_data *buffer, int32 count, int32 *actualCount)
+efi_gpt_get_partitionable_spaces(partition_data* partition,
+       partitionable_space_data* buffer, int32 count, int32* actualCount)
 {
        // TODO: implement
        return B_ERROR;
@@ -415,8 +415,8 @@ efi_gpt_get_partitionable_spaces(partition_data *partition,
 
 
 static status_t
-efi_gpt_get_next_supported_type(partition_data *partition, int32 *cookie,
-       char *type)
+efi_gpt_get_next_supported_type(partition_data* partition, int32* cookie,
+       char* type)
 {
        // TODO: implement
        return B_ERROR;
@@ -424,7 +424,7 @@ efi_gpt_get_next_supported_type(partition_data *partition, 
int32 *cookie,
 
 
 static status_t
-efi_gpt_shadow_changed(partition_data *partition, partition_data *child,
+efi_gpt_shadow_changed(partition_data* partition, partition_data* child,
        uint32 operation)
 {
        // TODO: implement
@@ -450,7 +450,7 @@ efi_gpt_resize(int fd, partition_id partitionID, off_t 
size, disk_job_id job)
        if (!locker.IsLocked())
                return B_ERROR;
 
-       partition_data *partition = get_partition(partitionID);
+       partition_data* partition = get_partition(partitionID);
        if (partition == NULL)
                return B_BAD_VALUE;
 
@@ -480,15 +480,15 @@ efi_gpt_resize_child(int fd, partition_id partitionID, 
off_t size,
        if (!locker.IsLocked())
                return B_ERROR;
 
-       partition_data *child = get_partition(partitionID);
+       partition_data* child = get_partition(partitionID);
        if (child == NULL)
                return B_BAD_VALUE;
 
-       partition_data *partition = get_parent_partition(partitionID);
+       partition_data* partition = get_parent_partition(partitionID);
        if (partition == NULL)
                return B_BAD_VALUE;
 
-       EFI::Header *header = (EFI::Header *)partition->content_cookie;
+       EFI::Header* header = (EFI::Header*)partition->content_cookie;
        if (header == NULL)
                return B_BAD_VALUE;
 
@@ -505,7 +505,7 @@ efi_gpt_resize_child(int fd, partition_id partitionID, 
off_t size,
 
        update_disk_device_job_progress(job, 0.0);
 
-       efi_partition_entry &entry = header->EntryAt(entryIndex);
+       efi_partition_entry& entry = header->EntryAt(entryIndex);
        entry.SetBlockCount(validatedSize / partition->block_size);
 
        status_t result = header->WriteEntry(fd, entryIndex);
@@ -541,15 +541,15 @@ efi_gpt_move_child(int fd, partition_id partitionID, 
partition_id childID,
        if (!locker.IsLocked())
                return B_ERROR;
 
-       partition_data *partition = get_partition(partitionID);
+       partition_data* partition = get_partition(partitionID);
        if (partition == NULL)
                return B_BAD_VALUE;
 
-       partition_data *child = get_partition(childID);
+       partition_data* child = get_partition(childID);
        if (child == NULL)
                return B_BAD_VALUE;
 
-       EFI::Header *header = (EFI::Header *)partition->content_cookie;
+       EFI::Header* header = (EFI::Header*)partition->content_cookie;
        if (header == NULL)
                return B_BAD_VALUE;
 
@@ -570,7 +570,7 @@ efi_gpt_move_child(int fd, partition_id partitionID, 
partition_id childID,
 
        update_disk_device_job_progress(job, 0.0);
 
-       efi_partition_entry &entry = header->EntryAt(entryIndex);
+       efi_partition_entry& entry = header->EntryAt(entryIndex);
        uint64 blockCount = entry.BlockCount();
        entry.SetStartBlock((validatedOffset - partition->offset)
                / partition->block_size);
@@ -592,7 +592,7 @@ efi_gpt_move_child(int fd, partition_id partitionID, 
partition_id childID,
 
 
 static status_t
-efi_gpt_set_content_name(int fd, partition_id partitionID, const char *name,
+efi_gpt_set_content_name(int fd, partition_id partitionID, const char* name,
        disk_job_id job)
 {
        if (fd < 0)
@@ -602,15 +602,15 @@ efi_gpt_set_content_name(int fd, partition_id 
partitionID, const char *name,
        if (!locker.IsLocked())
                return B_ERROR;
 
-       partition_data *child = get_partition(partitionID);
+       partition_data* child = get_partition(partitionID);
        if (child == NULL)
                return B_BAD_VALUE;
 
-       partition_data *partition = get_parent_partition(partitionID);
+       partition_data* partition = get_parent_partition(partitionID);
        if (partition == NULL)
                return B_BAD_VALUE;
 
-       EFI::Header *header = (EFI::Header *)partition->content_cookie;
+       EFI::Header* header = (EFI::Header*)partition->content_cookie;
        if (header == NULL)
                return B_BAD_VALUE;
 
@@ -620,7 +620,7 @@ efi_gpt_set_content_name(int fd, partition_id partitionID, 
const char *name,
 
        update_disk_device_job_progress(job, 0.0);
 
-       efi_partition_entry &entry = header->EntryAt(entryIndex);
+       efi_partition_entry& entry = header->EntryAt(entryIndex);
        to_ucs2(name, strlen(name), entry.name, EFI_PARTITION_NAME_LENGTH);
 
        status_t result = header->WriteEntry(fd, entryIndex);
@@ -638,7 +638,7 @@ efi_gpt_set_content_name(int fd, partition_id partitionID, 
const char *name,
 
 
 static status_t
-efi_gpt_set_type(int fd, partition_id partitionID, const char *type,
+efi_gpt_set_type(int fd, partition_id partitionID, const char* type,
        disk_job_id job)
 {
        if (fd < 0)
@@ -648,15 +648,15 @@ efi_gpt_set_type(int fd, partition_id partitionID, const 
char *type,
        if (!locker.IsLocked())
                return B_ERROR;
 
-       partition_data *child = get_partition(partitionID);
+       partition_data* child = get_partition(partitionID);
        if (child == NULL)
                return B_BAD_VALUE;
 
-       partition_data *partition = get_parent_partition(partitionID);
+       partition_data* partition = get_parent_partition(partitionID);
        if (partition == NULL)
                return B_BAD_VALUE;
 
-       EFI::Header *header = (EFI::Header *)partition->content_cookie;
+       EFI::Header* header = (EFI::Header*)partition->content_cookie;
        if (header == NULL)
                return B_BAD_VALUE;
 
@@ -670,7 +670,7 @@ efi_gpt_set_type(int fd, partition_id partitionID, const 
char *type,
 
        update_disk_device_job_progress(job, 0.0);
 
-       efi_partition_entry &entry = header->EntryAt(entryIndex);
+       efi_partition_entry& entry = header->EntryAt(entryIndex);
        entry.partition_type = typeGUID;
 
        status_t result = header->WriteEntry(fd, entryIndex);
@@ -686,13 +686,13 @@ efi_gpt_set_type(int fd, partition_id partitionID, const 
char *type,
 
 
 static status_t
-efi_gpt_initialize(int fd, partition_id partitionID, const char *name,
-       const char *parameters, off_t partitionSize, disk_job_id job)
+efi_gpt_initialize(int fd, partition_id partitionID, const char* name,
+       const char* parameters, off_t partitionSize, disk_job_id job)
 {
        if (fd < 0)
                return B_ERROR;
 
-       partition_data *partition = get_partition(partitionID);
+       partition_data* partition = get_partition(partitionID);
        if (partition == NULL)
                return B_BAD_VALUE;
 
@@ -720,8 +720,8 @@ efi_gpt_initialize(int fd, partition_id partitionID, const 
char *name,
 
 static status_t
 efi_gpt_create_child(int fd, partition_id partitionID, off_t offset,
-       off_t size, const char *type, const char *name, const char *parameters,
-       disk_job_id job, partition_id *childID)
+       off_t size, const char* type, const char* name, const char* parameters,
+       disk_job_id job, partition_id* childID)
 {
        if (fd < 0)
                return B_ERROR;
@@ -730,11 +730,11 @@ efi_gpt_create_child(int fd, partition_id partitionID, 
off_t offset,
        if (!locker.IsLocked())
                return B_ERROR;
 
-       partition_data *partition = get_partition(partitionID);
+       partition_data* partition = get_partition(partitionID);
        if (partition == NULL)
                return B_BAD_VALUE;
 
-       EFI::Header *header = (EFI::Header *)partition->content_cookie;
+       EFI::Header* header = (EFI::Header*)partition->content_cookie;
        if (header == NULL)
                return B_BAD_VALUE;
 
@@ -743,7 +743,7 @@ efi_gpt_create_child(int fd, partition_id partitionID, 
off_t offset,
        uint32 entryIndex = 0;
 
        if (!efi_gpt_validate_create_child(partition, &validatedOffset,
-                       &validatedSize, type, name, parameters, (int32 
*)&entryIndex))
+                       &validatedSize, type, name, parameters, 
(int32*)&entryIndex))
                return B_BAD_VALUE;
 
        guid_t typeGUID;
@@ -752,12 +752,12 @@ efi_gpt_create_child(int fd, partition_id partitionID, 
off_t offset,
 
        update_disk_device_job_progress(job, 0.0);
 
-       partition_data *child = create_child_partition(partition->id, 
entryIndex,
+       partition_data* child = create_child_partition(partition->id, 
entryIndex,
                validatedOffset, validatedSize, *childID);
        if (child == NULL)
                return B_ERROR;
 
-       efi_partition_entry &entry = header->EntryAt(entryIndex);
+       efi_partition_entry& entry = header->EntryAt(entryIndex);
        entry.partition_type = typeGUID;
        // TODO: set unique partition ID
        to_ucs2(name, strlen(name), entry.name, EFI_PARTITION_NAME_LENGTH);
@@ -777,7 +777,7 @@ efi_gpt_create_child(int fd, partition_id partitionID, 
off_t offset,
        child->name = strdup(name);
        child->type = strdup(type);
        child->parameters = strdup(parameters);
-       child->cookie = (void *)entryIndex;
+       child->cookie = (void*)entryIndex;
 
        if (child->type == NULL || child->parameters == NULL) {
                delete_partition(child->id);
@@ -801,15 +801,15 @@ efi_gpt_delete_child(int fd, partition_id partitionID, 
partition_id childID,
        if (!locker.IsLocked())
                return B_ERROR;
 
-       partition_data *partition = get_partition(partitionID);
+       partition_data* partition = get_partition(partitionID);
        if (partition == NULL)
                return B_BAD_VALUE;
 
-       partition_data *child = get_partition(childID);
+       partition_data* child = get_partition(childID);
        if (child == NULL)
                return B_BAD_VALUE;
 
-       EFI::Header *header = (EFI::Header *)partition->content_cookie;
+       EFI::Header* header = (EFI::Header*)partition->content_cookie;
        if (header == NULL)
                return B_BAD_VALUE;
 
@@ -822,7 +822,7 @@ efi_gpt_delete_child(int fd, partition_id partitionID, 
partition_id childID,
        if (!delete_partition(childID))
                return B_ERROR;
 
-       efi_partition_entry &entry = header->EntryAt(entryIndex);
+       efi_partition_entry& entry = header->EntryAt(entryIndex);
        entry.partition_type = kEmptyGUID;
 
        status_t result = header->WriteEntry(fd, entryIndex);
@@ -914,7 +914,7 @@ partition_module_info gEFIPartitionModule = {
 };
 
 #ifndef _BOOT_MODE
-partition_module_info *modules[] = {
+partition_module_info* modules[] = {
        &sEFIPartitionModule,
        NULL
 };


Other related posts:

  • » [haiku-commits] haiku: hrev45207 - src/add-ons/kernel/partitioning_systems/gpt - axeld