~pr0gg3d/ubuntu/oneiric/util-linux/bug-805886

« back to all changes in this revision

Viewing changes to libs/blkid/src/probers/adaptec_raid.c

  • Committer: Bazaar Package Importer
  • Author(s): Scott James Remnant
  • Date: 2009-07-16 15:48:23 UTC
  • mfrom: (1.3.7 upstream)
  • Revision ID: james.westby@ubuntu.com-20090716154823-i26fshvs4v8h90qh
Tags: 2.16-1ubuntu1
* Merge from Debian, remaining changes:
  - Since udev is required in Ubuntu, the hwclock.sh init script is
    not called on startup and the hwclockfirst.sh init script is
    removed.
  - Remove /etc/adjtime on upgrade if it was not used.
  - Install custom blkid.conf to use /dev/.blkid.tab since we don't
    expect device names to survive a reboot
  - No lsb_release call in mount.preinst since we'd need Pre-Depends
    (LP: #383697).

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