Lines 3-8
Link Here
|
3 |
* |
3 |
* |
4 |
* Copyright (C) 2005 Kay Sievers <kay.sievers@vrfy.org> |
4 |
* Copyright (C) 2005 Kay Sievers <kay.sievers@vrfy.org> |
5 |
* |
5 |
* |
|
|
6 |
* Based on information taken from dmraid: |
7 |
* Copyright (C) 2004-2006 Heinz Mauelshagen, Red Hat GmbH |
8 |
* |
6 |
* This program is free software; you can redistribute it and/or modify it |
9 |
* 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 |
10 |
* under the terms of the GNU General Public License as published by the |
8 |
* Free Software Foundation version 2 of the License. |
11 |
* Free Software Foundation version 2 of the License. |
Lines 31-37
Link Here
|
31 |
uint16_t signature; |
34 |
uint16_t signature; |
32 |
uint8_t version_number; |
35 |
uint8_t version_number; |
33 |
struct via_array { |
36 |
struct via_array { |
34 |
uint16_t disk_bits; |
37 |
uint16_t disk_bit_mask; |
35 |
uint8_t disk_array_ex; |
38 |
uint8_t disk_array_ex; |
36 |
uint32_t capacity_low; |
39 |
uint32_t capacity_low; |
37 |
uint32_t capacity_high; |
40 |
uint32_t capacity_high; |
Lines 43-48
Link Here
|
43 |
|
46 |
|
44 |
#define VIA_SIGNATURE 0xAA55 |
47 |
#define VIA_SIGNATURE 0xAA55 |
45 |
|
48 |
|
|
|
49 |
/* 8 bit checksum on first 50 bytes of metadata. */ |
50 |
static uint8_t meta_checksum(struct via_meta *via) |
51 |
{ |
52 |
uint8_t i = 50, sum = 0; |
53 |
|
54 |
while (i--) |
55 |
sum += ((uint8_t*) via)[i]; |
56 |
|
57 |
return sum == via->checksum; |
58 |
} |
59 |
|
46 |
int volume_id_probe_via_raid(struct volume_id *id, uint64_t off, uint64_t size) |
60 |
int volume_id_probe_via_raid(struct volume_id *id, uint64_t off, uint64_t size) |
47 |
{ |
61 |
{ |
48 |
const uint8_t *buf; |
62 |
const uint8_t *buf; |
Lines 68-73
Link Here
|
68 |
if (via->version_number > 1) |
82 |
if (via->version_number > 1) |
69 |
return -1; |
83 |
return -1; |
70 |
|
84 |
|
|
|
85 |
if (!meta_checksum(via)) |
86 |
return -1; |
87 |
|
71 |
volume_id_set_usage(id, VOLUME_ID_RAID); |
88 |
volume_id_set_usage(id, VOLUME_ID_RAID); |
72 |
snprintf(id->type_version, sizeof(id->type_version)-1, "%u", via->version_number); |
89 |
snprintf(id->type_version, sizeof(id->type_version)-1, "%u", via->version_number); |
73 |
id->type = "via_raid_member"; |
90 |
id->type = "via_raid_member"; |