Upload Tizen:Base source
[framework/base/util-linux-ng.git] / shlibs / blkid / src / probers / promise_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 #include <stdio.h>
11 #include <stdlib.h>
12 #include <unistd.h>
13 #include <string.h>
14 #include <errno.h>
15 #include <ctype.h>
16 #include <stdint.h>
17
18 #include "blkidP.h"
19
20 struct promise_metadata {
21         uint8_t sig[24];
22 };
23
24 #define PDC_CONFIG_OFF          0x1200
25 #define PDC_SIGNATURE           "Promise Technology, Inc."
26
27 static int probe_pdcraid(blkid_probe pr, const struct blkid_idmag *mag)
28 {
29         unsigned int i;
30         static unsigned int sectors[] = {
31                 63, 255, 256, 16, 399, 0
32         };
33
34         if (pr->size < 0x40000)
35                 return -1;
36
37         for (i = 0; sectors[i] != 0; i++) {
38                 uint64_t off;
39                 struct promise_metadata *pdc;
40
41                 off = ((pr->size / 0x200) - sectors[i]) * 0x200;
42                 pdc = (struct promise_metadata *)
43                                 blkid_probe_get_buffer(pr,
44                                         off,
45                                         sizeof(struct promise_metadata));
46                 if (!pdc)
47                         return -1;
48
49                 if (memcmp(pdc->sig, PDC_SIGNATURE,
50                                 sizeof(PDC_SIGNATURE) - 1) == 0)
51                         return 0;
52         }
53         return -1;
54 }
55
56 const struct blkid_idinfo pdcraid_idinfo = {
57         .name           = "promise_fasttrack_raid_member",
58         .usage          = BLKID_USAGE_RAID,
59         .probefunc      = probe_pdcraid,
60         .magics         = BLKID_NONE_MAGIC
61 };
62
63