2 * volume_id - reads filesystem label and uuid
4 * Copyright (C) 2004 Kay Sievers <kay.sievers@vrfy.org>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation version 2 of the License.
26 #include "volume_id.h"
31 struct lvm1_super_block {
33 } __attribute__((packed));
35 struct lvm2_super_block {
41 } __attribute__((packed));
43 #define LVM1_SB_OFF 0x400
44 #define LVM1_MAGIC "HM"
46 int volume_id_probe_lvm1(struct volume_id *id, uint64_t off)
49 struct lvm1_super_block *lvm;
51 dbg("probing at offset 0x%llx", (unsigned long long) off);
53 buf = volume_id_get_buffer(id, off + LVM1_SB_OFF, 0x800);
57 lvm = (struct lvm1_super_block *) buf;
59 if (memcmp(lvm->id, LVM1_MAGIC, 2) != 0)
62 volume_id_set_usage(id, VOLUME_ID_RAID);
63 id->type = "LVM1_member";
68 #define LVM2_LABEL_ID "LABELONE"
69 #define LVM2LABEL_SCAN_SECTORS 4
71 int volume_id_probe_lvm2(struct volume_id *id, uint64_t off)
75 struct lvm2_super_block *lvm;
77 dbg("probing at offset 0x%llx", (unsigned long long) off);
79 buf = volume_id_get_buffer(id, off, LVM2LABEL_SCAN_SECTORS * 0x200);
84 for (soff = 0; soff < LVM2LABEL_SCAN_SECTORS * 0x200; soff += 0x200) {
85 lvm = (struct lvm2_super_block *) &buf[soff];
87 if (memcmp(lvm->id, LVM2_LABEL_ID, 8) == 0)
94 memcpy(id->type_version, lvm->type, 8);
95 volume_id_set_usage(id, VOLUME_ID_RAID);
96 id->type = "LVM2_member";