Skip to contentSkip to conversation

master - libdevmapper: add dm_units_to_factor for size unit parsing

PATCH Peter Rajnoha 1 participant 1 message Apr 28, 2014

lore
Share & tools
lore
#0 lore raw
Gitweb:        http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=4360fdf89c7f38c5de0d3e6d612f67ee915cba15
Commit:        4360fdf89c7f38c5de0d3e6d612f67ee915cba15
Parent:        75d399800ab60264d1201ad3fa1f9283542459f6
Author:        Peter Rajnoha <[email protected]>
AuthorDate:    Mon Apr 28 10:25:43 2014 +0200
Committer:     Peter Rajnoha <[email protected]>
CommitterDate: Mon Apr 28 10:25:43 2014 +0200

libdevmapper: add dm_units_to_factor for size unit parsing

Actually moving the existing code from LVM to libdm for reuse.

---
 WHATS_NEW_DM               |    1 +
 lib/commands/toolcontext.c |    4 +-
 lib/display/display.c      |   99 -----------------------------------------
 lib/display/display.h      |    2 -
 libdm/libdevmapper.h       |   44 ++++++++++++++++++
 libdm/libdm-string.c       |  106 ++++++++++++++++++++++++++++++++++++++++++++
 tools/lvmcmdline.c         |    4 +-
 7 files changed, 155 insertions(+), 105 deletions(-)
WHATS_NEW_DM +1 -0
index 6a983a7..c81d354 100644
@@ -1,5 +1,6 @@
 Version 1.02.88 - 
 =================================
+  Add dm_units_to_factor for size unit parsing.
   Increase bitset size for minors for thin dmeventd plugin.
 
 Version 1.02.85 - 10th April 2014
lib/commands/toolcontext.c +2 -2
index d62fb8a..b2f8293 100644
@@ -282,8 +282,8 @@ static int _check_config(struct cmd_context *cmd)
 
 int process_profilable_config(struct cmd_context *cmd) {
 	if (!(cmd->default_settings.unit_factor =
-	      units_to_bytes(find_config_tree_str(cmd, global_units_CFG, NULL),
-			     &cmd->default_settings.unit_type))) {
+	      dm_units_to_factor(find_config_tree_str(cmd, global_units_CFG, NULL),
+				 &cmd->default_settings.unit_type, 1, NULL))) {
 		log_error("Invalid units specification");
 		return 0;
 	}
lib/display/display.c +0 -99

111 lines not on this page · raw message

lib/display/display.h +0 -2
index 41fba03..d5c0efa 100644
@@ -22,8 +22,6 @@
 
 #include <stdint.h>
 
-uint64_t units_to_bytes(const char *units, char *unit_type);
-
 /* Specify size in KB */
 const char *display_size(const struct cmd_context *cmd, uint64_t size);
 const char *display_size_long(const struct cmd_context *cmd, uint64_t size);
libdm/libdevmapper.h +44 -0

50 lines not on this page · raw message

libdm/libdm-string.c +106 -0

115 lines not on this page · raw message

tools/lvmcmdline.c +2 -2
index 758c429..7e4d9a6 100644
@@ -923,8 +923,8 @@ static int _get_settings(struct cmd_context *cmd)
 
 	if (arg_count(cmd, units_ARG))
 		if (!(cmd->current_settings.unit_factor =
-		      units_to_bytes(arg_str_value(cmd, units_ARG, ""),
-				     &cmd->current_settings.unit_type))) {
+		      dm_units_to_factor(arg_str_value(cmd, units_ARG, ""),
+					 &cmd->current_settings.unit_type, 1, NULL))) {
 			log_error("Invalid units specification");
 			return EINVALID_CMD_LINE;
 		}