Changeset 11131 in vbox for trunk/src/VBox/Frontends
- Timestamp:
- Aug 5, 2008 11:29:58 AM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxInternalManage.cpp
r11066 r11131 744 744 bool fRelative = false; 745 745 746 uint64_t cbSize = 0; 747 PVBOXHDD pDisk = NULL; 748 VBOXHDDRAW RawDescriptor; 749 HOSTPARTITIONS partitions; 750 uint32_t uPartitions = 0; 751 746 752 /* let's have a closer look at the arguments */ 747 753 for (int i = 0; i < argc; i++) … … 810 816 if (VBOX_FAILURE(vrc)) 811 817 { 812 RTPrintf("Error opening the raw disk: %Vrc\n", vrc); 813 return vrc; 814 } 815 816 uint64_t cbSize = 0; 818 RTPrintf("Error opening the raw disk '%s': %Vrc\n", rawdisk.raw(), vrc); 819 goto out; 820 } 821 817 822 #ifdef RT_OS_WINDOWS 818 823 /* Windows NT has no IOCTL_DISK_GET_LENGTH_INFORMATION ioctl. This was … … 838 843 } 839 844 else 840 return VERR_MEDIA_NOT_RECOGNIZED; 845 { 846 RTPrintf("File '%s' is no fixed medium device\n", rawdisk.raw()); 847 vrc = VERR_INVALID_PARAMETER; 848 goto out; 849 } 841 850 842 851 GET_LENGTH_INFORMATION DiskLenInfo; … … 851 860 } 852 861 else 853 rc = RTErrConvertFromWin32(GetLastError()); 862 { 863 vrc = RTErrConvertFromWin32(GetLastError()); 864 RTPrintf("Error getting the geometry of the raw disk '%s': %Vrc\n", rawdisk.raw(), vrc); 865 goto out; 866 } 854 867 #elif defined(RT_OS_LINUX) 855 868 struct stat DevStat; … … 875 888 cbSize = (uint64_t)cBlocks << 9; 876 889 else 877 return RTErrConvertFromErrno(errno); 890 { 891 vrc = RTErrConvertFromErrno(errno); 892 RTPrintf("Error getting the size of the raw disk '%s': %Vrc\n", rawdisk.raw(), vrc); 893 goto out; 894 } 878 895 } 879 896 } … … 881 898 { 882 899 RTPrintf("File '%s' is no block device\n", rawdisk.raw()); 883 return VERR_INVALID_PARAMETER; 900 vrc = VERR_INVALID_PARAMETER; 901 goto out; 884 902 } 885 903 #elif defined(RT_OS_DARWIN) … … 894 912 cbSize = cBlocks * cbBlock; 895 913 else 896 return RTErrConvertFromErrno(errno); 914 { 915 RTPrintf("Cannot get the block size for file '%s': %Vrc", rawdisk.raw(), vrc); 916 vrc = RTErrConvertFromErrno(errno); 917 goto out; 918 } 897 919 } 898 920 else 899 return RTErrConvertFromErrno(errno); 921 { 922 vrc = RTErrConvertFromErrno(errno); 923 RTPrintf("Cannot get the block count for file '%s': %Vrc", rawdisk.raw(), vrc); 924 goto out; 925 } 900 926 } 901 927 else 902 928 { 903 929 RTPrintf("File '%s' is no block device\n", rawdisk.raw()); 904 return VERR_INVALID_PARAMETER; 930 vrc = VERR_INVALID_PARAMETER; 931 goto out; 905 932 } 906 933 #elif defined(RT_OS_SOLARIS) … … 913 940 cbSize = mediainfo.dki_capacity * mediainfo.dki_lbsize; 914 941 else 915 return RTErrConvertFromErrno(errno); 942 { 943 vrc = RTErrConvertFromErrno(errno); 944 RTPrintf("Error getting the size of the raw disk '%s': %Vrc\n", rawdisk.raw(), vrc); 945 goto out; 946 } 916 947 } 917 948 else 918 949 { 919 950 RTPrintf("File '%s' is no block or char device\n", rawdisk.raw()); 920 return VERR_INVALID_PARAMETER; 951 vrc = VERR_INVALID_PARAMETER; 952 goto out; 921 953 } 922 954 #else /* all unrecognized OSes */ … … 926 958 if (VBOX_FAILURE(vrc)) 927 959 { 928 RTPrintf("Error getting the size of the raw disk : %Vrc\n", vrc);929 return vrc;960 RTPrintf("Error getting the size of the raw disk '%s': %Vrc\n", rawdisk.raw(), vrc); 961 goto out; 930 962 } 931 963 #endif … … 935 967 { 936 968 RTPrintf("Detected size of raw disk '%s' is %s, an invalid value\n", rawdisk.raw(), cbSize); 937 return VERR_INVALID_PARAMETER; 938 } 939 940 PVBOXHDD pDisk = NULL; 941 VBOXHDDRAW RawDescriptor; 942 HOSTPARTITIONS partitions; 943 uint32_t uPartitions = 0; 969 vrc = VERR_INVALID_PARAMETER; 970 goto out; 971 } 944 972 945 973 RawDescriptor.szSignature[0] = 'R'; … … 967 995 { 968 996 RTPrintf("Incorrect value in partitions parameter\n"); 969 return vrc;997 goto out; 970 998 } 971 999 uPartitions |= RT_BIT(u32); … … 976 1004 { 977 1005 RTPrintf("Incorrect separator in partitions parameter\n"); 978 return VERR_INVALID_PARAMETER; 1006 vrc = VERR_INVALID_PARAMETER; 1007 goto out; 979 1008 } 980 1009 } … … 984 1013 { 985 1014 RTPrintf("Error reading the partition information from '%s'\n", rawdisk.raw()); 986 return vrc;1015 goto out; 987 1016 } 988 1017 … … 1006 1035 RawDescriptor.pPartitions = (PVBOXHDDRAWPART)RTMemAllocZ(partitions.cPartitions * sizeof(VBOXHDDRAWPART)); 1007 1036 if (!RawDescriptor.pPartitions) 1008 return VERR_NO_MEMORY; 1037 { 1038 RTPrintf("Out of memory allocating the partition list for '%s'\n", rawdisk.raw()); 1039 vrc = VERR_NO_MEMORY; 1040 goto out; 1041 } 1009 1042 for (unsigned i = 0; i < partitions.cPartitions; i++) 1010 1043 { … … 1022 1055 RTPrintf("Error creating reference to individual partition %u, rc=%Vrc\n", 1023 1056 partitions.aPartitions[i].uIndex, vrc); 1024 return vrc;1057 goto out; 1025 1058 } 1026 1059 RawDescriptor.pPartitions[i].pszRawDevice = pszRawName; … … 1073 1106 void *pPartData = RTMemAlloc((size_t)RawDescriptor.pPartitions[i].cbPartitionData); 1074 1107 if (!pPartData) 1075 return VERR_NO_MEMORY; 1108 { 1109 RTPrintf("Out of memory allocating the partition descriptor for '%s'\n", rawdisk.raw()); 1110 vrc = VERR_NO_MEMORY; 1111 goto out; 1112 } 1076 1113 vrc = RTFileReadAt(RawFile, partitions.aPartitions[i].uPartDataStart * 512, pPartData, (size_t)RawDescriptor.pPartitions[i].cbPartitionData, NULL); 1077 1114 if (VBOX_FAILURE(vrc)) 1078 1115 { 1079 1116 RTPrintf("Cannot read partition data from raw device '%s': %Vrc\n", rawdisk.raw(), vrc); 1080 return vrc;1117 goto out; 1081 1118 } 1082 1119 /* Splice in the replacement MBR code if specified. */ … … 1089 1126 { 1090 1127 RTPrintf("Cannot open replacement MBR file '%s' specified with -mbr: %Vrc\n", pszMBRFilename, vrc); 1091 return vrc;1128 goto out; 1092 1129 } 1093 1130 vrc = RTFileReadAt(MBRFile, 0, pPartData, 0x1be, NULL); … … 1096 1133 { 1097 1134 RTPrintf("Cannot read replacement MBR file '%s': %Vrc\n", pszMBRFilename, vrc); 1098 return vrc;1135 goto out; 1099 1136 } 1100 1137 } … … 1120 1157 { 1121 1158 RTPrintf("Error while creating the virtual disk container: %Vrc\n", vrc); 1122 return vrc;1159 goto out; 1123 1160 } 1124 1161 … … 1139 1176 { 1140 1177 RTPrintf("Error while creating the raw disk VMDK: %Vrc\n", vrc); 1141 return vrc;1178 goto out; 1142 1179 } 1143 1180 RTPrintf("RAW host disk access VMDK file %s created successfully.\n", Utf8Str(filename).raw()); … … 1175 1212 1176 1213 return SUCCEEDED(rc) ? 0 : 1; 1214 1215 out: 1216 RTPrintf("The raw disk vmdk file was not created\n"); 1217 return VBOX_SUCCESS(vrc) ? 0 : 1; 1177 1218 } 1178 1219
Note:
See TracChangeset
for help on using the changeset viewer.