changeset 13670:25dba56d858d

2556 dd should accept M,G,T,... for sizes Reviewed by: Dan Kruchinin <dkruchinin@acm.org> Reviewed by: Richard Lowe <richlowe@richlowe.net> Approved by: Gordon Ross <gwr@nexenta.com>
author Josef 'Jeff' Sipek <jeffpc@josefsipek.net>
date Thu, 19 Apr 2012 20:18:45 -0400
parents 779ed9ad03ea
children 176fbb72a42d
files usr/src/cmd/dd/dd.c usr/src/man/man1m/dd.1m
diffstat 2 files changed, 64 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/usr/src/cmd/dd/dd.c	Mon Apr 16 21:31:22 2012 +0100
+++ b/usr/src/cmd/dd/dd.c	Thu Apr 19 20:18:45 2012 -0400
@@ -23,13 +23,12 @@
 /*
  * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  * Use is subject to license terms.
+ * Copyright 2012, Josef 'Jeff' Sipek <jeffpc@31bits.net>. All rights reserved.
  */
 
 /*	Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T	*/
 /*	  All Rights Reserved  	*/
 
-#pragma ident	"%Z%%M%	%I%	%E% SMI"
-
 /*
  *	convert and copy
  */
@@ -1642,7 +1641,8 @@
 /* Arg:		big - maximum valid input number			*/
 /* Global arg:	string - pointer to command arg				*/
 /*									*/
-/* Valid forms:	123 | 123k | 123w | 123b | 123*123 | 123x123		*/
+/* Valid forms:	123 | 123k | 123M | 123G | 123T | 123P | 123E | 123Z |	*/
+/*		123w | 123b | 123*123 | 123x123				*/
 /*		plus combinations such as 2b*3kw*4w			*/
 /*									*/
 /* Return:	converted number					*/
@@ -1668,6 +1668,30 @@
 		switch (*cs++)
 		{
 
+		case 'Z':
+			n *= 1024;
+			/* FALLTHROUGH */
+
+		case 'E':
+			n *= 1024;
+			/* FALLTHROUGH */
+
+		case 'P':
+			n *= 1024;
+			/* FALLTHROUGH */
+
+		case 'T':
+			n *= 1024;
+			/* FALLTHROUGH */
+
+		case 'G':
+			n *= 1024;
+			/* FALLTHROUGH */
+
+		case 'M':
+			n *= 1024;
+			/* FALLTHROUGH */
+
 		case 'k':
 			n *= 1024;
 			continue;
--- a/usr/src/man/man1m/dd.1m	Mon Apr 16 21:31:22 2012 +0100
+++ b/usr/src/man/man1m/dd.1m	Thu Apr 19 20:18:45 2012 -0400
@@ -403,12 +403,48 @@
 .RS +4
 .TP
 3.
+a positive decimal number followed by \fBM\fR, specifying multiplication by
+1024*1024
+.RE
+.RS +4
+.TP
+4.
+a positive decimal number followed by \fBG\fR, specifying multiplication by
+1024*1024*1024
+.RE
+.RS +4
+.TP
+5.
+a positive decimal number followed by \fBT\fR, specifying multiplication by
+1024*1024*1024*1024
+.RE
+.RS +4
+.TP
+6.
+a positive decimal number followed by \fBP\fR, specifying multiplication by
+1024*1024*1024*1024*1024
+.RE
+.RS +4
+.TP
+7.
+a positive decimal number followed by \fBE\fR, specifying multiplication by
+1024*1024*1024*1024*1024*1024
+.RE
+.RS +4
+.TP
+8.
+a positive decimal number followed by \fBZ\fR, specifying multiplication by
+1024*1024*1024*1024*1024*1024*1024
+.RE
+.RS +4
+.TP
+9.
 a positive decimal number followed by \fBb\fR, specifying multiplication by
 512
 .RE
 .RS +4
 .TP
-4.
+10.
 two or more positive decimal numbers (with or without \fBk\fR or \fBb\fR)
 separated by \fBx\fR, specifying the product of the indicated values.
 .RE