From c9e4a61574ac5113ed58751c96920a81bff39c67 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Mon, 21 Sep 2009 15:32:09 +0200 Subject: [PATCH] libblkid: add EVMS topology support (for old kernels) Signed-off-by: Karel Zak --- shlibs/blkid/src/topology/Makefile.am | 3 +- shlibs/blkid/src/topology/evms.c | 73 +++++++++++++++++++++++++++ shlibs/blkid/src/topology/topology.c | 3 +- shlibs/blkid/src/topology/topology.h | 1 + 4 files changed, 78 insertions(+), 2 deletions(-) create mode 100644 shlibs/blkid/src/topology/evms.c diff --git a/shlibs/blkid/src/topology/Makefile.am b/shlibs/blkid/src/topology/Makefile.am index 06927b28..ffaf58dc 100644 --- a/shlibs/blkid/src/topology/Makefile.am +++ b/shlibs/blkid/src/topology/Makefile.am @@ -8,4 +8,5 @@ libblkid_topology_la_SOURCES = topology.c \ topology.h \ sysfs.c \ md.c \ - dm.c + dm.c \ + evms.c diff --git a/shlibs/blkid/src/topology/evms.c b/shlibs/blkid/src/topology/evms.c new file mode 100644 index 00000000..9f6c48df --- /dev/null +++ b/shlibs/blkid/src/topology/evms.c @@ -0,0 +1,73 @@ +/* + * Evms topology + * -- this is fallback for old systems where the toplogy information are not + * exporte dy sysfs + * + * Copyright (C) 2009 Karel Zak + * + * This file may be redistributed under the terms of the + * GNU Lesser General Public License. + * + */ +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "topology.h" + +#define EVMS_MAJOR 117 +#define EVMS_GET_STRIPE_INFO _IOR(EVMS_MAJOR, 0xF0, struct evms_stripe_info) + +struct evms_stripe_info { + u_int32_t size; /* stripe unit 512-byte blocks */ + u_int32_t width; /* the number of stripe members or RAID data disks */ +} evms_stripe_info; + +static int is_evms_device(dev_t devno) +{ + if (major(devno) == EVMS_MAJOR) + return 1; + if (blkid_driver_has_major("evms", major(devno))) + return 1; + return 0; +} + +static int probe_evms_tp(blkid_probe pr, const struct blkid_idmag *mag) +{ + struct evms_stripe_info evms; + dev_t devno = blkid_probe_get_devno(pr); + + if (!devno) + goto nothing; /* probably not a block device */ + + if (!is_evms_device(devno)) + goto nothing; + + memset(&evms, 0, sizeof(evms)); + + if (ioctl(pr->fd, EVMS_GET_STRIPE_INFO, &evms)) + goto nothing; + + blkid_topology_set_minimum_io_size(pr, evms.size << 9); + blkid_topology_set_optimal_io_size(pr, (evms.size * evms.width) << 9); + + return 0; + +nothing: + return 1; +} + +const struct blkid_idinfo evms_tp_idinfo = +{ + .name = "evms", + .probefunc = probe_evms_tp, + .magics = BLKID_NONE_MAGIC +}; + diff --git a/shlibs/blkid/src/topology/topology.c b/shlibs/blkid/src/topology/topology.c index d6132a8f..ab2ecd0d 100644 --- a/shlibs/blkid/src/topology/topology.c +++ b/shlibs/blkid/src/topology/topology.c @@ -61,7 +61,8 @@ static const struct blkid_idinfo *idinfos[] = { &sysfs_tp_idinfo, &md_tp_idinfo, - &dm_tp_idinfo + &dm_tp_idinfo, + &evms_tp_idinfo }; diff --git a/shlibs/blkid/src/topology/topology.h b/shlibs/blkid/src/topology/topology.h index 8cfcaf98..48d3f26f 100644 --- a/shlibs/blkid/src/topology/topology.h +++ b/shlibs/blkid/src/topology/topology.h @@ -13,6 +13,7 @@ extern int blkid_topology_set_optimal_io_size(blkid_probe pr, unsigned long val) extern const struct blkid_idinfo sysfs_tp_idinfo; extern const struct blkid_idinfo md_tp_idinfo; extern const struct blkid_idinfo dm_tp_idinfo; +extern const struct blkid_idinfo evms_tp_idinfo; #endif /* BLKID_TOPOLOGY_H */ -- 2.39.5