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
This commit is contained in:
Tom Marshall
2019-07-23 15:18:15 -07:00
committed by Michael Bestas
parent 0d1ea41525
commit 21ddbea48d
5 changed files with 13 additions and 1 deletions

View File

@@ -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 @@ public:
void ShowCommands(void);
}; // class BasicMBRData
#pragma pack(pop)
#endif

3
bsd.h
View File

@@ -54,6 +54,7 @@ struct BSDRecord { // the partition table
// 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 @@ class BSDData {
}; // struct MBRData
#pragma pack ()
#pragma pack(pop)
#endif

3
gpt.h
View File

@@ -37,6 +37,7 @@ enum GPTValidity {gpt_valid, gpt_corrupt, gpt_invalid};
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 @@ public:
// Function prototypes....
int SizesOK(void);
#pragma pack(pop)
#endif

View File

@@ -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 @@ public:
void ShowData(int isGpt);
}; // MBRPart
#pragma pack(pop)
#endif // MBRPART_H

View File

@@ -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;