Fixed bug in hybrid MBR generation; gdisk 0.6.9
diff --git a/NEWS b/NEWS
index ad0987e..4e2c8e9 100644
--- a/NEWS
+++ b/NEWS
@@ -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):
 ------------------
 
-- Added tests to see if the file to be opened is a directory,
-  character device, FIFO, or socket; program now terminates if any of
-  these conditions is met. (Linux/FreeBSD/OS X only.) Thanks to an
-  anonymous contributor for this patch.
+- Added tests to see if the file to be opened is a directory, character
+  device, FIFO, or socket; program now terminates if any of these
+  conditions is met. (Linux/FreeBSD/OS X only.) Thanks to  Justin Maggard
+  for this patch.
 
 - Added 'f' option on gdisk's experts' menu (-G/--randomize-guids in
   sgdisk). This option randomizes the disk's GUID and all partitions'
diff --git a/current.spec b/current.spec
index b9b1341..600c21b 100644
--- a/current.spec
+++ b/current.spec
@@ -1,11 +1,11 @@
 Summary: An fdisk-like partitioning tool for GPT disks
 Name: gdisk
-Version: 0.6.8
+Version: 0.6.9
 Release: 1%{?dist}
 License: GPLv2
 URL: http://www.rodsbooks.com/gdisk
 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)
 
 %description
@@ -40,5 +40,5 @@
 %doc %{_mandir}/man8*
 
 %changelog
-* Sun May 23 2010 R Smith <rodsmith@rodsbooks.com> - 0.6.8
-- Created spec file for 0.6.8 release
+* Sun Jul 4 2010 R Smith <rodsmith@rodsbooks.com> - 0.6.9
+- Created spec file for 0.6.9 release
diff --git a/gdisk.8 b/gdisk.8
index ce4cda8..e11df37 100644
--- a/gdisk.8
+++ b/gdisk.8
@@ -1,6 +1,6 @@
 .\" Copyright 2010 Roderick W. Smith (rodsmith@rodsbooks.com)
 .\" 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"
 gdisk \- Interactive GUID partition table (GPT) manipulator
 .SH "SYNOPSIS"
@@ -648,7 +648,8 @@
 
 * David Hubbard (david.c.hubbard@gmail.com)
 
-* One anonymous contributor
+* Justin Maggard (justin.maggard@netgear.com)
+
 
 .SH "SEE ALSO"
 \fBcfdisk (8)\fR,
diff --git a/gpt.cc b/gpt.cc
index 213774e..c2f6f55 100644
--- a/gpt.cc
+++ b/gpt.cc
@@ -1519,6 +1519,15 @@
             protectiveMBR.SetPartBootable(mbrNum);
          mbrNum++;
       } // 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 (protectiveMBR.FindFirstAvailable() == UINT32_C(1)) {
             protectiveMBR.MakePart(mbrNum, 1, protectiveMBR.FindLastInFree(1), convInfo.hexCode);
@@ -1527,12 +1536,11 @@
             protectiveMBR.MakeBiggestPart(mbrNum, convInfo.hexCode);
          } // if/else
          mbrNum++;
-      } // if EFI GPT partition specified
-   } // for
+      } // if
+   } // while
    // Now do logical partition(s)...
    protectiveMBR.SetDisk(&myDisk);
    numConverted += protectiveMBR.CreateLogicals(notes);
-//   numConverted += PartsToLogical(notes);
    return numConverted;
 } // GPTData::PartsToMBR()
 
diff --git a/gpt.h b/gpt.h
index 235c7af..91b5152 100644
--- a/gpt.h
+++ b/gpt.h
@@ -1,7 +1,7 @@
 /* gpt.h -- GPT and data structure definitions, types, and
    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. */
 
 #include <stdint.h>
@@ -16,7 +16,7 @@
 #ifndef __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-
 // numbered value to refer to partition numbers. (Most will be 0 or positive,
diff --git a/gpttext.cc b/gpttext.cc
index 3000308..fe64be0 100644
--- a/gpttext.cc
+++ b/gpttext.cc
@@ -23,6 +23,7 @@
 #include <string.h>
 #include <errno.h>
 #include <stdint.h>
+#include <limits.h>
 #include <iostream>
 #include <sstream>
 #include <cstdio>
@@ -390,6 +391,7 @@
       // Linux won't find any partitions on the disk.
       newNote = new struct PartInfo;
       newNote->gptPartNum = MBR_EFI_GPT;
+      newNote->firstLBA = 1;
       newNote->active = 0;
       newNote->hexCode = 0xEE;
       newNote->type = PRIMARY;
diff --git a/partnotes.cc b/partnotes.cc
index de32c5b..c7954e7 100644
--- a/partnotes.cc
+++ b/partnotes.cc
@@ -444,7 +444,6 @@
    return (((p+e) <= 4) && (e <= 1));
 } // PartNotes::IsLegal()
 
-
 /*************************************************************************
  *                                                                       *
  * The following partitions manipulate the data in the quest to create a *
diff --git a/sgdisk.8 b/sgdisk.8
index 63c8cf5..1855bcd 100644
--- a/sgdisk.8
+++ b/sgdisk.8
@@ -1,6 +1,6 @@
 .\" Copyright 2010 Roderick W. Smith (rodsmith@rodsbooks.com)
 .\" 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"
 sgdisk \- Command\-line GUID partition table (GPT) manipulator for Linux and Unix
 .SH "SYNOPSIS"
@@ -304,7 +304,7 @@
 the end of the same block for the end sector.
 
 .TP
-.B \-N, \-\-largest\-new
+.B \-N, \-\-largest\-new=num
 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
 result in a sector-moved warning, since the first available sector
@@ -532,7 +532,7 @@
 
 * David Hubbard (david.c.hubbard@gmail.com)
 
-* One anonymous contributor
+* Justin Maggard (justin.maggard@netgear.com)
 
 .SH "SEE ALSO"
 \fBcfdisk (8)\fR,