Print this page
2556 dd should accept M,G,T,... for sizes

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/dd/dd.c
          +++ new/usr/src/cmd/dd/dd.c
↓ open down ↓ 15 lines elided ↑ open up ↑
  16   16   * If applicable, add the following below this CDDL HEADER, with the
  17   17   * fields enclosed by brackets "[]" replaced with your own identifying
  18   18   * information: Portions Copyright [yyyy] [name of copyright owner]
  19   19   *
  20   20   * CDDL HEADER END
  21   21   */
  22   22  
  23   23  /*
  24   24   * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
  25   25   * Use is subject to license terms.
       26 + * Copyright 2012, Josef 'Jeff' Sipek <jeffpc@31bits.net>. All rights reserved.
  26   27   */
  27   28  
  28   29  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  29   30  /*        All Rights Reserved   */
  30   31  
  31   32  #pragma ident   "%Z%%M% %I%     %E% SMI"
  32   33  
  33   34  /*
  34   35   *      convert and copy
  35   36   */
↓ open down ↓ 1599 lines elided ↑ open up ↑
1635 1636          return (1);
1636 1637  }
1637 1638  
1638 1639  /* number ************************************************************* */
1639 1640  /*                                                                      */
1640 1641  /* Convert a numeric arg to binary                                      */
1641 1642  /*                                                                      */
1642 1643  /* Arg:         big - maximum valid input number                        */
1643 1644  /* Global arg:  string - pointer to command arg                         */
1644 1645  /*                                                                      */
1645      -/* Valid forms: 123 | 123k | 123w | 123b | 123*123 | 123x123            */
     1646 +/* Valid forms: 123 | 123k | 123M | 123G | 123T | 123P | 123E | 123Z |  */
     1647 +/*              123w | 123b | 123*123 | 123x123                         */
1646 1648  /*              plus combinations such as 2b*3kw*4w                     */
1647 1649  /*                                                                      */
1648 1650  /* Return:      converted number                                        */
1649 1651  /*                                                                      */
1650 1652  /* ******************************************************************** */
1651 1653  
1652 1654  static unsigned long long
1653 1655  number(big)
1654 1656  long long big;
1655 1657  {
↓ open down ↓ 5 lines elided ↑ open up ↑
1661 1663          n = 0;
1662 1664          while ((*cs >= '0') && (*cs <= '9') && (n <= cut))
1663 1665          {
1664 1666                  n = n*10 + *cs++ - '0';
1665 1667          }
1666 1668          for (;;)
1667 1669          {
1668 1670                  switch (*cs++)
1669 1671                  {
1670 1672  
     1673 +                case 'Z':
     1674 +                        n *= 1024;
     1675 +                        /* FALLTHROUGH */
     1676 +
     1677 +                case 'E':
     1678 +                        n *= 1024;
     1679 +                        /* FALLTHROUGH */
     1680 +
     1681 +                case 'P':
     1682 +                        n *= 1024;
     1683 +                        /* FALLTHROUGH */
     1684 +
     1685 +                case 'T':
     1686 +                        n *= 1024;
     1687 +                        /* FALLTHROUGH */
     1688 +
     1689 +                case 'G':
     1690 +                        n *= 1024;
     1691 +                        /* FALLTHROUGH */
     1692 +
     1693 +                case 'M':
     1694 +                        n *= 1024;
     1695 +                        /* FALLTHROUGH */
     1696 +
1671 1697                  case 'k':
1672 1698                          n *= 1024;
1673 1699                          continue;
1674 1700  
1675 1701                  case 'w':
1676 1702                          n *= 2;
1677 1703                          continue;
1678 1704  
1679 1705                  case 'b':
1680 1706                          n *= BSIZE;
↓ open down ↓ 125 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX