Index: branches/rewrite/i386/modules/Disk/GUIDPartition.cpp =================================================================== --- branches/rewrite/i386/modules/Disk/GUIDPartition.cpp (revision 1089) +++ branches/rewrite/i386/modules/Disk/GUIDPartition.cpp (revision 1090) @@ -12,9 +12,60 @@ mBeginSector = 0; mPartitionNumber = partitionNumber; mNumPartitions = 0; + + if(mDisk) + { + // read in lba1, this contains the partition map if it's GPT + mDisk->Read(1, 1, mLBABUffer); + mGPTHeader = (gpt_hdr*)mLBABUffer; + } + else + { + mGPTHeader = NULL; + } + + if(isGPTDisk()) + { + mNumPartitions = mGPTHeader->hdr_entries; + } + + mGPTHeader = NULL; + + if(mPartitionNumber >= 0 && mPartitionNumber < mNumPartitions) + { + // read in partition entry. + mDisk->Read(2 + mPartitionNumber, 1, mLBABUffer); + + mGPTEntry = (gpt_ent*) mLBABUffer; + + mNumSectors = mGPTEntry->ent_lba_end - mGPTEntry->ent_lba_start; + mBeginSector = mGPTEntry->ent_lba_start; + //mUUID = mGPTEntry->ent_uuid; + } } GUIDPartition::~GUIDPartition() { -} \ No newline at end of file +} + + +bool GUIDPartition::isGPTDisk() +{ + static bool status = false; + + if(status) return status; + + if(!mGPTHeader) return false; + + if(mGPTHeader->hdr_sig[0] == 'E' && + mGPTHeader->hdr_sig[1] == 'F' && + mGPTHeader->hdr_sig[2] == 'I' && + mGPTHeader->hdr_sig[3] == ' ' && + mGPTHeader->hdr_sig[4] == 'P' && + mGPTHeader->hdr_sig[5] == 'A' && + mGPTHeader->hdr_sig[6] == 'R' && + mGPTHeader->hdr_sig[7] == 'T') return true; + + return false; +} Index: branches/rewrite/i386/modules/Disk/include/Partition.hpp =================================================================== --- branches/rewrite/i386/modules/Disk/include/Partition.hpp (revision 1089) +++ branches/rewrite/i386/modules/Disk/include/Partition.hpp (revision 1090) @@ -20,6 +20,8 @@ virtual IOReturn Write(UInt64 sector, UInt64 size, UInt8* buffer); virtual bool probe(); + + //virtual uuid_t getUUID(); protected: Disk *mDisk; @@ -27,6 +29,7 @@ UInt64 mBeginSector; SInt8 mPartitionNumber; UInt8 mNumPartitions; + //uuid_t mUUID; private: Index: branches/rewrite/i386/modules/Disk/include/Disk.hpp =================================================================== --- branches/rewrite/i386/modules/Disk/include/Disk.hpp (revision 1089) +++ branches/rewrite/i386/modules/Disk/include/Disk.hpp (revision 1090) @@ -14,6 +14,7 @@ Disk(const char* name); ~Disk(); + // TODO: add cacheing virtual IOReturn Read(UInt64 sector, UInt64 size, UInt8* buffer) = 0; virtual IOReturn Write(UInt64 sector, UInt64 size, UInt8* buffer) = 0; Index: branches/rewrite/i386/modules/Disk/include/GUIDPartition.hpp =================================================================== --- branches/rewrite/i386/modules/Disk/include/GUIDPartition.hpp (revision 1089) +++ branches/rewrite/i386/modules/Disk/include/GUIDPartition.hpp (revision 1090) @@ -16,8 +16,12 @@ ~GUIDPartition(); protected: + bool isGPTDisk(); private: + UInt8 mLBABUffer[512]; // TODO: don't assume 512 + gpt_hdr* mGPTHeader; + gpt_ent* mGPTEntry; }; #endif /* GUID_PARTITION_H */ Index: branches/rewrite/i386/modules/Disk/Partition.cpp =================================================================== --- branches/rewrite/i386/modules/Disk/Partition.cpp (revision 1089) +++ branches/rewrite/i386/modules/Disk/Partition.cpp (revision 1090) @@ -34,3 +34,10 @@ { return (mDisk != NULL) && (mPartitionNumber != INVALID_PARTITION) && mNumSectors; } + +/* +Partition::getUUID() +{ + return mUUID; +} +*/ \ No newline at end of file