~ubuntu-branches/ubuntu/trusty/util-linux/trusty-proposed

« back to all changes in this revision

Viewing changes to shlibs/blkid/src/topology/evms.c

  • Committer: Package Import Robot
  • Author(s): LaMont Jones
  • Date: 2011-11-03 15:38:23 UTC
  • mto: (4.5.5 sid) (1.6.4)
  • mto: This revision was merged to the branch mainline in revision 85.
  • Revision ID: package-import@ubuntu.com-20111103153823-10sx16jprzxlhkqf
ImportĀ upstreamĀ versionĀ 2.20.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
 * Evms topology
3
 
 * -- this is fallback for old systems where the toplogy information is not
4
 
 *    exported by sysfs
5
 
 *
6
 
 * Copyright (C) 2009 Karel Zak <kzak@redhat.com>
7
 
 *
8
 
 * This file may be redistributed under the terms of the
9
 
 * GNU Lesser General Public License.
10
 
 *
11
 
 */
12
 
#include <errno.h>
13
 
#include <fcntl.h>
14
 
#include <stdint.h>
15
 
#include <stdio.h>
16
 
#include <stdlib.h>
17
 
#include <string.h>
18
 
#include <sys/ioctl.h>
19
 
#include <sys/stat.h>
20
 
#include <sys/types.h>
21
 
#include <unistd.h>
22
 
 
23
 
#include "topology.h"
24
 
 
25
 
#define EVMS_MAJOR              117
26
 
 
27
 
#ifndef _IOT__IOTBASE_u_int32_t
28
 
#define _IOT__IOTBASE_u_int32_t IOT_SIMPLE(uint32_t)
29
 
#endif
30
 
#define _IOT_evms_stripe_info _IOT (_IOTS(uint32_t), 2, 0, 0, 0, 0)
31
 
#define EVMS_GET_STRIPE_INFO    _IOR(EVMS_MAJOR, 0xF0, struct evms_stripe_info)
32
 
 
33
 
struct evms_stripe_info {
34
 
        uint32_t        size;           /* stripe unit 512-byte blocks */
35
 
        uint32_t        width;          /* the number of stripe members or RAID data disks */
36
 
} evms_stripe_info;
37
 
 
38
 
static int is_evms_device(dev_t devno)
39
 
{
40
 
        if (major(devno) == EVMS_MAJOR)
41
 
                return 1;
42
 
        return blkid_driver_has_major("evms", major(devno));
43
 
}
44
 
 
45
 
static int probe_evms_tp(blkid_probe pr, const struct blkid_idmag *mag)
46
 
{
47
 
        struct evms_stripe_info evms;
48
 
        dev_t devno = blkid_probe_get_devno(pr);
49
 
 
50
 
        if (!devno)
51
 
                goto nothing;           /* probably not a block device */
52
 
 
53
 
        if (!is_evms_device(devno))
54
 
                goto nothing;
55
 
 
56
 
        memset(&evms, 0, sizeof(evms));
57
 
 
58
 
        if (ioctl(pr->fd, EVMS_GET_STRIPE_INFO, &evms))
59
 
                goto nothing;
60
 
 
61
 
        blkid_topology_set_minimum_io_size(pr, evms.size << 9);
62
 
        blkid_topology_set_optimal_io_size(pr, (evms.size * evms.width) << 9);
63
 
 
64
 
        return 0;
65
 
 
66
 
nothing:
67
 
        return 1;
68
 
}
69
 
 
70
 
const struct blkid_idinfo evms_tp_idinfo =
71
 
{
72
 
        .name           = "evms",
73
 
        .probefunc      = probe_evms_tp,
74
 
        .magics         = BLKID_NONE_MAGIC
75
 
};
76