Fixed bug in hybrid MBR generation; gdisk 0.6.9

This commit is contained in:
srs5694
2010-07-04 01:54:00 -04:00
parent 8f1b2d6edc
commit 61768bccde
8 changed files with 39 additions and 19 deletions

18
NEWS
View File

@@ -1,10 +1,20 @@
0.6.9 (7/4/2010):
------------------
- Fixed minor error in sgdisk man page (--largest-new option requires
a partition number).
- Fixed major bug in hybrid MBR creation, which caused incorrect
protective partition end point settings and occasionally other
problems.
0.6.8 (5/23/2010): 0.6.8 (5/23/2010):
------------------ ------------------
- Added tests to see if the file to be opened is a directory, - Added tests to see if the file to be opened is a directory, character
character device, FIFO, or socket; program now terminates if any of device, FIFO, or socket; program now terminates if any of these
these conditions is met. (Linux/FreeBSD/OS X only.) Thanks to an conditions is met. (Linux/FreeBSD/OS X only.) Thanks to Justin Maggard
anonymous contributor for this patch. for this patch.
- Added 'f' option on gdisk's experts' menu (-G/--randomize-guids in - Added 'f' option on gdisk's experts' menu (-G/--randomize-guids in
sgdisk). This option randomizes the disk's GUID and all partitions' sgdisk). This option randomizes the disk's GUID and all partitions'

View File

@@ -1,11 +1,11 @@
Summary: An fdisk-like partitioning tool for GPT disks Summary: An fdisk-like partitioning tool for GPT disks
Name: gdisk Name: gdisk
Version: 0.6.8 Version: 0.6.9
Release: 1%{?dist} Release: 1%{?dist}
License: GPLv2 License: GPLv2
URL: http://www.rodsbooks.com/gdisk URL: http://www.rodsbooks.com/gdisk
Group: Applications/System Group: Applications/System
Source: http://www.rodsbooks.com/gdisk/gdisk-0.6.8.tgz Source: http://www.rodsbooks.com/gdisk/gdisk-0.6.9.tgz
BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX) BuildRoot: %(mktemp -ud %{_tmppath}/%{name}-%{version}-%{release}-XXXXXX)
%description %description
@@ -40,5 +40,5 @@ rm -rf $RPM_BUILD_ROOT
%doc %{_mandir}/man8* %doc %{_mandir}/man8*
%changelog %changelog
* Sun May 23 2010 R Smith <rodsmith@rodsbooks.com> - 0.6.8 * Sun Jul 4 2010 R Smith <rodsmith@rodsbooks.com> - 0.6.9
- Created spec file for 0.6.8 release - Created spec file for 0.6.9 release

View File

@@ -1,6 +1,6 @@
.\" Copyright 2010 Roderick W. Smith (rodsmith@rodsbooks.com) .\" Copyright 2010 Roderick W. Smith (rodsmith@rodsbooks.com)
.\" May be distributed under the GNU General Public License .\" May be distributed under the GNU General Public License
.TH "GDISK" "8" "0.6.8" "Roderick W. Smith" "GPT fdisk Manual" .TH "GDISK" "8" "0.6.9" "Roderick W. Smith" "GPT fdisk Manual"
.SH "NAME" .SH "NAME"
gdisk \- Interactive GUID partition table (GPT) manipulator gdisk \- Interactive GUID partition table (GPT) manipulator
.SH "SYNOPSIS" .SH "SYNOPSIS"
@@ -648,7 +648,8 @@ Contributors:
* David Hubbard (david.c.hubbard@gmail.com) * David Hubbard (david.c.hubbard@gmail.com)
* One anonymous contributor * Justin Maggard (justin.maggard@netgear.com)
.SH "SEE ALSO" .SH "SEE ALSO"
\fBcfdisk (8)\fR, \fBcfdisk (8)\fR,

14
gpt.cc
View File

@@ -1519,6 +1519,15 @@ int GPTData::PartsToMBR(PartNotes & notes) {
protectiveMBR.SetPartBootable(mbrNum); protectiveMBR.SetPartBootable(mbrNum);
mbrNum++; mbrNum++;
} // if } // if
if (convInfo.gptPartNum == MBR_EFI_GPT)
mbrNum++;
} // for
// Now go through and set sizes for MBR_EFI_GPT partitions....
notes.Rewind();
mbrNum = 0;
while (notes.GetNextInfo(&convInfo) >= 0) {
if ((convInfo.gptPartNum >= 0) && (convInfo.type == PRIMARY))
mbrNum++;
if (convInfo.gptPartNum == MBR_EFI_GPT) { if (convInfo.gptPartNum == MBR_EFI_GPT) {
if (protectiveMBR.FindFirstAvailable() == UINT32_C(1)) { if (protectiveMBR.FindFirstAvailable() == UINT32_C(1)) {
protectiveMBR.MakePart(mbrNum, 1, protectiveMBR.FindLastInFree(1), convInfo.hexCode); protectiveMBR.MakePart(mbrNum, 1, protectiveMBR.FindLastInFree(1), convInfo.hexCode);
@@ -1527,12 +1536,11 @@ int GPTData::PartsToMBR(PartNotes & notes) {
protectiveMBR.MakeBiggestPart(mbrNum, convInfo.hexCode); protectiveMBR.MakeBiggestPart(mbrNum, convInfo.hexCode);
} // if/else } // if/else
mbrNum++; mbrNum++;
} // if EFI GPT partition specified } // if
} // for } // while
// Now do logical partition(s)... // Now do logical partition(s)...
protectiveMBR.SetDisk(&myDisk); protectiveMBR.SetDisk(&myDisk);
numConverted += protectiveMBR.CreateLogicals(notes); numConverted += protectiveMBR.CreateLogicals(notes);
// numConverted += PartsToLogical(notes);
return numConverted; return numConverted;
} // GPTData::PartsToMBR() } // GPTData::PartsToMBR()

4
gpt.h
View File

@@ -1,7 +1,7 @@
/* gpt.h -- GPT and data structure definitions, types, and /* gpt.h -- GPT and data structure definitions, types, and
functions */ functions */
/* This program is copyright (c) 2009 by Roderick W. Smith. It is distributed /* This program is copyright (c) 2009, 2010 by Roderick W. Smith. It is distributed
under the terms of the GNU GPL version 2, as detailed in the COPYING file. */ under the terms of the GNU GPL version 2, as detailed in the COPYING file. */
#include <stdint.h> #include <stdint.h>
@@ -16,7 +16,7 @@
#ifndef __GPTSTRUCTS #ifndef __GPTSTRUCTS
#define __GPTSTRUCTS #define __GPTSTRUCTS
#define GPTFDISK_VERSION "0.6.8" #define GPTFDISK_VERSION "0.6.9"
// Constants used by GPTData::PartsToMBR(). MBR_EMPTY must be the lowest- // Constants used by GPTData::PartsToMBR(). MBR_EMPTY must be the lowest-
// numbered value to refer to partition numbers. (Most will be 0 or positive, // numbered value to refer to partition numbers. (Most will be 0 or positive,

View File

@@ -23,6 +23,7 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#include <stdint.h> #include <stdint.h>
#include <limits.h>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <cstdio> #include <cstdio>
@@ -390,6 +391,7 @@ void GPTDataTextUI::MakeHybrid(void) {
// Linux won't find any partitions on the disk. // Linux won't find any partitions on the disk.
newNote = new struct PartInfo; newNote = new struct PartInfo;
newNote->gptPartNum = MBR_EFI_GPT; newNote->gptPartNum = MBR_EFI_GPT;
newNote->firstLBA = 1;
newNote->active = 0; newNote->active = 0;
newNote->hexCode = 0xEE; newNote->hexCode = 0xEE;
newNote->type = PRIMARY; newNote->type = PRIMARY;

View File

@@ -444,7 +444,6 @@ int PartNotes::IsLegal(void) {
return (((p+e) <= 4) && (e <= 1)); return (((p+e) <= 4) && (e <= 1));
} // PartNotes::IsLegal() } // PartNotes::IsLegal()
/************************************************************************* /*************************************************************************
* * * *
* The following partitions manipulate the data in the quest to create a * * The following partitions manipulate the data in the quest to create a *

View File

@@ -1,6 +1,6 @@
.\" Copyright 2010 Roderick W. Smith (rodsmith@rodsbooks.com) .\" Copyright 2010 Roderick W. Smith (rodsmith@rodsbooks.com)
.\" May be distributed under the GNU General Public License .\" May be distributed under the GNU General Public License
.TH "SGDISK" "8" "0.6.8" "Roderick W. Smith" "GPT fdisk Manual" .TH "SGDISK" "8" "0.6.9" "Roderick W. Smith" "GPT fdisk Manual"
.SH "NAME" .SH "NAME"
sgdisk \- Command\-line GUID partition table (GPT) manipulator for Linux and Unix sgdisk \- Command\-line GUID partition table (GPT) manipulator for Linux and Unix
.SH "SYNOPSIS" .SH "SYNOPSIS"
@@ -304,7 +304,7 @@ which is the start of the largest available block for the start sector and
the end of the same block for the end sector. the end of the same block for the end sector.
.TP .TP
.B \-N, \-\-largest\-new .B \-N, \-\-largest\-new=num
Create a new partition that fills the largest available block of space on Create a new partition that fills the largest available block of space on
the disk. Note that if used on a completely blank disk, this is likely to the disk. Note that if used on a completely blank disk, this is likely to
result in a sector-moved warning, since the first available sector result in a sector-moved warning, since the first available sector
@@ -532,7 +532,7 @@ Contributors:
* David Hubbard (david.c.hubbard@gmail.com) * David Hubbard (david.c.hubbard@gmail.com)
* One anonymous contributor * Justin Maggard (justin.maggard@netgear.com)
.SH "SEE ALSO" .SH "SEE ALSO"
\fBcfdisk (8)\fR, \fBcfdisk (8)\fR,