master - libdm: add dm_bitset_parse_list()
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=81fad9e853c45a5c3e56b2bede3a3fc7d7bed30b Commit: 81fad9e853c45a5c3e56b2bede3a3fc7d7bed30b Parent: d382e660356f1095040b8a84b54a0c1db0ab78b1 Author: Bryn M. Reeves <[email protected]> AuthorDate: Thu Feb 18 16:14:43 2016 +0000 Committer: Bryn M. Reeves <[email protected]> CommitterDate: Tue Jul 5 19:53:16 2016 +0100
libdm: add dm_bitset_parse_list()
Add a function to parse a list of integer values and ranges into a dm_bitset representation. Individual values signify that that bit is set in the resulting mask and ranges are given as a pair of start and end values, M-N, such that M and N are the first and last members of the range (inclusive).
The implementation is based on the kernel's __bitmap_parselist() that is used for cpumasks and other set configuration passed in string form from user space.
--- WHATS_NEW_DM | 1 + libdm/.exported_symbols.DM_1_02_129 | 1 + libdm/datastruct/bitset.c | 98 +++++++++++++++++++++++++++++++++++ libdm/libdevmapper.h | 10 ++++ 4 files changed, 110 insertions(+), 0 deletions(-)
WHATS_NEW_DM +1 -0
@@ -1,5 +1,6 @@ Version 1.02.129 - ================================= + Add dm_bitset_parse_list() to parse a string representation of a bitset. Thin dmeventd plugin umounts lvm2 volume only when pool is 95% or more. Version 1.02.128 - 25th June 2016
libdm/.exported_symbols.DM_1_02_129 new file +1 -0
@@ -0,0 +1 @@ +dm_bitset_parse_list
libdm/datastruct/bitset.c +98 -0
107 lines not on this page · raw message
libdm/libdevmapper.h +10 -0
@@ -1843,6 +1843,16 @@ int dm_bit_get_next(dm_bitset_t bs, int last_bit);#define dm_bit_copy (bs1, bs2) \ memcpy((bs1) + 1, (bs2) + 1, ((*(bs1) / DM_BITS_PER_INT) + 1) * sizeof(int)) +/* +* Parse a string representation of a bitset into a dm_bitset_t. The +* notation used is identical to the kernel bitmap parser (cpuset etc.) +* and supports both lists ("1,2,3") and ranges ("1-2,5-8"). If the mem +* parameter is NULL memory for the bitset will be allocated using +* dm_malloc(). Otherwise the bitset will be allocated using the supplied +* dm_pool. +*/ +dm_bitset_t dm_bitset_parse_list (const char *str,struct dm_pool *mem); +/* Returns number of set bits */ static inline unsigned hweight32 (uint32_t i) {