1546 * If expert (-e) mode, then ask user if they wish
1547 * to change the current solaris label into an EFI one
1548 */
1549 if (expert_mode) {
1550 #if defined(_SUNOS_VTOC_8)
1551 int i;
1552 #endif
1553 int choice;
1554 u_ioparam_t ioparam;
1555 struct extvtoc vtoc;
1556 struct dk_label label;
1557 struct dk_gpt *vtoc64;
1558 struct efi_info efinfo;
1559 struct disk_type *dptr;
1560
1561 /* Ask user what label to use */
1562 fmt_print("[0] SMI Label\n");
1563 fmt_print("[1] EFI Label\n");
1564 ioparam.io_bounds.lower = 0;
1565 ioparam.io_bounds.upper = 1;
1566 if (cur_label == L_TYPE_SOLARIS)
1567 deflt = 0;
1568 else
1569 deflt = 1;
1570 defltptr = &deflt;
1571 choice = input(FIO_INT, "Specify Label type", ':',
1572 &ioparam, defltptr, DATA_INPUT);
1573 if ((choice == 0) && (cur_label == L_TYPE_SOLARIS)) {
1574 goto expert_end;
1575 } else if ((choice == 1) && (cur_label == L_TYPE_EFI)) {
1576 goto expert_end;
1577 }
1578 switch (choice) {
1579 case 0:
1580 /*
1581 * EFI label to SMI label
1582 */
1583 if (cur_dtype->capacity > INFINITY) {
1584 fmt_print("Warning: SMI labels only support up to "
1585 "2 TB.\n");
1586 }
1587
1588 if (cur_disk->fdisk_part.systid == EFI_PMBR) {
1589 fmt_print("Warning: This disk has an EFI label. "
1590 "Changing to SMI label will erase all\n"
1591 "current partitions.\n");
1592 if (check("Continue"))
1593 return (-1);
1594 #if defined(_FIRMWARE_NEEDS_FDISK)
1595 fmt_print("You must use fdisk to delete the current "
1596 "EFI partition and create a new\n"
1597 "Solaris partition before you can convert the "
1598 "label.\n");
1599 return (-1);
1631 if (delete_disk_type(cur_disk->disk_type) == 0) {
1632 cur_label = L_TYPE_SOLARIS;
1633 cur_disk->label_type = L_TYPE_SOLARIS;
1634 cur_disk->disk_type = dptr;
1635 cur_disk->disk_parts = dptr->dtype_plist;
1636 cur_dtype = dptr;
1637 cur_parts = dptr->dtype_plist;
1638
1639 if (status = write_label())
1640 err_print("Label failed.\n");
1641 else
1642 cur_disk->disk_flags &= ~DSK_LABEL_DIRTY;
1643
1644 return (status);
1645 } else {
1646 err_print("Label failed.\n");
1647 return (-1);
1648 }
1649
1650
1651 case 1:
1652 /*
1653 * SMI label to EFI label
1654 */
1655
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);
1662 }
1663
1664 if (get_disk_info(cur_file, &efinfo) != 0) {
1665 return (-1);
1666 }
1667 (void) memset((char *)&label, 0, sizeof (struct dk_label));
1668 label.dkl_pcyl = pcyl;
1669 label.dkl_ncyl = ncyl;
1670 label.dkl_acyl = acyl;
1671 #if defined(_SUNOS_VTOC_16)
1672 label.dkl_bcyl = bcyl;
1673 #endif /* defined(_SUNOC_VTOC_16) */
1674 label.dkl_nhead = nhead;
1675 label.dkl_nsect = nsect;
1676 #if defined(_SUNOS_VTOC_8)
1677 for (i = 0; i < NDKMAP; i++) {
1678 label.dkl_map[i] = cur_parts->pinfo_map[i];
1679 }
1680 #endif /* defined(_SUNOS_VTOC_8) */
1681 label.dkl_magic = DKL_MAGIC;
1682 label.dkl_vtoc = cur_parts->vtoc;
|
1546 * If expert (-e) mode, then ask user if they wish
1547 * to change the current solaris label into an EFI one
1548 */
1549 if (expert_mode) {
1550 #if defined(_SUNOS_VTOC_8)
1551 int i;
1552 #endif
1553 int choice;
1554 u_ioparam_t ioparam;
1555 struct extvtoc vtoc;
1556 struct dk_label label;
1557 struct dk_gpt *vtoc64;
1558 struct efi_info efinfo;
1559 struct disk_type *dptr;
1560
1561 /* Ask user what label to use */
1562 fmt_print("[0] SMI Label\n");
1563 fmt_print("[1] EFI Label\n");
1564 ioparam.io_bounds.lower = 0;
1565 ioparam.io_bounds.upper = 1;
1566 if ((cur_label == L_TYPE_SOLARIS) &&
1567 (cur_disk->fdisk_part.systid != EFI_PMBR))
1568 deflt = L_TYPE_SOLARIS;
1569 else
1570 deflt = L_TYPE_EFI;
1571 defltptr = &deflt;
1572 choice = input(FIO_INT, "Specify Label type", ':',
1573 &ioparam, defltptr, DATA_INPUT);
1574 if ((choice == L_TYPE_SOLARIS) &&
1575 (cur_label == L_TYPE_SOLARIS) &&
1576 (cur_disk->fdisk_part.systid != EFI_PMBR)) {
1577 goto expert_end;
1578 } else if ((choice == L_TYPE_EFI) &&
1579 (cur_label == L_TYPE_EFI)) {
1580 goto expert_end;
1581 }
1582 switch (choice) {
1583 case L_TYPE_SOLARIS:
1584 /*
1585 * EFI label to SMI label
1586 */
1587 if (cur_dtype->capacity > INFINITY) {
1588 fmt_print("Warning: SMI labels only support up to "
1589 "2 TB.\n");
1590 }
1591
1592 if (cur_disk->fdisk_part.systid == EFI_PMBR) {
1593 fmt_print("Warning: This disk has an EFI label. "
1594 "Changing to SMI label will erase all\n"
1595 "current partitions.\n");
1596 if (check("Continue"))
1597 return (-1);
1598 #if defined(_FIRMWARE_NEEDS_FDISK)
1599 fmt_print("You must use fdisk to delete the current "
1600 "EFI partition and create a new\n"
1601 "Solaris partition before you can convert the "
1602 "label.\n");
1603 return (-1);
1635 if (delete_disk_type(cur_disk->disk_type) == 0) {
1636 cur_label = L_TYPE_SOLARIS;
1637 cur_disk->label_type = L_TYPE_SOLARIS;
1638 cur_disk->disk_type = dptr;
1639 cur_disk->disk_parts = dptr->dtype_plist;
1640 cur_dtype = dptr;
1641 cur_parts = dptr->dtype_plist;
1642
1643 if (status = write_label())
1644 err_print("Label failed.\n");
1645 else
1646 cur_disk->disk_flags &= ~DSK_LABEL_DIRTY;
1647
1648 return (status);
1649 } else {
1650 err_print("Label failed.\n");
1651 return (-1);
1652 }
1653
1654
1655 case L_TYPE_EFI:
1656 /*
1657 * SMI label to EFI label
1658 */
1659
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 }
1668 }
1669
1670 if (get_disk_info(cur_file, &efinfo) != 0) {
1671 return (-1);
1672 }
1673 (void) memset((char *)&label, 0, sizeof (struct dk_label));
1674 label.dkl_pcyl = pcyl;
1675 label.dkl_ncyl = ncyl;
1676 label.dkl_acyl = acyl;
1677 #if defined(_SUNOS_VTOC_16)
1678 label.dkl_bcyl = bcyl;
1679 #endif /* defined(_SUNOC_VTOC_16) */
1680 label.dkl_nhead = nhead;
1681 label.dkl_nsect = nsect;
1682 #if defined(_SUNOS_VTOC_8)
1683 for (i = 0; i < NDKMAP; i++) {
1684 label.dkl_map[i] = cur_parts->pinfo_map[i];
1685 }
1686 #endif /* defined(_SUNOS_VTOC_8) */
1687 label.dkl_magic = DKL_MAGIC;
1688 label.dkl_vtoc = cur_parts->vtoc;
|