Updated to version 0.4.1
Adds relative partition sizing and placement options for both start and
end sectors; improves hybrid MBR synchronization (deletes matching MBR
partition when a GPT partition is deleted, warns about inconsistencies
when verifying or writing a partition table).
diff --git a/bsd.h b/bsd.h
index b35d921..c92cfb0 100644
--- a/bsd.h
+++ b/bsd.h
@@ -11,7 +11,7 @@
#ifndef __BSD_STRUCTS
#define __BSD_STRUCTS
-#define BSD_SIGNATURE UINT32_C(0x82564557)
+#define BSD_SIGNATURE UINT32_C(0x82564557) /* BSD disklabel signature ("magic") */
#define LABEL_OFFSET1 64 /* BSD disklabels can start at one of these two */
#define LABEL_OFFSET2 512 /* values; check both for valid signatures */
@@ -36,33 +36,32 @@
enum BSDValidity {unknown, bsd_invalid, bsd};
// Data for a single BSD partition record
-struct BSDRecord { // the partition table
- uint32_t lengthLBA; // number of sectors in partition
- uint32_t firstLBA; // starting sector
- uint32_t fragSize; // filesystem basic fragment size
- uint8_t fsType; // filesystem type, see below
- uint8_t frag; // filesystem fragments per block
- uint16_t pcpg; /* filesystem cylinders per group */ // was u_uint16_t
+// Create entries for all fields, although we only use lengthLBA, firstLBA,
+// and fsType, to simplify loading the data from disk....
+struct BSDRecord { // the partition table
+ uint32_t lengthLBA; // number of sectors in partition
+ uint32_t firstLBA; // starting sector
+ uint32_t fragSize; // filesystem basic fragment size
+ uint8_t fsType; // filesystem type, see below
+ uint8_t frag; // filesystem fragments per block
+ uint16_t pcpg; // filesystem cylinders per group
};
// Full data in tweaked MBR format
class BSDData {
protected:
// We only need a few items from the main BSD disklabel data structure....
- uint32_t signature; // the magic number
- uint32_t sectorSize; // # of bytes per sector
- uint32_t signature2; // the magic number (again)
- uint16_t numParts; // number of partitions in table
- BSDRecord* partitions; // partition array
+ uint32_t signature; // the magic number
+ uint32_t sectorSize; // # of bytes per sector
+ uint32_t signature2; // the magic number (again)
+ uint16_t numParts; // number of partitions in table
+ BSDRecord* partitions; // partition array
// Above are basic BSD disklabel data; now add more stuff....
-// uint64_t offset; // starting point in blocks
- uint64_t labelStart; // BSD disklabel start point in bytes from firstLBA
- uint64_t labelFirstLBA; // first sector of BSD disklabel (partition or disk)
- uint64_t labelLastLBA; // final sector of BSD disklabel
-// char deviceFilename[256];
+ uint64_t labelFirstLBA; // first sector of BSD disklabel (partition or disk)
+ uint64_t labelLastLBA; // final sector of BSD disklabel
+ uint64_t labelStart; // BSD disklabel start point in bytes from labelFirstLBA
BSDValidity state;
-// struct BSDRecord* GetPartition(int i); // Return BSD partition
public:
BSDData(void);
~BSDData(void);
@@ -70,7 +69,6 @@
void ReadBSDData(int fd, uint64_t startSector, uint64_t endSector);
void ReverseMetaBytes(void);
void DisplayBSDData(void);
-// int ConvertBSDParts(struct GPTPartition gptParts[]);
int ShowState(void); // returns 1 if BSD disklabel detected
int IsDisklabel(void) {return (state == bsd);}