Print this page
2741 format shouldn't allow write SMI label to disk with EFI partition

Split Close
Expand all
Collapse all
          --- old/usr/src/cmd/format/menu_command.c
          +++ new/usr/src/cmd/format/menu_command.c
↓ open down ↓ 1555 lines elided ↑ open up ↑
1556 1556                  struct dk_label label;
1557 1557                  struct dk_gpt   *vtoc64;
1558 1558                  struct efi_info efinfo;
1559 1559                  struct disk_type        *dptr;
1560 1560  
1561 1561                  /* Ask user what label to use */
1562 1562                  fmt_print("[0] SMI Label\n");
1563 1563                  fmt_print("[1] EFI Label\n");
1564 1564                  ioparam.io_bounds.lower = 0;
1565 1565                  ioparam.io_bounds.upper = 1;
1566      -                if (cur_label == L_TYPE_SOLARIS)
1567      -                        deflt = 0;
     1566 +                if ((cur_label == L_TYPE_SOLARIS) &&
     1567 +                    (cur_disk->fdisk_part.systid != EFI_PMBR))
     1568 +                        deflt = L_TYPE_SOLARIS;
1568 1569                  else
1569      -                        deflt = 1;
     1570 +                        deflt = L_TYPE_EFI;
1570 1571                  defltptr = &deflt;
1571 1572                  choice = input(FIO_INT, "Specify Label type", ':',
1572 1573                      &ioparam, defltptr, DATA_INPUT);
1573      -                if ((choice == 0) && (cur_label == L_TYPE_SOLARIS)) {
     1574 +                if ((choice == L_TYPE_SOLARIS) &&
     1575 +                    (cur_label == L_TYPE_SOLARIS) &&
     1576 +                    (cur_disk->fdisk_part.systid != EFI_PMBR)) {
1574 1577                          goto expert_end;
1575      -                } else if ((choice == 1) && (cur_label == L_TYPE_EFI)) {
     1578 +                } else if ((choice == L_TYPE_EFI) &&
     1579 +                    (cur_label == L_TYPE_EFI)) {
1576 1580                          goto expert_end;
1577 1581                  }
1578 1582                  switch (choice) {
1579      -                case 0:
     1583 +                case L_TYPE_SOLARIS:
1580 1584                  /*
1581 1585                   * EFI label to SMI label
1582 1586                   */
1583 1587                  if (cur_dtype->capacity > INFINITY) {
1584 1588                          fmt_print("Warning: SMI labels only support up to "
1585 1589                              "2 TB.\n");
1586 1590                  }
1587 1591  
1588 1592                  if (cur_disk->fdisk_part.systid == EFI_PMBR) {
1589 1593                          fmt_print("Warning: This disk has an EFI label. "
↓ open down ↓ 51 lines elided ↑ open up ↑
1641 1645                          else
1642 1646                                  cur_disk->disk_flags &= ~DSK_LABEL_DIRTY;
1643 1647  
1644 1648                          return (status);
1645 1649                  } else {
1646 1650                          err_print("Label failed.\n");
1647 1651                          return (-1);
1648 1652                  }
1649 1653  
1650 1654  
1651      -                case 1:
     1655 +                case L_TYPE_EFI:
1652 1656                  /*
1653 1657                   * SMI label to EFI label
1654 1658                   */
1655 1659  
1656      -
1657      -                fmt_print("Warning: This disk has an SMI label. Changing to "
1658      -                    "EFI label will erase all\ncurrent partitions.\n");
1659      -
1660      -                if (check("Continue")) {
1661      -                        return (-1);
     1660 +                if ((cur_disk->fdisk_part.systid == SUNIXOS) ||
     1661 +                    (cur_disk->fdisk_part.systid == SUNIXOS2)) {
     1662 +                        fmt_print("Warning: This disk has an SMI label. "
     1663 +                            "Changing to EFI label will erase all\ncurrent "
     1664 +                            "partitions.\n");
     1665 +                        if (check("Continue")) {
     1666 +                                return (-1);
     1667 +                        }
1662 1668                  }
1663 1669  
1664 1670                  if (get_disk_info(cur_file, &efinfo) != 0) {
1665 1671                          return (-1);
1666 1672                  }
1667 1673                  (void) memset((char *)&label, 0, sizeof (struct dk_label));
1668 1674                  label.dkl_pcyl = pcyl;
1669 1675                  label.dkl_ncyl = ncyl;
1670 1676                  label.dkl_acyl = acyl;
1671 1677  #if defined(_SUNOS_VTOC_16)
↓ open down ↓ 834 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX