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

« back to all changes in this revision

Viewing changes to shlibs/blkid/src/probers/highpoint_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 hpt45x_metadata {
 
19
        uint32_t        magic;
 
20
};
 
21
 
 
22
#define HPT45X_MAGIC_OK                 0x5a7816f3
 
23
#define HPT45X_MAGIC_BAD                0x5a7816fd
 
24
 
 
25
static int probe_highpoint45x(blkid_probe pr, const struct blkid_idmag *mag)
 
26
{
 
27
        struct hpt45x_metadata *hpt;
 
28
        uint64_t off;
 
29
        uint32_t magic;
 
30
 
 
31
        if (pr->size < 0x10000)
 
32
                return -1;
 
33
 
 
34
        off = ((pr->size / 0x200) - 11) * 0x200;
 
35
        hpt = (struct hpt45x_metadata *)
 
36
                        blkid_probe_get_buffer(pr,
 
37
                                        off,
 
38
                                        sizeof(struct hpt45x_metadata));
 
39
        if (!hpt)
 
40
                return -1;
 
41
        magic = le32_to_cpu(hpt->magic);
 
42
        if (magic != HPT45X_MAGIC_OK && magic != HPT45X_MAGIC_BAD)
 
43
                return -1;
 
44
        return 0;
 
45
}
 
46
 
 
47
const struct blkid_idinfo highpoint45x_idinfo = {
 
48
        .name           = "highpoint_raid_member",
 
49
        .usage          = BLKID_USAGE_RAID,
 
50
        .probefunc      = probe_highpoint45x,
 
51
        .magics         = BLKID_NONE_MAGIC
 
52
};
 
53
 
 
54
const struct blkid_idinfo highpoint37x_idinfo = {
 
55
        .name           = "highpoint_raid_member",
 
56
        .usage          = BLKID_USAGE_RAID,
 
57
        .magics         = {
 
58
                { .magic = "\xf0\x16\x78\x5a", .len = 4, .kboff = 4 },
 
59
                { .magic = "\xfd\x16\x78\x5a", .len = 4, .kboff = 4 },
 
60
                { NULL }
 
61
        }
 
62
};
 
63
 
 
64