2 * volume_id - reads filesystem label and uuid
4 * Copyright (C) 2005 Kay Sievers <kay.sievers@vrfy.org>
6 * Based on information taken from dmraid:
7 * Copyright (C) 2004-2006 Heinz Mauelshagen, Red Hat GmbH
9 * This program is free software: you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation, either version 2 of the License, or
12 * (at your option) any later version.
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
19 * You should have received a copy of the GNU General Public License
20 * along with this program. If not, see <http://www.gnu.org/licenses/>.
34 #include "libvolume_id.h"
35 #include "libvolume_id-private.h"
39 uint8_t version_number;
41 uint16_t disk_bit_mask;
42 uint8_t disk_array_ex;
43 uint32_t capacity_low;
44 uint32_t capacity_high;
45 uint32_t serial_checksum;
47 uint32_t serial_checksum[8];
51 #define VIA_SIGNATURE 0xAA55
53 /* 8 bit checksum on first 50 bytes of metadata. */
54 static uint8_t meta_checksum(struct via_meta *via)
56 uint8_t i = 50, sum = 0;
59 sum += ((uint8_t*) via)[i];
61 return sum == via->checksum;
65 int volume_id_probe_via_raid(struct volume_id *id, uint64_t off, uint64_t size)
71 dbg("probing at offset 0x%llx, size 0x%llx\n",
72 (unsigned long long) off, (unsigned long long) size);
77 meta_off = ((size / 0x200)-1) * 0x200;
79 buf = volume_id_get_buffer(id, off + meta_off, 0x200);
83 via = (struct via_meta *) buf;
84 if (le16_to_cpu(via->signature) != VIA_SIGNATURE)
87 if (via->version_number > 1)
90 if (!meta_checksum(via))
93 volume_id_set_usage(id, VOLUME_ID_RAID);
94 snprintf(id->type_version, sizeof(id->type_version)-1, "%u", via->version_number);
95 id->type = "via_raid_member";