gptfdisk: include gptcl.h after sgdisk.h
This fixes alignment issues with struct sgdisk_partition when used
outside sgdisk (eg. in recovery).
Also push/pop the pack decls in header files to further fix the issue.
Change-Id: If10799ea443ad6870a53494925b4032abb32c542
diff --git a/basicmbr.h b/basicmbr.h
index 504e039..b0938c6 100644
--- a/basicmbr.h
+++ b/basicmbr.h
@@ -26,6 +26,7 @@
// A 512-byte data structure into which the MBR can be loaded in one
// go. Also used when loading logical partitions.
+#pragma pack(push)
#pragma pack(1)
struct TempMBR {
uint8_t code[440];
@@ -151,4 +152,6 @@
void ShowCommands(void);
}; // class BasicMBRData
+#pragma pack(pop)
+
#endif
diff --git a/bsd.h b/bsd.h
index cbd3588..28015ce 100644
--- a/bsd.h
+++ b/bsd.h
@@ -57,6 +57,7 @@
// Full data in tweaked BSD format
// For some reason this has to be packed or MS Visual C++'s debugger complains
// about memory errors whenever a BSDData variable is destroyed.
+#pragma pack(push)
#pragma pack (8)
class BSDData {
protected:
@@ -91,4 +92,6 @@
}; // struct MBRData
#pragma pack ()
+#pragma pack(pop)
+
#endif
diff --git a/gpt.h b/gpt.h
index 0712a1f..f53331f 100644
--- a/gpt.h
+++ b/gpt.h
@@ -39,6 +39,7 @@
enum WhichToUse {use_gpt, use_mbr, use_bsd, use_new, use_abort};
// Header (first 512 bytes) of GPT table
+#pragma pack(push)
#pragma pack(1)
struct GPTHeader {
uint64_t signature;
@@ -214,4 +215,6 @@
// Function prototypes....
int SizesOK(void);
+#pragma pack(pop)
+
#endif
diff --git a/mbrpart.h b/mbrpart.h
index 0de365f..004e821 100644
--- a/mbrpart.h
+++ b/mbrpart.h
@@ -41,6 +41,7 @@
// On read of logical entries, it's relative to the EBR record for that
// partition. When writing EBR records, it's relative to the extended
// partition's start.
+#pragma pack(push)
#pragma pack(1)
struct MBRRecord {
uint8_t status;
@@ -110,4 +111,6 @@
void ShowData(int isGpt);
}; // MBRPart
+#pragma pack(pop)
+
#endif // MBRPART_H
diff --git a/sgdisk.cc b/sgdisk.cc
index feebc0d..ccd4480 100644
--- a/sgdisk.cc
+++ b/sgdisk.cc
@@ -16,11 +16,11 @@
#include <iostream>
#include <sstream>
#include <errno.h>
-#include "gptcl.h"
#include <fcntl.h>
#include <unistd.h>
#include "sgdisk.h"
+#include "gptcl.h"
using namespace std;