Skip to content
Snippets Groups Projects
Commit 9b338c50 authored by Roderick W. Smith's avatar Roderick W. Smith
Browse files

Fixed new bug with hybrid MBR creation in gdisk; couldn't do more than

one partition because of sscanf weirdness.
parent 84aaff6b
No related branches found
No related tags found
No related merge requests found
0.8.10 (?/??/2014):
-------------------
- Fixed new (in 0.8.9) bug that caused a failure to create more than one
hybridized partition when creating a hybrid MBR.
- Fixed bug that caused gdisk to create hybridized partitions that ended
above the 2^32 sector point with incorrect end values. The program now
refuses to create such hybridized partitions at all.
0.8.9 (2/17/2014):
------------------
......
......@@ -138,6 +138,11 @@ int GPTPart::IsUsed(void) {
return (partitionType != GUIDData("0x00"));
} // GPTPart::IsUsed()
// Returns 1 if the partition's end point is under (2^32 - 1) sectors, 0 if it's over that value.
int GPTPart::IsSizedForMBR(void) {
return (lastLBA < UINT32_MAX);
} // GPTPart::IsSizedForMBR()
// Set the type code to the specified one. Also changes the partition
// name *IF* the current name is the generic one for the current partition
// type.
......
......@@ -63,6 +63,7 @@ class GPTPart {
void ShowAttributes(uint32_t partNum) {attributes.ShowAttributes(partNum);}
UnicodeString GetDescription(void);
int IsUsed(void);
int IsSizedForMBR(void);
// Simple data assignment:
void SetType(PartType t);
......
......@@ -396,7 +396,7 @@ void GPTDataTextUI::ShowDetails(void) {
void GPTDataTextUI::MakeHybrid(void) {
uint32_t partNums[3];
string line;
int numPartsToCvt, i, j, mbrNum = 0;
int numPartsToCvt = 0, i, j, mbrNum = 0;
unsigned int hexCode = 0;
MBRPart hybridPart;
MBRData hybridMBR;
......@@ -416,7 +416,10 @@ void GPTDataTextUI::MakeHybrid(void) {
cout << "Type from one to three GPT partition numbers, separated by spaces, to be\n"
<< "added to the hybrid MBR, in sequence: ";
line = ReadString();
numPartsToCvt = sscanf(line.c_str(), "%ud %ud %ud", &partNums[0], &partNums[1], &partNums[2]);
istringstream inLine(line);
do {
inLine >> partNums[numPartsToCvt++];
} while (!inLine.eof() && (numPartsToCvt < 3));
if (numPartsToCvt > 0) {
cout << "Place EFI GPT (0xEE) partition first in MBR (good for GRUB)? ";
......@@ -425,7 +428,7 @@ void GPTDataTextUI::MakeHybrid(void) {
for (i = 0; i < numPartsToCvt; i++) {
j = partNums[i] - 1;
if (partitions[j].IsUsed()) {
if (partitions[j].IsUsed() && partitions[j].IsSizedForMBR()) {
mbrNum = i + (eeFirst == 'Y');
cout << "\nCreating entry for GPT partition #" << j + 1
<< " (MBR partition #" << mbrNum + 1 << ")\n";
......@@ -439,7 +442,7 @@ void GPTDataTextUI::MakeHybrid(void) {
hybridPart.SetStatus(0x00);
hybridPart.SetInclusion(PRIMARY);
} else {
cerr << "\nGPT partition #" << j + 1 << " does not exist; skipping.\n";
cerr << "\nGPT partition #" << j + 1 << " does not exist or is too big; skipping.\n";
} // if/else
hybridMBR.AddPart(mbrNum, hybridPart);
} // for
......
......@@ -2,7 +2,7 @@
// Class to manage partition type codes -- a slight variant on MBR type
// codes, GUID type codes, and associated names.
/* This program is copyright (c) 2009-2013 by Roderick W. Smith. It is distributed
/* This program is copyright (c) 2009-2014 by Roderick W. Smith. It is distributed
under the terms of the GNU GPL version 2, as detailed in the COPYING file. */
#define __STDC_LIMIT_MACROS
......
......@@ -8,7 +8,7 @@
#ifndef __GPTSUPPORT
#define __GPTSUPPORT
#define GPTFDISK_VERSION "0.8.9"
#define GPTFDISK_VERSION "0.8.9.1"
#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__APPLE__)
// Darwin (Mac OS) & FreeBSD: disk IOCTLs are different, and there is no lseek64
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment