Chameleon

Chameleon Svn Source Tree

Root/branches/rewrite/i386/modules/Disk/GUIDPartition.cpp

Source at commit 1129 created 12 years 11 months ago.
By meklort, Change options.o so that it reloads the system config as well. Also change it so that it uses that config for variables (NOTE: if the calue exists in chameleonConfig, it's used instead.
1/*
2 * Copyright (c) 2011 Evan Lojewski. All rights reserved.
3 *
4 */
5#include <GUIDPartition.hpp>
6
7
8GUIDPartition::GUIDPartition(Disk* disk, UInt8 partitionNumber) : Partition(disk, partitionNumber)
9{
10 mDisk = disk;
11 mNumSectors = 0;
12 mBeginSector = 0;
13 mPartitionNumber = partitionNumber;
14 mNumPartitions = 0;
15
16 if(mDisk)
17 {
18 // read in lba1, this contains the partition map if it's GPT
19 mDisk->Read(1, 1, mLBABUffer);
20 mGPTHeader = (gpt_hdr*)mLBABUffer;
21 }
22 else
23 {
24 mGPTHeader = NULL;
25 }
26
27 if(isGPTDisk())
28 {
29 mNumPartitions = mGPTHeader->hdr_entries;
30 }
31
32 mGPTHeader = NULL;
33
34 if(mPartitionNumber >= 0 && mPartitionNumber < mNumPartitions)
35 {
36 // read in partition entry.
37 mDisk->Read(2 + mPartitionNumber, 1, mLBABUffer);
38
39 mGPTEntry = (gpt_ent*) mLBABUffer;
40
41 mNumSectors = mGPTEntry->ent_lba_end - mGPTEntry->ent_lba_start;
42 mBeginSector = mGPTEntry->ent_lba_start;
43 //mUUID = mGPTEntry->ent_uuid;
44 }
45}
46
47GUIDPartition::~GUIDPartition()
48{
49
50}
51
52
53bool GUIDPartition::isGPTDisk()
54{
55 static bool status = false;
56
57 if(status) return status;
58
59 if(!mGPTHeader) return false;
60
61 if(mGPTHeader->hdr_sig[0] == 'E' &&
62 mGPTHeader->hdr_sig[1] == 'F' &&
63 mGPTHeader->hdr_sig[2] == 'I' &&
64 mGPTHeader->hdr_sig[3] == ' ' &&
65 mGPTHeader->hdr_sig[4] == 'P' &&
66 mGPTHeader->hdr_sig[5] == 'A' &&
67 mGPTHeader->hdr_sig[6] == 'R' &&
68 mGPTHeader->hdr_sig[7] == 'T') return true;
69
70 return false;
71}
72

Archive Download this file

Revision: 1129