[sheepdog] [PATCH] dog/vdi: add hexadecimal support for index option

Ruoyu liangry at ucweb.com
Tue Jul 15 09:38:10 CEST 2014


It is convenient if the user already knows a oid, no need to
convert it to decimal index first.

Signed-off-by: Ruoyu <liangry at ucweb.com>
---
 dog/vdi.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/dog/vdi.c b/dog/vdi.c
index 1443cf4..ec78a2c 100644
--- a/dog/vdi.c
+++ b/dog/vdi.c
@@ -2534,9 +2534,13 @@ static int vdi_parser(int ch, const char *opt)
 		vdi_cmd_data.no_share = true;
 		break;
 	case 'i':
-		vdi_cmd_data.index = strtol(opt, &p, 10);
+		if (strncmp(opt, "0x", 2) == 0)
+			vdi_cmd_data.index = strtol(opt, &p, 16);
+		else
+			vdi_cmd_data.index = strtol(opt, &p, 10);
 		if (opt == p) {
-			sd_err("The index must be an integer");
+			sd_err("The index must be a decimal integer "
+				"or a hexadecimal integer started with 0x");
 			exit(EXIT_FAILURE);
 		}
 		break;
-- 
1.8.3.2





More information about the sheepdog mailing list