Module Name:    src
Committed By:   jnemeth
Date:           Fri Nov 22 04:21:02 UTC 2013

Modified Files:
        src/sbin/gpt: add.c label.c remove.c

Log Message:
change the "-b blocknr" parameter to accept a "human number"


To generate a diff of this commit:
cvs rdiff -u -r1.18 -r1.19 src/sbin/gpt/add.c
cvs rdiff -u -r1.11 -r1.12 src/sbin/gpt/label.c
cvs rdiff -u -r1.9 -r1.10 src/sbin/gpt/remove.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/gpt/add.c
diff -u src/sbin/gpt/add.c:1.18 src/sbin/gpt/add.c:1.19
--- src/sbin/gpt/add.c:1.18	Fri Nov 22 03:50:05 2013
+++ src/sbin/gpt/add.c	Fri Nov 22 04:21:02 2013
@@ -29,7 +29,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/add.c,v 1.14 2006/06/22 22:05:28 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: add.c,v 1.18 2013/11/22 03:50:05 jnemeth Exp $");
+__RCSID("$NetBSD: add.c,v 1.19 2013/11/22 04:21:02 jnemeth Exp $");
 #endif
 
 #include <sys/types.h>
@@ -212,9 +212,9 @@ cmd_add(int argc, char *argv[])
 		case 'b':
 			if (block > 0)
 				usage_add();
-			block = strtoll(optarg, &p, 10);
-			if (*p != 0 || block < 1)
+			if (dehumanize_number(optarg, &human_num) < 0)
 				usage_add();
+			block = human_num;
 			break;
 		case 'i':
 			if (entry > 0)

Index: src/sbin/gpt/label.c
diff -u src/sbin/gpt/label.c:1.11 src/sbin/gpt/label.c:1.12
--- src/sbin/gpt/label.c:1.11	Fri Nov 22 03:50:05 2013
+++ src/sbin/gpt/label.c	Fri Nov 22 04:21:02 2013
@@ -29,7 +29,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/label.c,v 1.3 2006/10/04 18:20:25 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: label.c,v 1.11 2013/11/22 03:50:05 jnemeth Exp $");
+__RCSID("$NetBSD: label.c,v 1.12 2013/11/22 04:21:02 jnemeth Exp $");
 #endif
 
 #include <sys/types.h>
@@ -186,6 +186,7 @@ cmd_label(int argc, char *argv[])
 {
 	char *p;
 	int ch, fd;
+	int64_t human_num;
 
 	/* Get the label options */
 	while ((ch = getopt(argc, argv, "ab:f:i:l:s:t:")) != -1) {
@@ -198,9 +199,9 @@ cmd_label(int argc, char *argv[])
 		case 'b':
 			if (block > 0)
 				usage_label();
-			block = strtoll(optarg, &p, 10);
-			if (*p != 0 || block < 1)
+			if (dehumanize_number(optarg, &human_num) < 0)
 				usage_label();
+			block = human_num;
 			break;
 		case 'f':
 			if (name != NULL)

Index: src/sbin/gpt/remove.c
diff -u src/sbin/gpt/remove.c:1.9 src/sbin/gpt/remove.c:1.10
--- src/sbin/gpt/remove.c:1.9	Fri Nov 22 03:50:05 2013
+++ src/sbin/gpt/remove.c	Fri Nov 22 04:21:02 2013
@@ -29,7 +29,7 @@
 __FBSDID("$FreeBSD: src/sbin/gpt/remove.c,v 1.10 2006/10/04 18:20:25 marcel Exp $");
 #endif
 #ifdef __RCSID
-__RCSID("$NetBSD: remove.c,v 1.9 2013/11/22 03:50:05 jnemeth Exp $");
+__RCSID("$NetBSD: remove.c,v 1.10 2013/11/22 04:21:02 jnemeth Exp $");
 #endif
 
 #include <sys/types.h>
@@ -158,6 +158,7 @@ cmd_remove(int argc, char *argv[])
 {
 	char *p;
 	int ch, fd;
+	int64_t human_num;
 
 	/* Get the remove options */
 	while ((ch = getopt(argc, argv, "ab:i:s:t:")) != -1) {
@@ -170,9 +171,9 @@ cmd_remove(int argc, char *argv[])
 		case 'b':
 			if (block > 0)
 				usage_remove();
-			block = strtoll(optarg, &p, 10);
-			if (*p != 0 || block < 1)
+			if (dehumanize_number(optarg, &human_num) < 0)
 				usage_remove();
+			block = human_num;
 			break;
 		case 'i':
 			if (entry > 0)

Reply via email to