Bug fix relating to loading of >128-entry partition tables

This commit is contained in:
srs5694
2010-02-21 11:09:20 -05:00
parent 08bb0da079
commit 1c6f8b013e
4 changed files with 28 additions and 8 deletions

View File

@@ -1,3 +1,15 @@
0.6.4.1 (2/20/2010):
--------------------
Note: Neither of the following changes affects actual program code, so I've
left the version number in the program at 0.6.4.
- Altered Makefile to pass user's compiler and linker environment
variables through.
- Added #include to gpttext.cc to enable it to compile on the latest
GCC versions (it was failing on at least some 4.4.x compilers).
0.6.4 (2/19/2010): 0.6.4 (2/19/2010):
------------------- -------------------

View File

@@ -1,7 +1,8 @@
CC=gcc CC=gcc
CXX=g++ CXX=g++
CFLAGS=-O2 -D_FILE_OFFSET_BITS=64 -g CFLAGS+=-D_FILE_OFFSET_BITS=64
CXXFLAGS=-O2 -Wall -D_FILE_OFFSET_BITS=64 -I /usr/local/include -I/opt/local/include -g CXXFLAGS+=-Wall -D_FILE_OFFSET_BITS=64
LDFLAGS+=
LIB_NAMES=crc32 support guid gptpart mbr gpt bsd parttypes attributes diskio diskio-unix LIB_NAMES=crc32 support guid gptpart mbr gpt bsd parttypes attributes diskio diskio-unix
LIB_SRCS=$(NAMES:=.cc) LIB_SRCS=$(NAMES:=.cc)
LIB_OBJS=$(LIB_NAMES:=.o) LIB_OBJS=$(LIB_NAMES:=.o)
@@ -11,10 +12,10 @@ DEPEND= makedepend $(CFLAGS)
all: gdisk sgdisk all: gdisk sgdisk
gdisk: $(LIB_OBJS) gdisk.o gpttext.o gdisk: $(LIB_OBJS) gdisk.o gpttext.o
$(CXX) $(LIB_OBJS) gdisk.o gpttext.o -L/opt/local/lib -L/usr/local/lib -luuid -o gdisk $(CXX) $(LIB_OBJS) gdisk.o gpttext.o -L/opt/local/lib -L/usr/local/lib $(LDFLAGS) -luuid -o gdisk
sgdisk: $(LIB_OBJS) sgdisk.o sgdisk: $(LIB_OBJS) sgdisk.o
$(CXX) $(LIB_OBJS) sgdisk.o -L/opt/local/lib -L/usr/local/lib -luuid -lpopt -o sgdisk $(CXX) $(LIB_OBJS) sgdisk.o -L/opt/local/lib -L/usr/local/lib $(LDFLAGS) -luuid -lpopt -o sgdisk
testguid: $(LIB_OBJS) testguid.o testguid: $(LIB_OBJS) testguid.o
$(CXX) $(LIB_OBJS) testguid.o -o testguid $(CXX) $(LIB_OBJS) testguid.o -o testguid

12
gpt.cc
View File

@@ -757,18 +757,24 @@ int GPTData::LoadSecondTableAsMain(void) {
// failure. // failure.
int GPTData::LoadHeader(struct GPTHeader *header, DiskIO & disk, uint64_t sector, int *crcOk) { int GPTData::LoadHeader(struct GPTHeader *header, DiskIO & disk, uint64_t sector, int *crcOk) {
int allOK = 1; int allOK = 1;
GPTHeader tempHeader;
disk.Seek(sector); disk.Seek(sector);
if (disk.Read(header, 512) != 512) { if (disk.Read(&tempHeader, 512) != 512) {
cerr << "Warning! Read error " << errno << "; strange behavior now likely!\n"; cerr << "Warning! Read error " << errno << "; strange behavior now likely!\n";
allOK = 0; allOK = 0;
} // if } // if
*crcOk = CheckHeaderCRC(header); *crcOk = CheckHeaderCRC(&tempHeader);
// Reverse byte order, if necessary // Reverse byte order, if necessary
if (IsLittleEndian() == 0) { if (IsLittleEndian() == 0) {
ReverseHeaderBytes(header); ReverseHeaderBytes(header);
} // if } // if
if (allOK && mainHeader.numParts != tempHeader.numParts)
allOK = SetGPTSize(tempHeader.numParts);
*header = tempHeader;
return allOK; return allOK;
} // GPTData::LoadHeader } // GPTData::LoadHeader

View File

@@ -24,6 +24,7 @@
#include <errno.h> #include <errno.h>
#include <iostream> #include <iostream>
#include <sstream> #include <sstream>
#include <cstdio>
#include "attributes.h" #include "attributes.h"
#include "gpttext.h" #include "gpttext.h"