/src/util-linux/libblkid/src/superblocks/isw_raid.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright (C) 2008 Karel Zak <kzak@redhat.com> |
3 | | * |
4 | | * Inspired by libvolume_id by |
5 | | * Kay Sievers <kay.sievers@vrfy.org> |
6 | | * |
7 | | * This file may be redistributed under the terms of the |
8 | | * GNU Lesser General Public License. |
9 | | */ |
10 | | #include <stdio.h> |
11 | | #include <stdlib.h> |
12 | | #include <unistd.h> |
13 | | #include <string.h> |
14 | | #include <stdint.h> |
15 | | |
16 | | #include "superblocks.h" |
17 | | |
18 | | struct isw_metadata { |
19 | | uint8_t sig[32]; |
20 | | uint32_t check_sum; |
21 | | uint32_t mpb_size; |
22 | | uint32_t family_num; |
23 | | uint32_t generation_num; |
24 | | }; |
25 | | |
26 | 11.4k | #define ISW_SIGNATURE "Intel Raid ISM Cfg Sig. " |
27 | | |
28 | | static int probe_iswraid(blkid_probe pr, |
29 | | const struct blkid_idmag *mag __attribute__((__unused__))) |
30 | 5.74k | { |
31 | 5.74k | uint64_t off; |
32 | 5.74k | unsigned int sector_size; |
33 | 5.74k | struct isw_metadata *isw; |
34 | | |
35 | 5.74k | if (!S_ISREG(pr->mode) && !blkid_probe_is_wholedisk(pr)) |
36 | 0 | return 1; |
37 | | |
38 | 5.74k | sector_size = blkid_probe_get_sectorsize(pr); |
39 | 5.74k | off = ((pr->size / sector_size) - 2) * sector_size; |
40 | | |
41 | 5.74k | isw = (struct isw_metadata *)blkid_probe_get_buffer(pr, |
42 | 5.74k | off, sizeof(struct isw_metadata)); |
43 | 5.74k | if (!isw) |
44 | 0 | return errno ? -errno : 1; |
45 | | |
46 | 5.74k | if (memcmp(isw->sig, ISW_SIGNATURE, sizeof(ISW_SIGNATURE)-1) != 0) |
47 | 5.74k | return 1; |
48 | | |
49 | 0 | if (blkid_probe_sprintf_version(pr, "%6s", |
50 | 0 | &isw->sig[sizeof(ISW_SIGNATURE)-1]) != 0) |
51 | 0 | return 1; |
52 | 0 | if (blkid_probe_set_magic(pr, off, sizeof(isw->sig), |
53 | 0 | (unsigned char *) isw->sig)) |
54 | 0 | return 1; |
55 | 0 | return 0; |
56 | 0 | } |
57 | | |
58 | | const struct blkid_idinfo iswraid_idinfo = { |
59 | | .name = "isw_raid_member", |
60 | | .usage = BLKID_USAGE_RAID, |
61 | | .minsz = 0x10000, |
62 | | .probefunc = probe_iswraid, |
63 | | .magics = BLKID_NONE_MAGIC |
64 | | }; |
65 | | |
66 | | |