summaryrefslogtreecommitdiff
path: root/util.c
diff options
context:
space:
mode:
authorNeilBrown <neilb@suse.de>2010-08-19 16:48:34 +1000
committerNeilBrown <neilb@suse.de>2010-09-06 11:26:28 +1000
commit0f22b998fb9cf8478810b89cd50fa5b4fbf11d38 (patch)
treea9c28e7b9b983519c83a6fafb638f48536b71683 /util.c
parent64436f0628a14f4e979b93bea57aba4b4c6143e8 (diff)
Add mbr pseudo metadata handler.
To support incorpating a new bare device into a collection of arrays - one partition each - mdadm needs a modest understanding of partition tables. The main needs to be able to recognise a partition table on one device and copy it onto another. This will be done using pseudo metadata types 'mbr' and 'gpt'. Signed-off-by: NeilBrown <neilb@suse.de>
Diffstat (limited to 'util.c')
-rw-r--r--util.c65
1 files changed, 7 insertions, 58 deletions
diff --git a/util.c b/util.c
index c9bdd6eb..c93b0a7a 100644
--- a/util.c
+++ b/util.c
@@ -65,55 +65,7 @@ struct blkpg_partition {
char volname[BLKPG_VOLNAMELTH]; /* volume label */
};
-/* partition table structures so we can check metadata position
- * against the end of the last partition.
- * Only handle MBR ant GPT partition tables.
- */
-struct MBR_part_record {
- __u8 bootable;
- __u8 first_head;
- __u8 first_sector;
- __u8 first_cyl;
- __u8 part_type;
- __u8 last_head;
- __u8 last_sector;
- __u8 last_cyl;
- __u32 first_sect_lba;
- __u32 blocks_num;
-};
-
-struct MBR {
- __u8 pad[446];
- struct MBR_part_record parts[4];
- __u16 magic;
-} __attribute__((packed));
-
-struct GPT_part_entry {
- unsigned char type_guid[16];
- unsigned char partition_guid[16];
- __u64 starting_lba;
- __u64 ending_lba;
- unsigned char attr_bits[8];
- unsigned char name[72];
-} __attribute__((packed));
-
-struct GPT {
- __u64 magic;
- __u32 revision;
- __u32 header_size;
- __u32 crc;
- __u32 pad1;
- __u64 current_lba;
- __u64 backup_lba;
- __u64 first_lba;
- __u64 last_lba;
- __u8 guid[16];
- __u64 part_start;
- __u32 part_cnt;
- __u32 part_size;
- __u32 part_crc;
- __u8 pad2[420];
-} __attribute__((packed));
+#include "part.h"
/* Force a compilation error if condition is true */
#define BUILD_BUG_ON(condition) ((void)BUILD_BUG_ON_ZERO(condition))
@@ -124,14 +76,6 @@ struct GPT {
aren't permitted). */
#define BUILD_BUG_ON_ZERO(e) (sizeof(struct { int:-!!(e); }))
-
-/* MBR/GPT magic numbers */
-#define MBR_SIGNATURE_MAGIC __cpu_to_le16(0xAA55)
-#define GPT_SIGNATURE_MAGIC __cpu_to_le64(0x5452415020494645ULL)
-
-#define MBR_PARTITIONS 4
-#define MBR_GPT_PARTITION_TYPE 0xEE
-
/*
* Parse a 128 bit uuid in 4 integers
* format is 32 hexx nibbles with options :.<space> separator
@@ -1049,7 +993,12 @@ void wait_for(char *dev, int fd)
dprintf("%s: timeout waiting for %s\n", __func__, dev);
}
-struct superswitch *superlist[] = { &super0, &super1, &super_ddf, &super_imsm, NULL };
+struct superswitch *superlist[] =
+{
+ &super0, &super1,
+ &super_ddf, &super_imsm,
+ &mbr,
+ NULL };
#if !defined(MDASSEMBLE) || defined(MDASSEMBLE) && defined(MDASSEMBLE_AUTO)