~ubuntu-branches/ubuntu/trusty/util-linux/trusty-proposed

« back to all changes in this revision

Viewing changes to shlibs/blkid/src/superblocks/adaptec_raid.c

  • Committer: Package Import Robot
  • Author(s): LaMont Jones
  • Date: 2011-11-03 15:38:23 UTC
  • mto: (4.5.5 sid) (1.6.4)
  • mto: This revision was merged to the branch mainline in revision 85.
  • Revision ID: package-import@ubuntu.com-20111103153823-10sx16jprzxlhkqf
ImportĀ upstreamĀ versionĀ 2.20.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
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 adaptec_metadata {
19
 
 
20
 
        uint32_t        b0idcode;
21
 
        uint8_t         lunsave[8];
22
 
        uint16_t        sdtype;
23
 
        uint16_t        ssavecyl;
24
 
        uint8_t         ssavehed;
25
 
        uint8_t         ssavesec;
26
 
        uint8_t         sb0flags;
27
 
        uint8_t         jbodEnable;
28
 
        uint8_t         lundsave;
29
 
        uint8_t         svpdirty;
30
 
        uint16_t        biosInfo;
31
 
        uint16_t        svwbskip;
32
 
        uint16_t        svwbcln;
33
 
        uint16_t        svwbmax;
34
 
        uint16_t        res3;
35
 
        uint16_t        svwbmin;
36
 
        uint16_t        res4;
37
 
        uint16_t        svrcacth;
38
 
        uint16_t        svwcacth;
39
 
        uint16_t        svwbdly;
40
 
        uint8_t         svsdtime;
41
 
        uint8_t         res5;
42
 
        uint16_t        firmval;
43
 
        uint16_t        firmbln;
44
 
        uint32_t        firmblk;
45
 
        uint32_t        fstrsvrb;
46
 
        uint16_t        svBlockStorageTid;
47
 
        uint16_t        svtid;
48
 
        uint8_t         svseccfl;
49
 
        uint8_t         res6;
50
 
        uint8_t         svhbanum;
51
 
        uint8_t         resver;
52
 
        uint32_t        drivemagic;
53
 
        uint8_t         reserved[20];
54
 
        uint8_t         testnum;
55
 
        uint8_t         testflags;
56
 
        uint16_t        maxErrorCount;
57
 
        uint32_t        count;
58
 
        uint32_t        startTime;
59
 
        uint32_t        interval;
60
 
        uint8_t         tstxt0;
61
 
        uint8_t         tstxt1;
62
 
        uint8_t         serNum[32];
63
 
        uint8_t         res8[102];
64
 
        uint32_t        fwTestMagic;
65
 
        uint32_t        fwTestSeqNum;
66
 
        uint8_t         fwTestRes[8];
67
 
        uint32_t        smagic;
68
 
        uint32_t        raidtbl;
69
 
        uint16_t        raidline;
70
 
        uint8_t         res9[0xF6];
71
 
} __attribute__((packed));
72
 
 
73
 
#define AD_SIGNATURE    0x4450544D      /* "DPTM" */
74
 
#define AD_MAGIC        0x37FC4D1E
75
 
 
76
 
static int probe_adraid(blkid_probe pr, const struct blkid_idmag *mag)
77
 
{
78
 
        uint64_t off;
79
 
        struct adaptec_metadata *ad;
80
 
 
81
 
        if (pr->size < 0x10000)
82
 
                return -1;
83
 
 
84
 
        if (!S_ISREG(pr->mode) && !blkid_probe_is_wholedisk(pr))
85
 
                return -1;
86
 
 
87
 
        off = ((pr->size / 0x200)-1) * 0x200;
88
 
        ad = (struct adaptec_metadata *)
89
 
                        blkid_probe_get_buffer(pr,
90
 
                                        off,
91
 
                                        sizeof(struct adaptec_metadata));
92
 
        if (!ad)
93
 
                return -1;
94
 
        if (ad->smagic != be32_to_cpu(AD_SIGNATURE))
95
 
                return -1;
96
 
        if (ad->b0idcode != be32_to_cpu(AD_MAGIC))
97
 
                return -1;
98
 
        if (blkid_probe_sprintf_version(pr, "%u", ad->resver) != 0)
99
 
                return -1;
100
 
        if (blkid_probe_set_magic(pr, off, sizeof(ad->b0idcode),
101
 
                                (unsigned char *) &ad->b0idcode))
102
 
                return -1;
103
 
        return 0;
104
 
}
105
 
 
106
 
const struct blkid_idinfo adraid_idinfo = {
107
 
        .name           = "adaptec_raid_member",
108
 
        .usage          = BLKID_USAGE_RAID,
109
 
        .probefunc      = probe_adraid,
110
 
        .magics         = BLKID_NONE_MAGIC
111
 
};
112
 
 
113