/src/util-linux/libblkid/src/topology/evms.c
Line | Count | Source (jump to first uncovered line) |
1 | | /* |
2 | | * Evms topology |
3 | | * -- this is fallback for old systems where the topology 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 | 0 | #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 | 0 | #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 | | }; |
37 | | |
38 | | static int is_evms_device(dev_t devno) |
39 | 0 | { |
40 | 0 | if (major(devno) == EVMS_MAJOR) |
41 | 0 | return 1; |
42 | 0 | return blkid_driver_has_major("evms", major(devno)); |
43 | 0 | } |
44 | | |
45 | | static int probe_evms_tp(blkid_probe pr, |
46 | | const struct blkid_idmag *mag __attribute__((__unused__))) |
47 | 0 | { |
48 | 0 | struct evms_stripe_info evms; |
49 | 0 | dev_t devno = blkid_probe_get_devno(pr); |
50 | |
|
51 | 0 | if (!devno) |
52 | 0 | goto nothing; /* probably not a block device */ |
53 | | |
54 | 0 | if (!is_evms_device(devno)) |
55 | 0 | goto nothing; |
56 | | |
57 | 0 | memset(&evms, 0, sizeof(evms)); |
58 | |
|
59 | 0 | if (ioctl(pr->fd, EVMS_GET_STRIPE_INFO, &evms)) |
60 | 0 | goto nothing; |
61 | | |
62 | 0 | blkid_topology_set_minimum_io_size(pr, evms.size << 9); |
63 | 0 | blkid_topology_set_optimal_io_size(pr, (evms.size * evms.width) << 9); |
64 | |
|
65 | 0 | return 0; |
66 | | |
67 | 0 | nothing: |
68 | 0 | return 1; |
69 | 0 | } |
70 | | |
71 | | const struct blkid_idinfo evms_tp_idinfo = |
72 | | { |
73 | | .name = "evms", |
74 | | .probefunc = probe_evms_tp, |
75 | | .magics = BLKID_NONE_MAGIC |
76 | | }; |
77 | | |