Changeset 86142 in vbox for trunk/src/VBox
- Timestamp:
- Sep 16, 2020 9:03:49 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManageList.cpp
r86134 r86142 1602 1602 { 1603 1603 ComPtr<IHostDrive> pHostDrive = apHostDrives[i]; 1604 /* 1605 * The drive path and the model are obtained using different way 1606 * outside of the IHostDrive object, therefore, they are defined 1607 * even if another info is not available. 1608 */ 1604 1605 /* The drivePath and model attributes are accessible even when the object 1606 is in 'limited' mode. */ 1609 1607 com::Bstr bstrDrivePath; 1610 1608 CHECK_ERROR(pHostDrive,COMGETTER(DrivePath)(bstrDrivePath.asOutParam())); 1611 RTPrintf("%sDrive: %ls\n", i > 0 ? "\n" : "", bstrDrivePath.raw()); 1609 if (SUCCEEDED(rc)) 1610 RTPrintf("%sDrive: %ls\n", i > 0 ? "\n" : "", bstrDrivePath.raw()); 1611 else 1612 RTPrintf("%sDrive: %Rhrc\n", i > 0 ? "\n" : "", rc); 1612 1613 1613 1614 com::Bstr bstrModel; 1614 1615 CHECK_ERROR(pHostDrive,COMGETTER(Model)(bstrModel.asOutParam())); 1615 if (bstrModel.isNotEmpty()) 1616 RTPrintf("Model: %ls\n", bstrModel.raw()); 1616 if (FAILED(rc)) 1617 RTPrintf("Model: %Rhrc\n", rc); 1618 else if (bstrModel.isNotEmpty()) 1619 RTPrintf("Model: \"%ls\"\n", bstrModel.raw()); 1617 1620 else 1618 RTPrintf("Model: Unknown\n"); 1619 1621 RTPrintf("Model: unknown/inaccessible\n"); 1622 1623 /* The other attributes are not accessible in limited mode and will fail 1624 with E_ACCESSDENIED. Typically means the user cannot read the drive. */ 1620 1625 com::Bstr bstrUuidDisk; 1626 rc = pHostDrive->COMGETTER(Uuid)(bstrUuidDisk.asOutParam()); 1627 if (SUCCEEDED(rc) && !com::Guid(bstrUuidDisk).isZero()) 1628 RTPrintf("UUID: %ls\n", bstrUuidDisk.raw()); 1629 else if (rc == E_ACCESSDENIED) 1630 { 1631 RTPrintf("Further disk and partitioning information is not available for drive \"%ls\". (E_ACCESSDENIED)\n", 1632 bstrDrivePath.raw()); 1633 continue; 1634 } 1635 else if (FAILED(rc)) 1636 { 1637 RTPrintf("UUID: %Rhrc\n", rc); 1638 com::GlueHandleComErrorNoCtx(pHostDrive, rc); 1639 } 1640 1641 LONG64 cbSize = 0; 1642 rc = pHostDrive->COMGETTER(Size)(&cbSize); 1643 if (SUCCEEDED(rc) && fOptLong) 1644 RTPrintf("Size: %llu bytes (%Rhcb)\n", cbSize, cbSize); 1645 else if (SUCCEEDED(rc)) 1646 RTPrintf("Size: %Rhcb\n", cbSize); 1647 else 1648 { 1649 RTPrintf("Size: %Rhrc\n", rc); 1650 com::GlueHandleComErrorNoCtx(pHostDrive, rc); 1651 } 1652 1621 1653 ULONG cbSectorSize = 0; 1622 LONG64 cbSize = 0; 1623 PartitioningType_T partitioningType; 1624 HRESULT hrc; 1625 if ( SUCCEEDED(hrc = pHostDrive->COMGETTER(Uuid)(bstrUuidDisk.asOutParam())) 1626 && SUCCEEDED(hrc = pHostDrive->COMGETTER(SectorSize)(&cbSectorSize)) 1627 && SUCCEEDED(hrc = pHostDrive->COMGETTER(Size)(&cbSize)) 1628 && SUCCEEDED(hrc = pHostDrive->COMGETTER(PartitioningType)(&partitioningType))) 1629 { 1630 if (partitioningType == PartitioningType_GPT || com::Guid(bstrUuidDisk).isZero()) 1631 RTPrintf("UUID: %ls\n", bstrUuidDisk.raw()); 1654 rc = pHostDrive->COMGETTER(SectorSize)(&cbSectorSize); 1655 if (SUCCEEDED(rc)) 1656 RTPrintf("Sector Size: %u bytes\n", cbSectorSize); 1657 else 1658 { 1659 RTPrintf("Sector Size: %Rhrc\n", rc); 1660 com::GlueHandleComErrorNoCtx(pHostDrive, rc); 1661 } 1662 1663 PartitioningType_T partitioningType = (PartitioningType_T)9999; 1664 rc = pHostDrive->COMGETTER(PartitioningType)(&partitioningType); 1665 if (SUCCEEDED(rc)) 1666 RTPrintf("Scheme: %s\n", partitioningType == PartitioningType_MBR ? "MBR" : "GPT"); 1667 else 1668 { 1669 RTPrintf("Scheme: %Rhrc\n", rc); 1670 com::GlueHandleComErrorNoCtx(pHostDrive, rc); 1671 } 1672 1673 com::SafeIfaceArray<IHostDrivePartition> apHostDrivesPartitions; 1674 rc = pHostDrive->COMGETTER(Partitions)(ComSafeArrayAsOutParam(apHostDrivesPartitions)); 1675 if (FAILED(rc)) 1676 { 1677 RTPrintf("Partitions: %Rhrc\n", rc); 1678 com::GlueHandleComErrorNoCtx(pHostDrive, rc); 1679 } 1680 else if (apHostDrivesPartitions.size() == 0) 1681 RTPrintf("Partitions: None (or not able to grok them).\n"); 1682 else if (partitioningType == PartitioningType_MBR) 1683 { 1632 1684 if (fOptLong) 1633 RTPrintf("Size: %llu bytes (%Rhcb)\n", cbSize, cbSize); 1685 RTPrintf("Partitions: First Last\n" 1686 "## Type Byte Size Byte Offset Cyl/Head/Sec Cyl/Head/Sec Active\n"); 1634 1687 else 1635 RTPrintf("Size: %Rhcb\n", cbSize); 1636 RTPrintf("Sector Size: %u bytes\n", cbSectorSize); 1637 RTPrintf("Scheme: %s\n", partitioningType == PartitioningType_MBR ? "MBR" : "GPT"); 1638 1639 com::SafeIfaceArray<IHostDrivePartition> apHostDrivesPartitions; 1640 CHECK_ERROR(pHostDrive, COMGETTER(Partitions)(ComSafeArrayAsOutParam(apHostDrivesPartitions))); 1641 1642 if (partitioningType == PartitioningType_MBR) 1688 RTPrintf("Partitions: First Last\n" 1689 "## Type Size Start Cyl/Head/Sec Cyl/Head/Sec Active\n"); 1690 for (size_t j = 0; j < apHostDrivesPartitions.size(); ++j) 1643 1691 { 1692 ComPtr<IHostDrivePartition> pHostDrivePartition = apHostDrivesPartitions[j]; 1693 1694 ULONG idx = 0; 1695 CHECK_ERROR(pHostDrivePartition, COMGETTER(Number)(&idx)); 1696 ULONG uType = 0; 1697 CHECK_ERROR(pHostDrivePartition, COMGETTER(TypeMBR)(&uType)); 1698 ULONG uStartCylinder = 0; 1699 CHECK_ERROR(pHostDrivePartition, COMGETTER(StartCylinder)(&uStartCylinder)); 1700 ULONG uStartHead = 0; 1701 CHECK_ERROR(pHostDrivePartition, COMGETTER(StartHead)(&uStartHead)); 1702 ULONG uStartSector = 0; 1703 CHECK_ERROR(pHostDrivePartition, COMGETTER(StartSector)(&uStartSector)); 1704 ULONG uEndCylinder = 0; 1705 CHECK_ERROR(pHostDrivePartition, COMGETTER(EndCylinder)(&uEndCylinder)); 1706 ULONG uEndHead = 0; 1707 CHECK_ERROR(pHostDrivePartition, COMGETTER(EndHead)(&uEndHead)); 1708 ULONG uEndSector = 0; 1709 CHECK_ERROR(pHostDrivePartition, COMGETTER(EndSector)(&uEndSector)); 1710 cbSize = 0; 1711 CHECK_ERROR(pHostDrivePartition, COMGETTER(Size)(&cbSize)); 1712 LONG64 offStart = 0; 1713 CHECK_ERROR(pHostDrivePartition, COMGETTER(Start)(&offStart)); 1714 BOOL fActive = 0; 1715 CHECK_ERROR(pHostDrivePartition, COMGETTER(Active)(&fActive)); 1716 PartitionType_T enmType = PartitionType_Unknown; 1717 CHECK_ERROR(pHostDrivePartition, COMGETTER(Type)(&enmType)); 1718 1719 /* Max size & offset here is around 16TiB with 4KiB sectors. */ 1720 if (fOptLong) /* cb/off: max 16TiB; idx: max 64. */ 1721 RTPrintf("%2u %02x %14llu %14llu %4u/%3u/%2u %4u/%3u/%2u %s %s\n", 1722 idx, uType, cbSize, offStart, 1723 uStartCylinder, uStartHead, uStartSector, uEndCylinder, uEndHead, uEndSector, 1724 fActive ? "yes" : "no", PartitionTypeToString(enmType, "")); 1725 else 1726 RTPrintf("%2u %02x %8Rhcb %8Rhcb %4u/%3u/%2u %4u/%3u/%2u %s %s\n", 1727 idx, uType, (uint64_t)cbSize, (uint64_t)offStart, 1728 uStartCylinder, uStartHead, uStartSector, uEndCylinder, uEndHead, uEndSector, 1729 fActive ? "yes" : "no", PartitionTypeToString(enmType, "")); 1730 } 1731 } 1732 else /* GPT */ 1733 { 1734 /* Determin the max partition type length to try reduce the table width: */ 1735 size_t cchMaxType = 0; 1736 for (size_t j = 0; j < apHostDrivesPartitions.size(); ++j) 1737 { 1738 ComPtr<IHostDrivePartition> pHostDrivePartition = apHostDrivesPartitions[j]; 1739 PartitionType_T enmType = PartitionType_Unknown; 1740 CHECK_ERROR(pHostDrivePartition, COMGETTER(Type)(&enmType)); 1741 size_t const cchTypeNm = strlen(PartitionTypeToString(enmType, "e530bf6d-2754-4e9d-b260-60a5d0b80457")); 1742 cchMaxType = RT_MAX(cchTypeNm, cchMaxType); 1743 } 1744 cchMaxType = RT_MIN(cchMaxType, RTUUID_STR_LENGTH); 1745 1746 if (fOptLong) 1747 RTPrintf("Partitions:\n" 1748 "## %-*s Uuid Byte Size Byte Offset Active Name\n", 1749 (int)cchMaxType, "Type"); 1750 else 1751 RTPrintf("Partitions:\n" 1752 "## %-*s Uuid Size Start Active Name\n", 1753 (int)cchMaxType, "Type"); 1754 1755 for (size_t j = 0; j < apHostDrivesPartitions.size(); ++j) 1756 { 1757 ComPtr<IHostDrivePartition> pHostDrivePartition = apHostDrivesPartitions[j]; 1758 1759 ULONG idx = 0; 1760 CHECK_ERROR(pHostDrivePartition, COMGETTER(Number)(&idx)); 1761 com::Bstr bstrUuidType; 1762 CHECK_ERROR(pHostDrivePartition, COMGETTER(TypeUuid)(bstrUuidType.asOutParam())); 1763 com::Bstr bstrUuidPartition; 1764 CHECK_ERROR(pHostDrivePartition, COMGETTER(Uuid)(bstrUuidPartition.asOutParam())); 1765 cbSize = 0; 1766 CHECK_ERROR(pHostDrivePartition, COMGETTER(Size)(&cbSize)); 1767 LONG64 offStart = 0; 1768 CHECK_ERROR(pHostDrivePartition, COMGETTER(Start)(&offStart)); 1769 BOOL fActive = 0; 1770 CHECK_ERROR(pHostDrivePartition, COMGETTER(Active)(&fActive)); 1771 com::Bstr bstrName; 1772 CHECK_ERROR(pHostDrivePartition, COMGETTER(Name)(bstrName.asOutParam())); 1773 1774 PartitionType_T enmType = PartitionType_Unknown; 1775 CHECK_ERROR(pHostDrivePartition, COMGETTER(Type)(&enmType)); 1776 1777 Utf8Str strTypeConv; 1778 const char *pszTypeNm = PartitionTypeToString(enmType, NULL); 1779 if (!pszTypeNm) 1780 pszTypeNm = (strTypeConv = bstrUuidType).c_str(); 1781 else if (strlen(pszTypeNm) >= RTUUID_STR_LENGTH /* includes '\0' */) 1782 pszTypeNm -= RTUUID_STR_LENGTH - 1 - strlen(pszTypeNm); 1783 1644 1784 if (fOptLong) 1645 RTPrintf(" Partitions: First Last\n"1646 "## Type Byte Size Byte Offset Cyl/Head/Sec Cyl/Head/Sec Active\n");1785 RTPrintf("%2u %-*s %36ls %19llu %19llu %-3s %ls\n", idx, cchMaxType, pszTypeNm, 1786 bstrUuidPartition.raw(), cbSize, offStart, fActive ? "on" : "off", bstrName.raw()); 1647 1787 else 1648 RTPrintf("Partitions: First Last\n" 1649 "## Type Size Start Cyl/Head/Sec Cyl/Head/Sec Active\n"); 1650 for (size_t j = 0; j < apHostDrivesPartitions.size(); ++j) 1651 { 1652 ComPtr<IHostDrivePartition> pHostDrivePartition = apHostDrivesPartitions[j]; 1653 1654 ULONG idx = 0; 1655 CHECK_ERROR(pHostDrivePartition, COMGETTER(Number)(&idx)); 1656 ULONG uType = 0; 1657 CHECK_ERROR(pHostDrivePartition, COMGETTER(TypeMBR)(&uType)); 1658 ULONG uStartCylinder = 0; 1659 CHECK_ERROR(pHostDrivePartition, COMGETTER(StartCylinder)(&uStartCylinder)); 1660 ULONG uStartHead = 0; 1661 CHECK_ERROR(pHostDrivePartition, COMGETTER(StartHead)(&uStartHead)); 1662 ULONG uStartSector = 0; 1663 CHECK_ERROR(pHostDrivePartition, COMGETTER(StartSector)(&uStartSector)); 1664 ULONG uEndCylinder = 0; 1665 CHECK_ERROR(pHostDrivePartition, COMGETTER(EndCylinder)(&uEndCylinder)); 1666 ULONG uEndHead = 0; 1667 CHECK_ERROR(pHostDrivePartition, COMGETTER(EndHead)(&uEndHead)); 1668 ULONG uEndSector = 0; 1669 CHECK_ERROR(pHostDrivePartition, COMGETTER(EndSector)(&uEndSector)); 1670 cbSize = 0; 1671 CHECK_ERROR(pHostDrivePartition, COMGETTER(Size)(&cbSize)); 1672 LONG64 offStart = 0; 1673 CHECK_ERROR(pHostDrivePartition, COMGETTER(Start)(&offStart)); 1674 BOOL fActive = 0; 1675 CHECK_ERROR(pHostDrivePartition, COMGETTER(Active)(&fActive)); 1676 PartitionType_T enmType = PartitionType_Unknown; 1677 CHECK_ERROR(pHostDrivePartition, COMGETTER(Type)(&enmType)); 1678 1679 /* Max size & offset here is around 16TiB with 4KiB sectors. */ 1680 if (fOptLong) /* cb/off: max 16TiB; idx: max 64. */ 1681 RTPrintf("%2u %02x %14llu %14llu %4u/%3u/%2u %4u/%3u/%2u %s %s\n", 1682 idx, uType, cbSize, offStart, 1683 uStartCylinder, uStartHead, uStartSector, uEndCylinder, uEndHead, uEndSector, 1684 fActive ? "yes" : "no", PartitionTypeToString(enmType, "")); 1685 else 1686 RTPrintf("%2u %02x %8Rhcb %8Rhcb %4u/%3u/%2u %4u/%3u/%2u %s %s\n", 1687 idx, uType, (uint64_t)cbSize, (uint64_t)offStart, 1688 uStartCylinder, uStartHead, uStartSector, uEndCylinder, uEndHead, uEndSector, 1689 fActive ? "yes" : "no", PartitionTypeToString(enmType, "")); 1690 } 1788 RTPrintf("%2u %-*s %36ls %8Rhcb %8Rhcb %-3s %ls\n", idx, cchMaxType, pszTypeNm, 1789 bstrUuidPartition.raw(), cbSize, offStart, fActive ? "on" : "off", bstrName.raw()); 1691 1790 } 1692 else /* GPT */ 1693 { 1694 /* Determin the max partition type length to try reduce the table width: */ 1695 size_t cchMaxType = 0; 1696 for (size_t j = 0; j < apHostDrivesPartitions.size(); ++j) 1697 { 1698 ComPtr<IHostDrivePartition> pHostDrivePartition = apHostDrivesPartitions[j]; 1699 PartitionType_T enmType = PartitionType_Unknown; 1700 CHECK_ERROR(pHostDrivePartition, COMGETTER(Type)(&enmType)); 1701 size_t const cchTypeNm = strlen(PartitionTypeToString(enmType, "e530bf6d-2754-4e9d-b260-60a5d0b80457")); 1702 cchMaxType = RT_MAX(cchTypeNm, cchMaxType); 1703 } 1704 cchMaxType = RT_MIN(cchMaxType, RTUUID_STR_LENGTH); 1705 1706 if (fOptLong) 1707 RTPrintf("Partitions:\n" 1708 "## %-*s Uuid Byte Size Byte Offset Active Name\n", 1709 (int)cchMaxType, "Type"); 1710 else 1711 RTPrintf("Partitions:\n" 1712 "## %-*s Uuid Size Start Active Name\n", 1713 (int)cchMaxType, "Type"); 1714 1715 for (size_t j = 0; j < apHostDrivesPartitions.size(); ++j) 1716 { 1717 ComPtr<IHostDrivePartition> pHostDrivePartition = apHostDrivesPartitions[j]; 1718 1719 ULONG idx = 0; 1720 CHECK_ERROR(pHostDrivePartition, COMGETTER(Number)(&idx)); 1721 com::Bstr bstrUuidType; 1722 CHECK_ERROR(pHostDrivePartition, COMGETTER(TypeUuid)(bstrUuidType.asOutParam())); 1723 com::Bstr bstrUuidPartition; 1724 CHECK_ERROR(pHostDrivePartition, COMGETTER(Uuid)(bstrUuidPartition.asOutParam())); 1725 cbSize = 0; 1726 CHECK_ERROR(pHostDrivePartition, COMGETTER(Size)(&cbSize)); 1727 LONG64 offStart = 0; 1728 CHECK_ERROR(pHostDrivePartition, COMGETTER(Start)(&offStart)); 1729 BOOL fActive = 0; 1730 CHECK_ERROR(pHostDrivePartition, COMGETTER(Active)(&fActive)); 1731 com::Bstr bstrName; 1732 CHECK_ERROR(pHostDrivePartition, COMGETTER(Name)(bstrName.asOutParam())); 1733 1734 PartitionType_T enmType = PartitionType_Unknown; 1735 CHECK_ERROR(pHostDrivePartition, COMGETTER(Type)(&enmType)); 1736 1737 Utf8Str strTypeConv; 1738 const char *pszTypeNm = PartitionTypeToString(enmType, NULL); 1739 if (!pszTypeNm) 1740 pszTypeNm = (strTypeConv = bstrUuidType).c_str(); 1741 else if (strlen(pszTypeNm) >= RTUUID_STR_LENGTH /* includes '\0' */) 1742 pszTypeNm -= RTUUID_STR_LENGTH - 1 - strlen(pszTypeNm); 1743 1744 if (fOptLong) 1745 RTPrintf("%2u %-*s %36ls %19llu %19llu %-3s %ls\n", idx, cchMaxType, pszTypeNm, 1746 bstrUuidPartition.raw(), cbSize, offStart, fActive ? "on" : "off", bstrName.raw()); 1747 else 1748 RTPrintf("%2u %-*s %36ls %8Rhcb %8Rhcb %-3s %ls\n", idx, cchMaxType, pszTypeNm, 1749 bstrUuidPartition.raw(), cbSize, offStart, fActive ? "on" : "off", bstrName.raw()); 1750 } 1751 } 1752 } 1753 else 1754 RTPrintf("Partitions and disk info for the drive %ls are not available. Error %Rhrc (%#RX32)\n", 1755 bstrDrivePath.raw(), hrc, hrc); 1791 } 1756 1792 } 1757 1793 return rc;
Note:
See TracChangeset
for help on using the changeset viewer.