~ubuntu-branches/ubuntu/lucid/loop-aes-utils/lucid-security

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Max Vozeler
  • Date: 2009-07-06 02:08:18 UTC
  • mfrom: (1.3.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090706020818-11pxao7bhgjenfv9
Tags: 2.15.1~rc1-2
Disable ncurses (--without-ncurses), not used in
mount/. Fixes FTBFS (closes: #535676).

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
 
 
11
#include <stdio.h>
 
12
#include <stdlib.h>
 
13
#include <unistd.h>
 
14
#include <string.h>
 
15
#include <stdint.h>
 
16
 
 
17
#include "blkidP.h"
 
18
 
 
19
struct jm_metadata {
 
20
        int8_t          signature[2];
 
21
        uint8_t         minor_version;
 
22
        uint8_t         major_version;
 
23
        uint16_t        checksum;
 
24
};
 
25
 
 
26
#define JM_SIGNATURE            "JM"
 
27
 
 
28
static int probe_jmraid(blkid_probe pr, const struct blkid_idmag *mag)
 
29
{
 
30
        uint64_t off;
 
31
        struct jm_metadata *jm;
 
32
 
 
33
        if (pr->size < 0x10000)
 
34
                return -1;
 
35
 
 
36
        off = ((pr->size / 0x200) - 1) * 0x200;
 
37
        jm = (struct jm_metadata *)
 
38
                blkid_probe_get_buffer(pr,
 
39
                                off,
 
40
                                sizeof(struct jm_metadata));
 
41
        if (!jm)
 
42
                return -1;
 
43
        if (memcmp(jm->signature, JM_SIGNATURE, sizeof(JM_SIGNATURE) - 1) != 0)
 
44
                return -1;
 
45
        if (blkid_probe_sprintf_version(pr, "%u.%u",
 
46
                                jm->major_version, jm->minor_version) != 0)
 
47
                return -1;
 
48
 
 
49
        return 0;
 
50
}
 
51
 
 
52
const struct blkid_idinfo jmraid_idinfo = {
 
53
        .name           = "jmicron_raid_member",
 
54
        .usage          = BLKID_USAGE_RAID,
 
55
        .probefunc      = probe_jmraid,
 
56
        .magics         = BLKID_NONE_MAGIC
 
57
};
 
58
 
 
59