mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
lv_type: simplier macro usage
Use more simple macros - as there is likely not going to happen any macro replacement - so use more effient structure layout.
This commit is contained in:
parent
429ab45a1c
commit
5b7e30da76
@ -64,7 +64,8 @@ static const struct lv_prop lv_props[LVP_COUNT + 1] = {
|
||||
/* create table of lv type names, e.g. linear and corresponding enum from lv_types.h */
|
||||
|
||||
static const struct lv_type lv_types[LVT_COUNT + 1] = {
|
||||
#define lvt(a, b, c) { # a, a, b, c },
|
||||
{ "" },
|
||||
#define lvt(a) { # a, a ## _LVT },
|
||||
#include "lv_types.h"
|
||||
#undef lvt
|
||||
};
|
||||
|
@ -256,10 +256,8 @@ struct lv_prop {
|
||||
/* see global lv_types[] */
|
||||
|
||||
struct lv_type {
|
||||
const char enum_name[30]; /* "foo_LVT" */
|
||||
const char name[30]; /* "foo" */
|
||||
uint16_t lvt_enum; /* foo_LVT */
|
||||
const char name[32]; /* "foo" */
|
||||
int (*fn) (struct cmd_context *cmd, struct logical_volume *lv); /* lv_is_foo() */
|
||||
};
|
||||
|
||||
|
||||
|
@ -46,9 +46,11 @@ enum {
|
||||
|
||||
/* define enums for LV types, foo_LVT */
|
||||
enum {
|
||||
#define lvt(a, b, c) a ,
|
||||
LVT_NONE,
|
||||
#define lvt(a) a ## _LVT ,
|
||||
#include "lv_types.h"
|
||||
#undef lvt
|
||||
LVT_COUNT
|
||||
};
|
||||
|
||||
enum {
|
||||
|
@ -1,39 +1,44 @@
|
||||
|
||||
/*
|
||||
* Copyright (C) 2016-2024 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License v.2.1.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
/*
|
||||
* LV types used in command definitions. The type strings are used
|
||||
* as LV suffixes, e.g. LV_type or LV_type1_type2.
|
||||
*
|
||||
* The final NULL arg can be replaced with lv_is_type() functions
|
||||
* if the current lv_is_type #defines become functions and are
|
||||
* moved to tools.h
|
||||
*
|
||||
* Until then, the lv_is_type() functions are called indirectly
|
||||
* through _lv_is_type().
|
||||
* Update toollib.c:_lv_is_type() when adding new XXXXX_LVT test
|
||||
*/
|
||||
|
||||
lvt(LVT_NONE, "", NULL)
|
||||
lvt(linear_LVT, "linear", NULL)
|
||||
lvt(striped_LVT, "striped", NULL)
|
||||
lvt(snapshot_LVT, "snapshot", NULL) /* lv_is_cow, lv_is_thick_snapshot */
|
||||
lvt(thin_LVT, "thin", NULL)
|
||||
lvt(thinpool_LVT, "thinpool", NULL)
|
||||
lvt(cache_LVT, "cache", NULL)
|
||||
lvt(cachepool_LVT, "cachepool", NULL)
|
||||
lvt(vdo_LVT, "vdo", NULL)
|
||||
lvt(vdopool_LVT, "vdopool", NULL)
|
||||
lvt(vdopooldata_LVT, "vdopooldata", NULL)
|
||||
lvt(mirror_LVT, "mirror", NULL)
|
||||
lvt(raid_LVT, "raid", NULL) /* any raid type */
|
||||
lvt(raid0_LVT, "raid0", NULL)
|
||||
lvt(raid1_LVT, "raid1", NULL)
|
||||
lvt(raid4_LVT, "raid4", NULL)
|
||||
lvt(raid5_LVT, "raid5", NULL)
|
||||
lvt(raid6_LVT, "raid6", NULL)
|
||||
lvt(raid10_LVT, "raid10", NULL)
|
||||
lvt(error_LVT, "error", NULL)
|
||||
lvt(zero_LVT, "zero", NULL)
|
||||
lvt(writecache_LVT, "writecache", NULL)
|
||||
lvt(integrity_LVT, "integrity", NULL)
|
||||
lvt(LVT_COUNT, "", NULL)
|
||||
|
||||
/* enum value 0 means none */
|
||||
lvt(linear)
|
||||
lvt(striped)
|
||||
lvt(snapshot) /* lv_is_cow, lv_is_thick_snapshot */
|
||||
lvt(thin)
|
||||
lvt(thinpool)
|
||||
lvt(cache)
|
||||
lvt(cachepool)
|
||||
lvt(vdo)
|
||||
lvt(vdopool)
|
||||
lvt(vdopooldata)
|
||||
lvt(mirror)
|
||||
lvt(raid) /* any raid type */
|
||||
lvt(raid0)
|
||||
lvt(raid1)
|
||||
lvt(raid4)
|
||||
lvt(raid5)
|
||||
lvt(raid6)
|
||||
lvt(raid10)
|
||||
lvt(writecache)
|
||||
lvt(integrity)
|
||||
lvt(error)
|
||||
lvt(zero)
|
||||
|
@ -2933,10 +2933,7 @@ static int _lv_types_match(struct cmd_context *cmd, struct logical_volume *lv, u
|
||||
* in tools.h
|
||||
*/
|
||||
|
||||
if (!type->fn)
|
||||
match = _lv_is_type(cmd, lv, lvt_enum);
|
||||
else
|
||||
match = type->fn(cmd, lv);
|
||||
match = _lv_is_type(cmd, lv, lvt_enum);
|
||||
|
||||
if (match)
|
||||
found_a_match = 1;
|
||||
|
Loading…
Reference in New Issue
Block a user