volume_id: LVM - add uuid
This commit is contained in:
committed by
Kay Sievers
parent
9e5920842b
commit
5caa40bea2
@@ -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)
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -71,7 +71,8 @@ enum uuid_format {
|
||||
UUID_DOS,
|
||||
UUID_64BIT_LE,
|
||||
UUID_64BIT_BE,
|
||||
UUID_FOURINT,
|
||||
UUID_MD,
|
||||
UUID_LVM,
|
||||
};
|
||||
|
||||
enum endian {
|
||||
|
||||
Reference in New Issue
Block a user