[PATCH 1/3] fdisk: accept lowercase K/M/G suffixes

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This accepts lowercase suffixes as alternative names for the uppercase
ones. These suffixes were accepted in previous fdisk versions but with
a different meaning.

Presumably some users are inclined not to use shift key here even if
this isn't the expected way to write these units.

Signed-off-by: Francesco Cosoleto <cosoleto@xxxxxxxxx>
---
 fdisk/fdisk.c |   14 +++++++-------
 1 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index 640fb9d..c88af0c 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -1448,16 +1448,16 @@ read_int_sx(unsigned int low, unsigned int dflt, unsigned int high,
 				if (!display_in_cyl_units)
 					i *= heads * sectors;
 			} else if (*line_ptr &&
-				   *(line_ptr + 1) == 'B' &&
+				   (*(line_ptr + 1) == 'B' || *(line_ptr + 1) == 'b') &&
 				   *(line_ptr + 2) == '\0') {
 				/*
 				 * 10^N
 				 */
-				if (*line_ptr == 'K')
+				if (*line_ptr == 'K' || *line_ptr == 'k')
 					absolute = 1000;
-				else if (*line_ptr == 'M')
+				else if (*line_ptr == 'M' || *line_ptr == 'm')
 					absolute = 1000000;
-				else if (*line_ptr == 'G')
+				else if (*line_ptr == 'G' || *line_ptr == 'g')
 					absolute = 1000000000;
 				else
 					absolute = -1;
@@ -1466,11 +1466,11 @@ read_int_sx(unsigned int low, unsigned int dflt, unsigned int high,
 				/*
 				 * 2^N
 				 */
-				if (*line_ptr == 'K')
+				if (*line_ptr == 'K' || *line_ptr == 'k')
 					absolute = 1 << 10;
-				else if (*line_ptr == 'M')
+				else if (*line_ptr == 'M' || *line_ptr == 'm')
 					absolute = 1 << 20;
-				else if (*line_ptr == 'G')
+				else if (*line_ptr == 'G' || *line_ptr == 'g')
 					absolute = 1 << 30;
 				else
 					absolute = -1;
-- 
1.7.3.4

--
To unsubscribe from this list: send the line "unsubscribe util-linux" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux