summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHannes Reinecke <hare@suse.de>2007-12-16 19:22:32 +0100
committerKay Sievers <kay.sievers@vrfy.org>2007-12-16 19:22:32 +0100
commit5caa40bea22b9ac07dbe667985d1b8556d8b6b80 (patch)
tree1a05b3c754ab03d5b0e2bd4a29c89ae8bb1a3ea8
parent9e5920842b0b414e78b04ddd40fb4cf29b0d855c (diff)
volume_id: LVM - add uuid
-rw-r--r--extras/volume_id/lib/Makefile2
-rw-r--r--extras/volume_id/lib/linux_raid.c6
-rw-r--r--extras/volume_id/lib/lvm.c11
-rw-r--r--extras/volume_id/lib/util.c18
-rw-r--r--extras/volume_id/lib/util.h3
5 files changed, 33 insertions, 7 deletions
diff --git a/extras/volume_id/lib/Makefile b/extras/volume_id/lib/Makefile
index b206854f55..925eff9f98 100644
--- a/extras/volume_id/lib/Makefile
+++ b/extras/volume_id/lib/Makefile
@@ -13,7 +13,7 @@ INSTALL_DATA = ${INSTALL} -m 644
INSTALL_LIB = ${INSTALL} -m 755
SHLIB_CUR = 0
-SHLIB_REV = 81
+SHLIB_REV = 82
SHLIB_AGE = 0
SHLIB = libvolume_id.so.$(SHLIB_CUR).$(SHLIB_REV).$(SHLIB_AGE)
diff --git a/extras/volume_id/lib/linux_raid.c b/extras/volume_id/lib/linux_raid.c
index 3c2e86e422..5e0c4a494f 100644
--- a/extras/volume_id/lib/linux_raid.c
+++ b/extras/volume_id/lib/linux_raid.c
@@ -87,7 +87,7 @@ static int volume_id_probe_linux_raid0(struct volume_id *id, uint64_t off, uint6
uuid.ints[2] = 0;
uuid.ints[3] = 0;
}
- volume_id_set_uuid(id, uuid.bytes, 0, UUID_FOURINT);
+ volume_id_set_uuid(id, uuid.bytes, 0, UUID_MD);
snprintf(id->type_version, sizeof(id->type_version)-1, "%u.%u.%u",
le32_to_cpu(mdp0->major_version),
le32_to_cpu(mdp0->minor_version),
@@ -103,7 +103,7 @@ static int volume_id_probe_linux_raid0(struct volume_id *id, uint64_t off, uint6
uuid.ints[2] = 0;
uuid.ints[3] = 0;
}
- volume_id_set_uuid(id, uuid.bytes, 0, UUID_FOURINT);
+ volume_id_set_uuid(id, uuid.bytes, 0, UUID_MD);
snprintf(id->type_version, sizeof(id->type_version)-1, "%u.%u.%u",
be32_to_cpu(mdp0->major_version),
be32_to_cpu(mdp0->minor_version),
@@ -134,7 +134,7 @@ static int volume_id_probe_linux_raid1(struct volume_id *id, uint64_t off, uint6
if (le32_to_cpu(mdp1->major_version) != 1)
return -1;
- volume_id_set_uuid(id, mdp1->set_uuid, 0, UUID_FOURINT);
+ volume_id_set_uuid(id, mdp1->set_uuid, 0, UUID_MD);
volume_id_set_label_raw(id, mdp1->set_name, 32);
volume_id_set_label_string(id, mdp1->set_name, 32);
volume_id_set_usage(id, VOLUME_ID_RAID);
diff --git a/extras/volume_id/lib/lvm.c b/extras/volume_id/lib/lvm.c
index 9c83c55307..7c4f81131c 100644
--- a/extras/volume_id/lib/lvm.c
+++ b/extras/volume_id/lib/lvm.c
@@ -38,6 +38,11 @@ struct lvm2_super_block {
uint8_t type[8];
} PACKED;
+struct lvm2_pv_header {
+ uint8_t id[32];
+ uint64_t devsize_xl;
+} PACKED;
+
#define LVM1_SB_OFF 0x400
#define LVM1_MAGIC "HM"
@@ -71,6 +76,7 @@ int volume_id_probe_lvm2(struct volume_id *id, uint64_t off, uint64_t size)
const uint8_t *buf;
unsigned int soff;
struct lvm2_super_block *lvm;
+ struct lvm2_pv_header *pvhdr;
dbg("probing at offset 0x%llx", (unsigned long long) off);
@@ -89,8 +95,13 @@ int volume_id_probe_lvm2(struct volume_id *id, uint64_t off, uint64_t size)
return -1;
found:
+ dbg("found at offset 0x%x (pv hdr offset 0x%x)",
+ soff, cpu_to_le32(lvm->offset_xl));
+ soff += cpu_to_le32(lvm->offset_xl);
+ pvhdr = (struct lvm2_pv_header *) &buf[soff];
memcpy(id->type_version, lvm->type, 8);
volume_id_set_usage(id, VOLUME_ID_RAID);
+ volume_id_set_uuid(id, pvhdr->id, 0, UUID_LVM);
id->type = "LVM2_member";
return 0;
diff --git a/extras/volume_id/lib/util.c b/extras/volume_id/lib/util.c
index 395e81bbf3..c094661ccc 100644
--- a/extras/volume_id/lib/util.c
+++ b/extras/volume_id/lib/util.c
@@ -274,9 +274,12 @@ void volume_id_set_uuid(struct volume_id *id, const uint8_t *buf, size_t len, en
case UUID_DCE:
count = 16;
break;
- case UUID_FOURINT:
+ case UUID_MD:
count = 35;
break;
+ case UUID_LVM:
+ count = 32;
+ break;
}
memcpy(id->uuid_raw, buf, count);
id->uuid_raw_len = count;
@@ -324,7 +327,7 @@ set:
memcpy(id->uuid, buf, count);
id->uuid[count] = '\0';
break;
- case UUID_FOURINT:
+ case UUID_MD:
sprintf(id->uuid,
"%02x%02x%02x%02x:%02x%02x%02x%02x:%02x%02x%02x%02x:%02x%02x%02x%02x",
buf[0], buf[1], buf[2], buf[3],
@@ -332,6 +335,17 @@ set:
buf[8], buf[9], buf[10], buf[11],
buf[12], buf[13], buf[14],buf[15]);
break;
+ case UUID_LVM:
+ sprintf(id->uuid,
+ "%c%c%c%c%c%c-%c%c%c%c-%c%c%c%c-%c%c%c%c-%c%c%c%c-%c%c%c%c-%c%c%c%c%c%c",
+ buf[0], buf[1], buf[2], buf[3], buf[4], buf[5],
+ buf[6], buf[7], buf[8], buf[9],
+ buf[10], buf[11], buf[12], buf[13],
+ buf[14], buf[15], buf[16], buf[17],
+ buf[18], buf[19], buf[20], buf[21],
+ buf[22], buf[23], buf[24], buf[25],
+ buf[26], buf[27], buf[28], buf[29], buf[30], buf[31]);
+ break;
}
}
diff --git a/extras/volume_id/lib/util.h b/extras/volume_id/lib/util.h
index 14a76c8fd2..e3c766d4ab 100644
--- a/extras/volume_id/lib/util.h
+++ b/extras/volume_id/lib/util.h
@@ -71,7 +71,8 @@ enum uuid_format {
UUID_DOS,
UUID_64BIT_LE,
UUID_64BIT_BE,
- UUID_FOURINT,
+ UUID_MD,
+ UUID_LVM,
};
enum endian {