lib/properties: Common code for handling properties.
PATCH 1/2 lib/properties: Common code for handling properties.
The common bits from lib/report/properties.[c|h] have been moved to lib/properties/prop_common.[c|h] to allow re-use of property handling functionality without polluting the report handling functionality.
--- include/.symlinks.in | 1 + lib/Makefile.in | 3 +- lib/properties/prop_common.c | 92 ++++++++++++ lib/properties/prop_common.h | 121 ++++++++++++++++ lib/report/columns.h | 43 +----- lib/report/properties.c | 326 +++++++++++++++---------------------------- lib/report/properties.h | 17 +-- 7 files changed, 328 insertions(+), 275 deletions(-) create mode 100644 lib/properties/prop_common.c create mode 100644 lib/properties/prop_common.h
include/.symlinks.in +1 -0
@@ -58,6 +58,7 @@ @top_srcdir@/lib/misc/lvm-wrappers.h @top_srcdir@/lib/misc/lvm-percent.h @top_srcdir@/lib/misc/sharedlib.h + at top_srcdir@/lib/properties/prop_common.h @top_srcdir@/lib/report/properties.h @top_srcdir@/lib/report/report.h @top_srcdir@/lib/uuid/uuid.h
lib/Makefile.in +2 -1
@@ -1,6 +1,6 @@ # # Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. -# Copyright (C) 2004-2011 Red Hat, Inc. All rights reserved. +# Copyright (C) 2004-2013 Red Hat, Inc. All rights reserved. # # This file is part of LVM2. #
@@ -104,6 +104,7 @@ SOURCES =\ misc/lvm-wrappers.c \ misc/lvm-percent.c \ mm/memlock.c \ + properties/prop_common.c \ report/properties.c \ report/report.c \ striped/striped.c \
lib/properties/prop_common.c new file +92 -0
92 lines not on this page · raw message
lib/properties/prop_common.h new file +121 -0
121 lines not on this page · raw message
lib/report/columns.h +1 -42
54 lines not on this page · raw message
lib/report/properties.c +109 -217
514 lines not on this page · raw message
lib/report/properties.h +2 -15
@@ -1,5 +1,5 @@/* -* Copyright (C) 2010 Red Hat, Inc. All rights reserved. +* Copyright (C) 2010-2013 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. *
@@ -18,20 +18,7 @@#include "lvm-types.h" #include "metadata.h" #include "report.h" - -struct lvm_property_type { -unsigned type; -const char *id; -unsigned is_settable:1 ; -unsigned is_string:1 ; -unsigned is_integer:1 ; -union { -const char *string; -uint64_t integer; - } value; -int (*get) (const void *obj,struct lvm_property_type *prop); -int (*set) (void *obj,struct lvm_property_type *prop); -}; +#include "prop_common.h" int lvseg_get_property (const struct lv_segment *lvseg,struct lvm_property_type *prop);
Signature · 1 line
1.8.1.4
PATCH 2/2 lvm2app: Add thin and thin pool lv creation
Add thin and thin pool lv creation support to lvm library
This is Mohan's thinp patch, re-worked to include suggestions from Zdenek and Mohan.
Rework of commit 4d5de8322b3a6050def60542b167b46d97b2824d which uses refactored properties handling.
Based on work done by M. Mohan Kumar <[email protected]>
--- lib/properties/prop_common.h | 9 ++ liblvm/Makefile.in | 3 +- liblvm/lvm2app.h | 153 +++++++++++++++++++++- liblvm/lvm_lv.c | 293 ++++++++++++++++++++++++++++++++++++++++++- liblvm/lvm_misc.c | 24 +++- liblvm/lvm_misc.h | 8 +- liblvm/lvm_pv.c | 4 +- liblvm/lvm_vg.c | 6 +- 8 files changed, 483 insertions(+), 17 deletions(-)
lib/properties/prop_common.h +9 -0
@@ -62,6 +62,15 @@ static int _ ## NAME ## _set (void *obj, struct lvm_property_type *prop) \return 1 ; \ } +#define SET_NUM_PROPERTY (NAME ,VALUE ,TYPE ,VAR ) \ +static int _ ## NAME ## _set (void *obj, struct lvm_property_type *prop) \ +{ \ + struct TYPE *VAR = (struct TYPE *)obj; \ +\ + VALUE = prop->value.integer; \ + return 1; \ +} +#define GET_STR_PROPERTY_FN (NAME ,VALUE ,TYPE ,VAR ) \ static int _ ## NAME ## _get (const void *obj, struct lvm_property_type *prop) \ { \
liblvm/Makefile.in +2 -1
@@ -1,6 +1,6 @@ # # Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. -# Copyright (C) 2004-2012 Red Hat, Inc. All rights reserved. +# Copyright (C) 2004-2013 Red Hat, Inc. All rights reserved. # # This file is part of LVM2. #
@@ -18,6 +18,7 @@ top_builddir = @top_builddir@ SOURCES =\ lvm_misc.c \ + lvm_prop.c \ lvm_base.c \ lvm_lv.c \ lvm_pv.c \
liblvm/lvm2app.h +152 -1
175 lines not on this page · raw message
liblvm/lvm_lv.c +290 -3
320 lines not on this page · raw message
liblvm/lvm_misc.c +20 -4
@@ -1,5 +1,5 @@/* -* Copyright (C) 2008,2010 Red Hat, Inc. All rights reserved. +* Copyright (C) 2008-2013 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. *
@@ -16,6 +16,7 @@#include "properties.h" #include "lvm_misc.h" #include "lvm2app.h" +#include "lvm_prop.h" struct dm_list *tag_list_copy (struct dm_pool *p,struct dm_list *tag_list) {
@@ -46,8 +47,11 @@ struct dm_list *tag_list_copy(struct dm_pool *p, struct dm_list *tag_list) }struct lvm_property_value get_property (const pv_t pv,const vg_t vg, -const lv_t lv,const lvseg_t lvseg, -const pvseg_t pvseg,const char *name) +const lv_t lv, +const lvseg_t lvseg, +const pvseg_t pvseg, +const struct lvcreate_params *lvcp, +const char *name) {struct lvm_property_type prop;struct lvm_property_value v = {0 };
@@ -69,6 +73,9 @@ struct lvm_property_value get_property(const pv_t pv, const vg_t vg, }else if (pvseg) {if (!pvseg_get_property (pvseg, &prop))return v; + }else if (lvcp) { +if (!lv_create_param_get_property (lvcp, &prop)) +return v; }else {log_errno (EINVAL ,"Invalid NULL handle passed to library function." );return v;
@@ -87,7 +94,9 @@ struct lvm_property_value get_property(const pv_t pv, const vg_t vg,int set_property (const pv_t pv,const vg_t vg,const lv_t lv, -const char *name,struct lvm_property_value *v) +struct lvcreate_params *lvcp, +const char *name, +struct lvm_property_value *v) {struct lvm_property_type prop;
@@ -111,6 +120,13 @@ int set_property(const pv_t pv, const vg_t vg, const lv_t lv, v->is_valid =0 ;return -1 ; } + }else if (lvcp) { +if (!lv_create_param_set_property (lvcp, &prop)) { + v->is_valid =0 ; +return -1 ; + } + }else { +return -1 ; }return 0 ; }
liblvm/lvm_misc.h +5 -3
@@ -1,5 +1,5 @@/* -* Copyright (C) 2008,2010 Red Hat, Inc. All rights reserved. +* Copyright (C) 2008-2013 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. *
@@ -20,8 +20,10 @@struct dm_list *tag_list_copy (struct dm_pool *p,struct dm_list *tag_list);struct lvm_property_value get_property (const pv_t pv,const vg_t vg,const lv_t lv,const lvseg_t lvseg, -const pvseg_t pvseg,const char *name); +const pvseg_t pvseg,const struct lvcreate_params *lvcp, +const char *name);int set_property (const pv_t pv,const vg_t vg,const lv_t lv, -const char *name,struct lvm_property_value *value); +struct lvcreate_params *lvcp,const char *name, +struct lvm_property_value *value);#endif
liblvm/lvm_pv.c +2 -2
@@ -53,13 +53,13 @@ uint64_t lvm_pv_get_free(const pv_t pv)struct lvm_property_value lvm_pv_get_property (const pv_t pv,const char *name) { -return get_property (pv,NULL ,NULL ,NULL ,NULL , name); +return get_property (pv,NULL ,NULL ,NULL ,NULL ,NULL , name); }struct lvm_property_value lvm_pvseg_get_property (const pvseg_t pvseg,const char *name) { -return get_property (NULL ,NULL ,NULL ,NULL , pvseg, name); +return get_property (NULL ,NULL ,NULL ,NULL , pvseg,NULL , name); }struct lvm_list_wrapper
liblvm/lvm_vg.c +3 -3
@@ -1,5 +1,5 @@/* -* Copyright (C) 2008,2009 Red Hat, Inc. All rights reserved. +* Copyright (C) 2008-2013 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. *
@@ -340,7 +340,7 @@ const char *lvm_vg_get_name(const vg_t vg)struct lvm_property_value lvm_vg_get_property (const vg_t vg,const char *name) { -return get_property (NULL , vg,NULL ,NULL ,NULL , name); +return get_property (NULL , vg,NULL ,NULL ,NULL ,NULL , name); } int lvm_vg_set_property(const vg_t vg, const char *name,
@@ -357,7 +357,7 @@ int lvm_vg_set_property(const vg_t vg, const char *name, strlen(value->value.string) + 1); } -return set_property (NULL , vg,NULL , name, value); +return set_property (NULL , vg,NULL ,NULL , name, value); }struct dm_list *lvm_list_vg_names (lvm_t libh)
Signature · 1 line
1.8.1.4