blob: 56721dd71950604fa322de8ccef3c30bdf4a6c98 [file] [log] [blame]
bigbiff bigbiffe60683a2013-02-22 20:55:50 -05001/*
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
11#include <stdio.h>
12#include <stdlib.h>
13#include <unistd.h>
14#include <string.h>
15#include <stdint.h>
16
17#include "superblocks.h"
18
19struct lsi_metadata {
20 uint8_t sig[6];
21};
22
23
24#define LSI_SIGNATURE "$XIDE$"
25
26static int probe_lsiraid(blkid_probe pr,
27 const struct blkid_idmag *mag __attribute__((__unused__)))
28{
29 uint64_t off;
30 struct lsi_metadata *lsi;
31
32 if (pr->size < 0x10000)
33 return -1;
34 if (!S_ISREG(pr->mode) && !blkid_probe_is_wholedisk(pr))
35 return -1;
36
37 off = ((pr->size / 0x200) - 1) * 0x200;
38 lsi = (struct lsi_metadata *)
39 blkid_probe_get_buffer(pr,
40 off,
41 sizeof(struct lsi_metadata));
42 if (!lsi)
43 return -1;
44
45 if (memcmp(lsi->sig, LSI_SIGNATURE, sizeof(LSI_SIGNATURE)-1) != 0)
46 return -1;
47 if (blkid_probe_set_magic(pr, off, sizeof(lsi->sig),
48 (unsigned char *) lsi->sig))
49 return -1;
50 return 0;
51}
52
53const struct blkid_idinfo lsiraid_idinfo = {
54 .name = "lsi_mega_raid_member",
55 .usage = BLKID_USAGE_RAID,
56 .probefunc = probe_lsiraid,
57 .magics = BLKID_NONE_MAGIC
58};
59
60