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 696f826..8db61cd 100644
--- a/basicmbr.h
+++ b/basicmbr.h
@@ -24,6 +24,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];
@@ -149,4 +150,6 @@
void ShowCommands(void);
}; // class BasicMBRData
+#pragma pack(pop)
+
#endif
diff --git a/bsd.h b/bsd.h
index e042b7b..b9d5374 100644
--- a/bsd.h
+++ b/bsd.h
@@ -54,6 +54,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:
@@ -88,4 +89,6 @@
}; // struct MBRData
#pragma pack ()
+#pragma pack(pop)
+
#endif
diff --git a/gpt.h b/gpt.h
index 6e1e0bb..a1ff47f 100644
--- a/gpt.h
+++ b/gpt.h
@@ -37,6 +37,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;
@@ -212,4 +213,6 @@
// Function prototypes....
int SizesOK(void);
+#pragma pack(pop)
+
#endif
diff --git a/mbrpart.h b/mbrpart.h
index 6c7b21a..b889f3d 100644
--- a/mbrpart.h
+++ b/mbrpart.h
@@ -39,6 +39,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;
@@ -108,4 +109,6 @@
void ShowData(int isGpt);
}; // MBRPart
+#pragma pack(pop)
+
#endif // MBRPART_H
diff --git a/sgdisk.cc b/sgdisk.cc
index cd65ae6..d3524c5 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;