~ubuntu-branches/ubuntu/precise/util-linux/precise

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Steve Langasek
  • Date: 2011-12-16 22:53:42 UTC
  • mfrom: (1.6.4) (4.5.5 sid)
  • Revision ID: package-import@ubuntu.com-20111216225342-206wz4bhvutyvx0d
Tags: 2.20.1-1ubuntu1
* Merge from Debian unstable, remaining changes:
  - Build for multiarch.
  - Add pre-depends on multiarch-support.
  - configure.ac: don't try to be clever about extracting a path name from
    $libdir to append to /usr in a way that's not overridable; instead,
    reuse the built-in configurable libexecdir.
  - Fix up the .pc.in files to know about libexecdir, so our substitutions
    don't leave us with unusable pkg-config files.
  - Install custom blkid.conf to use /dev/.blkid.tab since we don't
    expect device names to survive a reboot
  - Mention mountall(8) in fstab(5) manpages, along with its special
    options.
  - Since upstart is required in Ubuntu, the hwclock.sh init script is not
    called on startup and the hwclockfirst.sh init script is removed.
  - Drop depends on initscripts for the above.
  - Replace hwclock udev rule with an Upstart job.
  - For the case where mount is called with a directory to mount, look
    that directory up in mountall's /lib/init/fstab if we couldn't find
    it mentioned anywhere else.  This means "mount /proc", "mount /sys",
    etc. work.
  - mount.8 points to the cifs-utils package, not the obsolete smbfs one. 
  - Use canonicalize_spec in getmntdevbackward. proc should not be
    interpreted as a non-canonical-path.
* Dropped changes, superseded upstream:
  - shlibs/mount/src/tab_update.c: don't refuse to update mtab when source
    is 'none'.

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