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

« back to all changes in this revision

Viewing changes to libs/blkid/src/probers/nvidia_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
 
 * Copyright (C) 2005 Kay Sievers <kay.sievers@vrfy.org>
4
 
 *
5
 
 * Inspired by libvolume_id by
6
 
 *     Kay Sievers <kay.sievers@vrfy.org>
7
 
 *
8
 
 * This file may be redistributed under the terms of the
9
 
 * GNU Lesser General Public License.
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 nv_metadata {
20
 
        uint8_t         vendor[8];
21
 
        uint32_t        size;
22
 
        uint32_t        chksum;
23
 
        uint16_t        version;
24
 
};
25
 
 
26
 
#define NVIDIA_SIGNATURE                "NVIDIA"
27
 
 
28
 
static int probe_nvraid(blkid_probe pr, const struct blkid_idmag *mag)
29
 
{
30
 
        uint64_t off;
31
 
        struct nv_metadata *nv;
32
 
 
33
 
        if (pr->size < 0x10000)
34
 
                return -1;
35
 
 
36
 
        off = ((pr->size / 0x200) - 2) * 0x200;
37
 
        nv = (struct nv_metadata *)
38
 
                blkid_probe_get_buffer(pr,
39
 
                                off,
40
 
                                sizeof(struct nv_metadata));
41
 
        if (!nv)
42
 
                return -1;
43
 
 
44
 
        if (memcmp(nv->vendor, NVIDIA_SIGNATURE, sizeof(NVIDIA_SIGNATURE)-1) != 0)
45
 
                return -1;
46
 
 
47
 
        if (blkid_probe_sprintf_version(pr, "%u", le16_to_cpu(nv->version)) != 0)
48
 
                return -1;
49
 
 
50
 
        return 0;
51
 
}
52
 
 
53
 
const struct blkid_idinfo nvraid_idinfo = {
54
 
        .name           = "nvidia_raid_member",
55
 
        .usage          = BLKID_USAGE_RAID,
56
 
        .probefunc      = probe_nvraid,
57
 
        .magics         = BLKID_NONE_MAGIC
58
 
};
59
 
 
60