summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRod Smith <rodsmith@rodsbooks.com>2017-07-23 11:50:17 -0400
committerRod Smith <rodsmith@rodsbooks.com>2017-07-23 11:50:17 -0400
commit0dfa506ba6e999c511dd69b688e24ab8884f4a1a (patch)
tree36d0d288c25879e8aef7df16bc46f5ae3bac77e6
parent503e9ada12d38394381442a944d5c9da847800b6 (diff)
downloadsgdisk-0dfa506ba6e999c511dd69b688e24ab8884f4a1a.tar.gz
Added a couple of new verification checks and minor tweaks.
-rw-r--r--Makefile1
-rw-r--r--NEWS3
-rw-r--r--gpt.cc24
-rw-r--r--mbr.cc6
-rw-r--r--support.cc2
5 files changed, 28 insertions, 8 deletions
diff --git a/Makefile b/Makefile
index 8c43169..b92104d 100644
--- a/Makefile
+++ b/Makefile
@@ -44,6 +44,7 @@ depend: $(SRCS)
$(OBJS):
$(CRITICAL_CXX_FLAGS)
+# makedepend dependencies below -- type "makedepend *.cc" to regenerate....
# DO NOT DELETE
attributes.o: /usr/include/stdint.h /usr/include/features.h
diff --git a/NEWS b/NEWS
index 31e9a15..d65ab59 100644
--- a/NEWS
+++ b/NEWS
@@ -1,6 +1,9 @@
1.0.2 (?/??/2017):
------------------
+- Addition of new verification checks, mostly (but not exclusively) related
+ to the new j/-j/--move-main-table option.
+
- Added new option: 'j' on the experts' menu in gdisk;
'-j/--move-main-table={sector}' in sgdisk. This option enables relocating
the main partition table from sector 2 (the default location) to somewhere
diff --git a/gpt.cc b/gpt.cc
index 44f5fb4..015da65 100644
--- a/gpt.cc
+++ b/gpt.cc
@@ -276,7 +276,7 @@ int GPTData::Verify(void) {
<< "The 'e' option on the experts' menu may fix this problem.\n";
} // if
- // Check the main and backup partition tables for overlap with things
+ // Check the main and backup partition tables for overlap with things and unusual gaps
if (mainHeader.partitionEntriesLBA + GetTableSizeInSectors() > mainHeader.firstUsableLBA) {
problems++;
cout << "\nProblem: Main partition table extends past the first usable LBA.\n"
@@ -292,6 +292,28 @@ int GPTData::Verify(void) {
cout << "\nProblem: The backup partition table overlaps the backup header.\n"
<< "Using 'e' on the experts' menu may fix this problem.\n";
} // if
+ if (mainHeader.partitionEntriesLBA != 2) {
+ cout << "\nWarning: There is a gap between the main metadata (sector 1) and the main\n"
+ << "partition table (sector " << mainHeader.partitionEntriesLBA
+ << "). This is helpful in some exotic configurations,\n"
+ << "but is generally ill-advised. Using 'j' on the experts' menu can adjust this\n"
+ << "gap.\n";
+ } // if
+ if (mainHeader.partitionEntriesLBA + GetTableSizeInSectors() != mainHeader.firstUsableLBA) {
+ cout << "\nWarning: There is a gap between the main partition table (ending sector "
+ << mainHeader.partitionEntriesLBA + GetTableSizeInSectors() - 1 << ")\n"
+ << "and the first usable sector (" << mainHeader.firstUsableLBA << "). This is helpful in some exotic configurations,\n"
+ << "but is unusual. The util-linux fdisk program often creates disks like this.\n"
+ << "Using 'j' on the experts' menu can adjust this gap.\n";
+ } // if
+
+ if (mainHeader.sizeOfPartitionEntries * mainHeader.numParts < 16384) {
+ cout << "\nWarning: The size of the partition table (" << mainHeader.sizeOfPartitionEntries * mainHeader.numParts
+ << " bytes) is less than the minimum\n"
+ << "required by the GPT specification. Most OSes and tools seem to work fine on\n"
+ << "such disks, but this is a violation of the GPT specification and so may cause\n"
+ << "problems.\n";
+ } // if
if ((mainHeader.lastUsableLBA >= diskSize) || (mainHeader.lastUsableLBA > mainHeader.backupLBA)) {
problems++;
diff --git a/mbr.cc b/mbr.cc
index 08c61be..c3483a0 100644
--- a/mbr.cc
+++ b/mbr.cc
@@ -31,12 +31,6 @@ using namespace std;
MBRData::~MBRData(void) {
} // MBRData destructor
-/* // Assignment operator -- copy entire set of MBR data.
-MBRData & MBRData::operator=(const MBRData & orig) {
- BasicMBRData::operator=(orig);
- return *this;
-} // MBRData::operator=() */
-
// Assignment operator -- copy entire set of MBR data.
MBRData & MBRData::operator=(const BasicMBRData & orig) {
BasicMBRData::operator=(orig);
diff --git a/support.cc b/support.cc
index d96da2d..bc91c6e 100644
--- a/support.cc
+++ b/support.cc
@@ -77,7 +77,7 @@ uint64_t GetNumber(uint64_t low, uint64_t high, uint64_t def, const string & pro
cin.getline(line, 255);
if (!cin.good())
exit(5);
- num = sscanf(line, "%ld", &response);
+ num = sscanf(line, "%lld", &response);
if (num == 1) { // user provided a response
if ((response < low) || (response > high))
cout << "Value out of range\n";