summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsrs5694 <srs5694@users.sourceforge.net>2012-12-15 01:55:21 -0500
committersrs5694 <srs5694@users.sourceforge.net>2012-12-15 01:55:21 -0500
commitd8eed4629449a325999808a0170dbda53bd4a6df (patch)
tree0fc11fed0800001c44f07e90877b557c2c417743
parent4307ef2e863cbec357df56197046c6b679fc5d2d (diff)
downloadsgdisk-d8eed4629449a325999808a0170dbda53bd4a6df.tar.gz
Added partition type codes; new verification check.
-rw-r--r--Makefile.mac16
-rw-r--r--NEWS20
-rw-r--r--fixparts.828
-rw-r--r--gpt.cc31
-rw-r--r--gpt.h2
-rw-r--r--gptpart.cc3
-rw-r--r--gpttext.cc2
-rw-r--r--parttypes.cc17
-rw-r--r--support.h2
9 files changed, 87 insertions, 34 deletions
diff --git a/Makefile.mac b/Makefile.mac
index a9b5315..4e2cf32 100644
--- a/Makefile.mac
+++ b/Makefile.mac
@@ -1,8 +1,8 @@
CC=gcc
CXX=g++
CFLAGS=-O2 -D_FILE_OFFSET_BITS=64 -g
-CXXFLAGS=-O2 -Wall -D_FILE_OFFSET_BITS=64 -D USE_UTF16 -I/sw/include -I/usr/local/include -I/opt/local/include -g
-#CXXFLAGS=-O2 -Wall -D_FILE_OFFSET_BITS=64 -I /usr/local/include -I/opt/local/include -g
+#CXXFLAGS=-O2 -Wall -D_FILE_OFFSET_BITS=64 -D USE_UTF16 -I/sw/include -I/usr/local/include -I/opt/local/include -g
+CXXFLAGS=-O2 -Wall -D_FILE_OFFSET_BITS=64 -I/sw/include -I /usr/local/include -I/opt/local/include -g
LIB_NAMES=crc32 support guid gptpart mbrpart basicmbr mbr gpt bsd parttypes attributes diskio diskio-unix
MBR_LIBS=support diskio diskio-unix basicmbr mbrpart
#LIB_SRCS=$(NAMES:=.cc)
@@ -14,16 +14,16 @@ DEPEND= makedepend $(CFLAGS)
all: gdisk sgdisk cgdisk fixparts
gdisk: $(LIB_OBJS) gpttext.o gdisk.o
-# $(CXX) $(LIB_OBJS) gpttext.o gdisk.o -o gdisk
- $(CXX) $(LIB_OBJS) -L/usr/lib -licucore gpttext.o gdisk.o -o gdisk
+ $(CXX) $(LIB_OBJS) gpttext.o gdisk.o -o gdisk
+# $(CXX) $(LIB_OBJS) -L/usr/lib -licucore gpttext.o gdisk.o -o gdisk
cgdisk: $(LIB_OBJS) cgdisk.o gptcurses.o
-# $(CXX) $(LIB_OBJS) cgdisk.o gptcurses.o $(LDFLAGS) -lncurses -o sgdisk
- $(CXX) $(LIB_OBJS) cgdisk.o gptcurses.o $(LDFLAGS) -licucore -lncurses -o cgdisk
+ $(CXX) $(LIB_OBJS) cgdisk.o gptcurses.o $(LDFLAGS) -lncurses -o sgdisk
+# $(CXX) $(LIB_OBJS) cgdisk.o gptcurses.o $(LDFLAGS) -licucore -lncurses -o cgdisk
sgdisk: $(LIB_OBJS) gptcl.o sgdisk.o
-# $(CXX) $(LIB_OBJS) gptcl.o sgdisk.o -L/sw/lib -lpopt -o sgdisk
- $(CXX) $(LIB_OBJS) gptcl.o sgdisk.o -L/sw/lib -licucore -lpopt -o sgdisk
+ $(CXX) $(LIB_OBJS) gptcl.o sgdisk.o -L/sw/lib -lpopt -o sgdisk
+# $(CXX) $(LIB_OBJS) gptcl.o sgdisk.o -L/sw/lib -licucore -lpopt -o sgdisk
fixparts: $(MBR_LIB_OBJS) fixparts.o
$(CXX) $(MBR_LIB_OBJS) fixparts.o $(LDFLAGS) -o fixparts
diff --git a/NEWS b/NEWS
index 607e3f5..24e867c 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,23 @@
+0.8.6 (?/??/2012):
+------------------
+
+- Added a new check to the verification code.
+
+- Added partition type code for Sony system partition
+ (F4019732-066E-4E12-8273-346C5641494F). I'm not entirely clear what this
+ is used for, but it's appearing on some new Sony computers.
+
+- Tweaked hybrid MBR creation options to fix a problem that caused the main
+ 0xEE MBR partition to NOT be created if the user told gdisk to NOT place
+ it at the start of the disk AND IF fewer than three partitions are
+ hybridize AND IF the user opted to create a second protective partition.
+
+- Changed default build options for Mac OS X to *NOT* use libicu,
+ since it seems to have broken somewhere along the line. It still
+ works on Linux, though.
+
+- Added partition type codes for VMWare ESX (FB00, FB01, and FC00).
+
0.8.5 (5/30/2012):
------------------
diff --git a/fixparts.8 b/fixparts.8
index 0359bc4..a36f1a1 100644
--- a/fixparts.8
+++ b/fixparts.8
@@ -39,13 +39,13 @@ within constraints imposed by the MBR data structures.
Additional features include the ability to change partition type codes or
boot/active flags, to delete partitions, and to recompute CHS values. With
the possible exception of recomputing CHS values, these secondary features
-are better performed with \fBfdisk\fR, because \fBfixpart\fR's design means
+are better performed with \fBfdisk\fR, because \fBfixparts\fR' design means
that it's likely to alter partition numbering even when such changes are
not requested.
-The \fBfixpart\fR program employs a user interface similar to that of
-Linux's \fBfdisk\fR, but \fBfixpart\fR is much more specialized. Most
-importantly, you can't create new partitions with \fBfixpart\fR, although
+The \fBfixparts\fR program employs a user interface similar to that of
+Linux's \fBfdisk\fR, but \fBfixparts\fR is much more specialized. Most
+importantly, you can't create new partitions with \fBfixparts\fR, although
you can change primary/logical assignment.
In the MBR scheme, partitions come in three varieties:
@@ -64,10 +64,10 @@ holding areas for logical partitions.
.TP
.B logical
A disk can contain an arbitrary number of logical partitions
-(\fBfixpart\fR, however, imposes a limit of 124 logical partitions). All
+(\fBfixparts\fR, however, imposes a limit of 124 logical partitions). All
the logical partitions reside inside a single extended partition, and are
defined using a linked-list data structure. This fact means that every
-logical partition be preceded by at least one sector of unallocated space
+logical partition must be preceded by at least one sector of unallocated space
to hold its defining data structure (an Extended Boot Record, or EBR).
.PP
@@ -81,7 +81,7 @@ between logical partitions, since this would mean placing a primary
partition within an extended partition (which is just a specific type of
primary partition).
-Unlike most disk utilities, \fBfixpart\fR's user interface ignores extended
+Unlike most disk utilities, \fBfixparts\fR' user interface ignores extended
partitions. Internally, the program discards the information on the
original extended partition and, when you tell it to save its changes, it
generates a new extended partition to contain the then-defined logical
@@ -89,19 +89,19 @@ partitions. This is done because most of the repairs and manipulations the
tool performs require generating a fresh extended partition, so keeping the
original in the user interface would only be a complication.
-Another unusual feature of \fBfixpart\fR's user interface is that partition
+Another unusual feature of \fBfixparts\fR' user interface is that partition
numbers do not necessarily correlate with primary/logical status. In most
utilities, partitions 1\-4 correspond to primary partitions, whereas
-partitions 5 and up are logical partitions. In \fBfixpart\fR, any partition
+partitions 5 and up are logical partitions. In \fBfixparts\fR, any partition
number may be assigned primary or logical status, so long as the rules for
layout described earlier are obeyed. When the partition table is saved,
partitions will be assigned appropriately and then tools such as the Linux
kernel and \fBfdisk\fR will give them conventional numbers.
-When it first starts, \fBfixpart\fR performs a scan for GPT data. If the
-disk looks like a conventional GPT disk, \fBfixpart\fR refuses to run. If
+When it first starts, \fBfixparts\fR performs a scan for GPT data. If the
+disk looks like a conventional GPT disk, \fBfixparts\fR refuses to run. If
the disk appears to be a conventional MBR disk but GPT signatures are
-present in the GPT primary or secondary header areas, \fBfixpart\fR
+present in the GPT primary or secondary header areas, \fBfixparts\fR
offers to delete this extraneous data. If you tell it to do so, the program
immediately wipes the GPT header or headers. (If only one header was found,
only that one header will be erased, to minimize the risk of damaging a
@@ -109,7 +109,7 @@ boot loader or other data that might have overwritten just one of the GPT
headers.)
With the exception of optionally erasing leftover GPT data when it first
-starts, \fBfixpart\fR keeps all changes in memory until the user writes
+starts, \fBfixparts\fR keeps all changes in memory until the user writes
changes with the \fBw\fR command. Thus, you can adjust your partitions in
the user interface and abort those changes by typing \fBq\fR to quit
without saving changes.
@@ -147,7 +147,7 @@ form if there had been no free sectors between the two partitions.
.TP
.B o
Omit a partition. Once omitted, the partition will still appear in the
-\fBfixpart\fR partition list, but it will be flagged as omitted. You can
+\fBfixparts\fR partition list, but it will be flagged as omitted. You can
subsequently convert it to primary or logical form with the \fBr\fR or
\fBl\fR commands, respectively. When you save your changes with \fBw\fR,
though, the partition will be lost.
diff --git a/gpt.cc b/gpt.cc
index 9960d8f..e0f5899 100644
--- a/gpt.cc
+++ b/gpt.cc
@@ -3,7 +3,7 @@
/* By Rod Smith, initial coding January to February, 2009 */
-/* This program is copyright (c) 2009-2011 by Roderick W. Smith. It is distributed
+/* This program is copyright (c) 2009-2012 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
@@ -259,6 +259,14 @@ int GPTData::Verify(void) {
<< "The 'e' option on the experts' menu may fix this problem.\n";
} // if
+ if ((mainHeader.lastUsableLBA >= diskSize) || (mainHeader.lastUsableLBA > mainHeader.backupLBA)) {
+ problems++;
+ cout << "\nProblem: GPT claims the disk is larger than it is!\n";
+ cout << "(Claimed last usable sector is " << mainHeader.lastUsableLBA << ", but\n";
+ cout << "backup header is at " << mainHeader.backupLBA << " and disk size is\n";
+ cout << diskSize << "sectors\n";
+ }
+
// Check for overlapping partitions....
problems += FindOverlaps();
@@ -1018,6 +1026,21 @@ int GPTData::SaveGPTData(int quiet) {
} // if/else quiet
} // if
+ if ((mainHeader.lastUsableLBA >= diskSize) || (mainHeader.lastUsableLBA > mainHeader.backupLBA)) {
+ if (quiet == 0) {
+ cout << "Warning! The claimed last usable sector is incorrect! Do you want to correct\n"
+ << "this problem? ";
+ if (GetYN() == 'Y') {
+ MoveSecondHeaderToEnd();
+ cout << "Have adjusted the second header and last usable sector value.\n";
+ } else {
+ cout << "Have not corrected the problem. Strange problems may occur in the future!\n";
+ } // if correction requested
+ } else { // go ahead and do correction automatically
+ MoveSecondHeaderToEnd();
+ } // if/else quiet
+ } // if
+
// Check for overlapping or insane partitions....
if ((FindOverlaps() > 0) || (FindInsanePartitions() > 0)) {
allOK = 0;
@@ -2196,12 +2219,12 @@ void GPTData::SetAlignment(uint32_t n) {
// sector size), but not by the previously-located alignment value, then the
// alignment value is adjusted down. If the computed alignment is less than 8
// and the disk is bigger than SMALLEST_ADVANCED_FORMAT, resets it to 8. This
-// is a safety measure for WD Advanced Format and similar drives. If no partitions
-// are defined, the alignment value is set to DEFAULT_ALIGNMENT (2048) (or an
+// is a safety measure for Advanced Format drives. If no partitions are
+// defined, the alignment value is set to DEFAULT_ALIGNMENT (2048) (or an
// adjustment of that based on the current sector size). The result is that new
// drives are aligned to 2048-sector multiples but the program won't complain
// about other alignments on existing disks unless a smaller-than-8 alignment
-// is used on big disks (as safety for WD Advanced Format drives).
+// is used on big disks (as safety for Advanced Format drives).
// Returns the computed alignment value.
uint32_t GPTData::ComputeAlignment(void) {
uint32_t i = 0, found, exponent = 31;
diff --git a/gpt.h b/gpt.h
index 26672d7..7afd11a 100644
--- a/gpt.h
+++ b/gpt.h
@@ -183,7 +183,7 @@ public:
int IsFree(uint64_t sector, uint32_t *partNum = NULL);
int IsFreePartNum(uint32_t partNum);
int IsUsedPartNum(uint32_t partNum);
-
+
// Change how functions work, or return information on same
void SetAlignment(uint32_t n);
uint32_t ComputeAlignment(void); // Set alignment based on current partitions
diff --git a/gptpart.cc b/gptpart.cc
index 7ac629a..0f5ef02 100644
--- a/gptpart.cc
+++ b/gptpart.cc
@@ -114,6 +114,7 @@ void GPTPart::SetName(const string & theName) {
// Set the name for a partition to theName, using a Unicode string as
// input.
void GPTPart::SetName(const UnicodeString & theName) {
+ cout << "Entering GPTPart::SetName(const UnicodeString...)\n";
if (theName.isBogus()) {
cerr << "Bogus UTF-16 name found in GPTPart::SetName()! Name not changed!\n";
} else {
@@ -138,7 +139,7 @@ void GPTPart::SetName(const string & theName) {
memset(name, 0, NAME_SIZE);
for (i = 0; i < length; i++)
name[i * 2] = theName[i];
-} // GPTPart::SetName(), Windows version
+} // GPTPart::SetName(), ASCII version
#endif
// Set the name for the partition based on the current GUID partition type
diff --git a/gpttext.cc b/gpttext.cc
index 506c0f1..474b23b 100644
--- a/gpttext.cc
+++ b/gpttext.cc
@@ -452,7 +452,7 @@ void GPTDataTextUI::MakeHybrid(void) {
if (eeFirst == 'Y') {
hybridMBR.AddPart(0, hybridPart);
} else {
- hybridMBR.AddPart(3, hybridPart);
+ hybridMBR.AddPart(numPartsToCvt, hybridPart);
} // else
hybridMBR.SetHybrid();
diff --git a/parttypes.cc b/parttypes.cc
index 88eef57..721e8ff 100644
--- a/parttypes.cc
+++ b/parttypes.cc
@@ -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-2011 by Roderick W. Smith. It is distributed
+/* This program is copyright (c) 2009-2012 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
@@ -72,7 +72,8 @@ void PartType::AddAllTypes(void) {
// on empty partition table entries....
AddType(0x0000, "00000000-0000-0000-0000-000000000000", "Unused entry", 0);
- // DOS/Windows partition types, which confusingly Linux also uses in GPT
+ // DOS/Windows partition types, most of which are hidden from the "L" listing
+ // (they're available mainly for MBR-to-GPT conversions).
AddType(0x0100, "EBD0A0A2-B9E5-4433-87C0-68B6B72699C7", "Microsoft basic data", 0); // FAT-12
AddType(0x0400, "EBD0A0A2-B9E5-4433-87C0-68B6B72699C7", "Microsoft basic data", 0); // FAT-16 < 32M
AddType(0x0600, "EBD0A0A2-B9E5-4433-87C0-68B6B72699C7", "Microsoft basic data", 0); // FAT-16
@@ -106,7 +107,7 @@ void PartType::AddAllTypes(void) {
AddType(0x7f02, "2E0A753D-9E48-43B0-8337-B15192CB1B5E", "ChromeOS reserved");
// Linux-specific partition types....
- AddType(0x8200, "0657FD6D-A4AB-43C4-84E5-0933C84B4F4F", "Linux swap"); // Linux swap (or Solaris)
+ AddType(0x8200, "0657FD6D-A4AB-43C4-84E5-0933C84B4F4F", "Linux swap"); // Linux swap (or Solaris on MBR)
AddType(0x8300, "0FC63DAF-8483-4772-8E79-3D69D8477DE4", "Linux filesystem"); // Linux native
AddType(0x8301, "8DA63339-0007-60C0-C436-083AC8230908", "Linux reserved");
AddType(0x8e00, "E6D6D379-F507-44C2-A23C-238F2A3DF928", "Linux LVM");
@@ -171,10 +172,18 @@ void PartType::AddAllTypes(void) {
AddType(0xc001, "75894C1E-3AEB-11D3-B7C1-7B03A0000000", "HP-UX data");
AddType(0xc002, "E2A1E728-32E3-11D6-A682-7B03A0000000", "HP-UX service");
+ // Sony uses this GUID on some of its computers.
+ AddType(0xed00, "F4019732-066E-4E12-8273-346C5641494F", "Sony system partition");
+
// EFI system and related partitions
AddType(0xef00, "C12A7328-F81F-11D2-BA4B-00A0C93EC93B", "EFI System"); // Parted identifies these as having the "boot flag" set
AddType(0xef01, "024DEE41-33E7-11D3-9D69-0008C781F39F", "MBR partition scheme"); // Used to nest MBR in GPT
- AddType(0xef02, "21686148-6449-6E6F-744E-656564454649", "BIOS boot partition"); // Boot loader
+ AddType(0xef02, "21686148-6449-6E6F-744E-656564454649", "BIOS boot partition"); // Used by GRUB
+
+ // VMWare ESX partition types codes
+ AddType(0xfb00, "AA31E02A-400F-11DB-9590-000C2911D1B8", "VMWare VMFS");
+ AddType(0xfb01, "9198EFFC-31C0-11DB-8F78-000C2911D1B8", "VMWare reserved");
+ AddType(0xfc00, "9D275380-40AD-11DB-BF97-000C2911D1B8", "VMWare kcore crash protection");
// A straggler Linux partition type....
AddType(0xfd00, "A19D880F-05FC-4D3B-A006-743F0F84911E", "Linux RAID");
diff --git a/support.h b/support.h
index bc743cf..39098dc 100644
--- a/support.h
+++ b/support.h
@@ -8,7 +8,7 @@
#ifndef __GPTSUPPORT
#define __GPTSUPPORT
-#define GPTFDISK_VERSION "0.8.5"
+#define GPTFDISK_VERSION "0.8.5.4"
#if defined (__FreeBSD__) || defined (__FreeBSD_kernel__) || defined (__APPLE__)
// Darwin (Mac OS) & FreeBSD: disk IOCTLs are different, and there is no lseek64