1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
lvm2/liblvm
Tony Asleson 91f737383c lvm2app: Add signed numerical property values
Currently lvm2app properties have the following structure:

typedef struct lvm_property_value {
        uint32_t is_settable:1;
        uint32_t is_string:1;
        uint32_t is_integer:1;
        uint32_t is_valid:1;
        uint32_t padding:28;
        union {
                const char *string;
                uint64_t integer;
        } value;
} lvm_property_value_t;

which assumes that numerical values were in the range of 0 to 2**64-1.  However,
some of the properties were 'signed', like LV major/minor numbers and some
reserved values for properties that represent percentages.  Thus when the
values were retrieved they were in two's complement notation.  So for a -1
major number the API user would get a value of 18446744073709551615.  The
API user could cast the returned value to an int64_t to handle this, but that
requires the API developer to look at the source code and determine when it
should be done.

This change modifies the return property structure to:

typedef struct lvm_property_value {
        uint32_t is_settable:1;
        uint32_t is_string:1;
        uint32_t is_integer:1;
        uint32_t is_valid:1;
        uint32_t is_signed:1;
        uint32_t padding:27;
        union {
                const char *string;
                uint64_t integer;
                int64_t signed_integer;
        } value;
} lvm_property_value_t;

With this addition the API user can interrogate that the value is numerical,
(is_integer = 1) and subsequently check if it's signed (is_signed = 1) too.
If signed, then the API developer should use the union's signed_integer to
avoid casting.

This change maintains backwards compatibility as the structure size remains
unchanged and integer value remains unchanged.  Only the additional bit
taken from the pad is utilized.

Bugzilla reference:
https://bugzilla.redhat.com/show_bug.cgi?id=838257

Signed-off-by: Tony Asleson <tasleson@redhat.com>
2015-05-06 08:51:04 -05:00
..
.exported_symbols Generate liblvm2app and libdevmapper exported symbols from header files. 2010-06-25 18:17:38 +00:00
Doxyfile Add Doxygen file for lvm2app to generate documentation from lvm2app.h. 2010-02-24 18:16:54 +00:00
liblvm2app.pc.in configure: add --enable-blkid_wiping 2013-11-27 15:48:16 +01:00
lvm2app.h lvm2app: Add signed numerical property values 2015-05-06 08:51:04 -05:00
lvm_base.c lvm2app: call fin_locking in lvm_quit 2015-05-03 00:43:13 +02:00
lvm_lv.c cleanup: rename virtual_extents 2014-11-03 14:19:33 +01:00
lvm_misc.c lvm2app: Add signed numerical property values 2015-05-06 08:51:04 -05:00
lvm_misc.h liblvm: Save off and restore umask values 2013-12-20 13:36:22 -06:00
lvm_prop_fields.h lvm2app: Add ability to create PV with args 2013-11-19 14:40:34 -06:00
lvm_prop.c lvm2app: Add signed numerical property values 2015-05-06 08:51:04 -05:00
lvm_prop.h lvm2app: Add ability to create PV with args 2013-11-19 14:40:34 -06:00
lvm_pv.c pvremove: Avoid metadata re-reads & related error messages. 2015-01-06 14:27:30 +01:00
lvm_vg.c liblvm: Save off and restore umask values 2013-12-20 13:36:22 -06:00
Makefile.in lvm2app: Add thin and thin pool lv creation 2013-07-12 16:52:16 -05:00