Changeset 40240 in vbox for trunk/src/VBox/Storage/testcase
- Timestamp:
- Feb 23, 2012 8:51:34 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Storage/testcase/vbox-img.cpp
r38945 r40240 60 60 " --size <size in bytes>\n" 61 61 " [--format VDI|VMDK|VHD] (default: VDI)\n" 62 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n", 62 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n" 63 "\n" 64 " repair --filename <filename>\n" 65 " [--dry-run]\n" 66 " [--format VDI|VMDK|VHD] (default: autodetect)\n", 63 67 g_pszProgName); 64 68 } … … 1158 1162 1159 1163 1164 int handleRepair(HandlerArg *a) 1165 { 1166 int rc = VINF_SUCCESS; 1167 PVBOXHDD pDisk = NULL; 1168 const char *pszFilename = NULL; 1169 char *pszBackend = NULL; 1170 const char *pszFormat = NULL; 1171 bool fDryRun = false; 1172 VDTYPE enmType = VDTYPE_HDD; 1173 1174 /* Parse the command line. */ 1175 static const RTGETOPTDEF s_aOptions[] = 1176 { 1177 { "--filename", 'f', RTGETOPT_REQ_STRING }, 1178 { "--dry-run", 'd', RTGETOPT_REQ_NOTHING }, 1179 { "--format", 'b', RTGETOPT_REQ_STRING } 1180 }; 1181 int ch; 1182 RTGETOPTUNION ValueUnion; 1183 RTGETOPTSTATE GetState; 1184 RTGetOptInit(&GetState, a->argc, a->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 0, 0 /* fFlags */); 1185 while ((ch = RTGetOpt(&GetState, &ValueUnion))) 1186 { 1187 switch (ch) 1188 { 1189 case 'f': // --filename 1190 pszFilename = ValueUnion.psz; 1191 break; 1192 1193 case 'd': // --dry-run 1194 fDryRun = true; 1195 break; 1196 1197 case 'b': // --format 1198 pszFormat = ValueUnion.psz; 1199 break; 1200 1201 default: 1202 ch = RTGetOptPrintError(ch, &ValueUnion); 1203 printUsage(g_pStdErr); 1204 return ch; 1205 } 1206 } 1207 1208 /* Check for mandatory parameters. */ 1209 if (!pszFilename) 1210 return errorSyntax("Mandatory --filename option missing\n"); 1211 1212 /* just try it */ 1213 if (!pszFormat) 1214 { 1215 rc = VDGetFormat(NULL, NULL, pszFilename, &pszBackend, &enmType); 1216 if (RT_FAILURE(rc)) 1217 return errorSyntax("Format autodetect failed: %Rrc\n", rc); 1218 pszFormat = pszBackend; 1219 } 1220 1221 rc = VDRepair(pVDIfs, NULL, pszFilename, pszFormat, fDryRun ? VD_REPAIR_DRY_RUN : 0); 1222 if (RT_FAILURE(rc)) 1223 rc = errorRuntime("Error while repairing the virtual disk: %Rrc\n", rc); 1224 1225 if (pszBackend) 1226 RTStrFree(pszBackend); 1227 return rc; 1228 } 1229 1230 1160 1231 int main(int argc, char *argv[]) 1161 1232 { … … 1246 1317 { "createcache", handleCreateCache }, 1247 1318 { "createbase", handleCreateBase }, 1319 { "repair", handleRepair }, 1248 1320 { NULL, NULL } 1249 1321 };
Note:
See TracChangeset
for help on using the changeset viewer.