Upload Tizen:Base source
[framework/base/util-linux-ng.git] / shlibs / blkid / src / probers / lsi_raid.c
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
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <unistd.h>
14 #include <string.h>
15 #include <stdint.h>
16
17 #include "blkidP.h"
18
19 struct lsi_metadata {
20         uint8_t         sig[6];
21 };
22
23
24 #define LSI_SIGNATURE           "$XIDE$"
25
26 static int probe_lsiraid(blkid_probe pr, const struct blkid_idmag *mag)
27 {
28         uint64_t off;
29         struct lsi_metadata *lsi;
30
31         if (pr->size < 0x10000)
32                 return -1;
33
34         off = ((pr->size / 0x200) - 1) * 0x200;
35         lsi = (struct lsi_metadata *)
36                 blkid_probe_get_buffer(pr,
37                                 off,
38                                 sizeof(struct lsi_metadata));
39         if (!lsi)
40                 return -1;
41
42         if (memcmp(lsi->sig, LSI_SIGNATURE, sizeof(LSI_SIGNATURE)-1) != 0)
43                 return -1;
44
45         return 0;
46 }
47
48 const struct blkid_idinfo lsiraid_idinfo = {
49         .name           = "lsi_mega_raid_member",
50         .usage          = BLKID_USAGE_RAID,
51         .probefunc      = probe_lsiraid,
52         .magics         = BLKID_NONE_MAGIC
53 };
54
55