Changeset 32380 in vbox for trunk/src/VBox/Devices
- Timestamp:
- Sep 10, 2010 9:45:19 AM (14 years ago)
- Location:
- trunk/src/VBox/Devices/Storage/testcase
- Files:
-
- 1 deleted
- 1 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/testcase/Makefile.kmk
r31594 r32380 49 49 # 50 50 ifdef VBOX_WITH_TESTCASES 51 PROGRAMS += tstVD tstVD-2 tstVDCopy tstVDSnap tstVDShareable tstVDSetUuid 52 if1of ($(KBUILD_TARGET), darwin freebsd linux win solaris) 53 # disable as no longer required 54 # PROGRAMS += VBoxFixHdd 55 endif 56 ifeq ($(KBUILD_TARGET),l4) 57 tstVD_TEMPLATE = VBOXLNXHOSTR3EXE 58 tstVD-2_TEMPLATE = VBOXLNXHOSTR3EXE 59 tstVDCopy_TEMPLATE = VBOXLNXHOSTR3EXE 60 tstVDSnap_TEMPLATE = VBOXLNXHOSTR3EXE 61 tstVDShareable_TEMPLATE = VBOXLNXHOSTR3EXE 62 tstVDSetUuid_TEMPLATE = VBOXLNXHOSTR3EXE 63 else 64 tstVD_TEMPLATE = VBOXR3TSTEXE 65 tstVD-2_TEMPLATE = VBOXR3TSTEXE 66 tstVDCopy_TEMPLATE = VBOXR3TSTEXE 67 tstVDSnap_TEMPLATE = VBOXR3TSTEXE 68 tstVDShareable_TEMPLATE = VBOXR3TSTEXE 69 tstVDSetUuid_TEMPLATE = VBOXR3TSTEXE 70 VBoxFixHdd_TEMPLATE = VBOXR3STATIC 71 endif 51 PROGRAMS += tstVD tstVD-2 tstVDCopy tstVDSnap tstVDShareable vbox-img 52 tstVD_TEMPLATE = VBOXR3TSTEXE 53 tstVD-2_TEMPLATE = VBOXR3TSTEXE 54 tstVDCopy_TEMPLATE = VBOXR3TSTEXE 55 tstVDSnap_TEMPLATE = VBOXR3TSTEXE 56 tstVDShareable_TEMPLATE = VBOXR3TSTEXE 57 vbox-img_TEMPLATE = VBOXR3STATIC 72 58 tstVD_LIBS = $(LIB_DDU) $(LIB_RUNTIME) 73 59 tstVD-2_LIBS = $(LIB_DDU) $(LIB_RUNTIME) … … 76 62 tstVDShareable_LIBS = $(LIB_DDU) $(LIB_RUNTIME) 77 63 tstVDSetUuid_LIBS = $(LIB_DDU) $(LIB_RUNTIME) 78 VBoxFixHdd_LIBS = \64 vbox-img_LIBS = \ 79 65 $(VBOX_LIB_RUNTIME_STATIC) 80 66 if1of ($(KBUILD_TARGET),os2 win) 81 VBoxFixHdd_LIBS += \67 vbox-img_LIBS += \ 82 68 $(PATH_LIB)/VBox-liblzf-static$(VBOX_SUFF_LIB) \ 83 69 $(PATH_LIB)/VBox-zlib-static$(VBOX_SUFF_LIB) 84 70 else 85 VBoxFixHdd_LIBS += \71 vbox-img_LIBS += \ 86 72 $(PATH_LIB)/VBox-liblzf$(VBOX_SUFF_LIB) \ 87 73 $(SDK_VBOX_ZLIB_LIBS) 88 74 endif 89 75 ifeq ($(KBUILD_TARGET),linux) 90 VBoxFixHdd_LIBS += crypt76 vbox-img_LIBS += crypt 91 77 else ifeq ($(KBUILD_TARGET),darwin) 92 VBoxFixHdd_LIBS += iconv78 vbox-img_LIBS += iconv 93 79 else ifeq ($(KBUILD_TARGET),win) 94 VBoxFixHdd_SDKS.win = VBOX_NTDLL80 vbox-img_SDKS.win = VBOX_NTDLL 95 81 endif 96 82 tstVD_SOURCES = tstVD.cpp … … 99 85 tstVDSnap_SOURCES = tstVDSnap.cpp 100 86 tstVDShareable_SOURCES = tstVDShareable.cpp 101 tstVDSetUuid_SOURCES = tstVDSetUuid.cpp 102 VBoxFixHdd_SOURCES = \103 tstVDSetUuid.cpp \104 tstVDSetUuidStubs.cpp \87 88 vbox-img_SOURCES = \ 89 vbox-img.cpp \ 90 $(VBOX_PATH_DEVICES_SRC)/Storage/VCICacheCore.cpp \ 105 91 $(VBOX_PATH_DEVICES_SRC)/Storage/VBoxHDD.cpp \ 106 92 $(VBOX_PATH_DEVICES_SRC)/Storage/RawHDDCore.cpp \ … … 110 96 $(VBOX_PATH_DEVICES_SRC)/Storage/ParallelsHDDCore.cpp 111 97 ifdef VBOX_WITH_NEW_IO_CODE 112 VBoxFixHdd_DEFS += VBOX_WITH_NEW_IO_CODE98 vbox-img_DEFS += VBOX_WITH_NEW_IO_CODE 113 99 endif 114 VBoxFixHdd_DEFS += VBOX_HDD_NO_DYNAMIC_BACKENDS IN_VBOXDDU IN_VBOXDDU_STATIC IN_RT_R3100 vbox-img_DEFS += VBOX_HDD_NO_DYNAMIC_BACKENDS IN_VBOXDDU IN_VBOXDDU_STATIC IN_RT_R3 115 101 endif 116 102 -
trunk/src/VBox/Devices/Storage/testcase/vbox-img.cpp
r32370 r32380 1 1 /* $Id$ */ 2 2 /** @file 3 * S imple VBox HDD container test utility for changing the uuid of images.3 * Standalone image manipulation tool 4 4 */ 5 5 … … 21 21 #include <VBox/VBoxHDD.h> 22 22 #include <VBox/err.h> 23 #include <VBox/version.h> 23 24 #include <iprt/initterm.h> 24 25 #include <iprt/buildconfig.h> … … 29 30 #include <iprt/message.h> 30 31 #include <iprt/getopt.h> 32 #include <iprt/assert.h> 31 33 32 34 const char *g_pszProgName = ""; 33 34 static const RTGETOPTDEF s_aOptions[] =35 {36 { "--filename", 'f', RTGETOPT_REQ_STRING },37 { "--format", 'o', RTGETOPT_REQ_STRING },38 { "--uuid", 'u', RTGETOPT_REQ_UUID },39 { "--parentuuid", 'p', RTGETOPT_REQ_UUID },40 { "--zeroparentuuid", 'P', RTGETOPT_REQ_NOTHING }41 };42 43 35 static void showUsage(void) 44 36 { 45 37 RTStrmPrintf(g_pStdErr, 46 38 "Usage: %s\n" 47 " 39 " setuuid --filename <filename>\n" 48 40 " [--format VDI|VMDK|VHD|...]\n" 49 41 " [--uuid <uuid>]\n" 50 42 " [--parentuuid <uuid>]\n" 51 " [--zeroparentuuid]\n", 43 " [--zeroparentuuid]\n" 44 "\n" 45 " convert --srcfilename <filename>\n" 46 " --dstfilename <filename>\n" 47 " [--srcformat VDI|VMDK|VHD|RAW|..]\n" 48 " [--dstformat VDI|VMDK|VHD|RAW|..]\n" 49 " [--variant Standard,Fixed,Split2G,Stream,ESX]\n", 52 50 g_pszProgName); 53 51 } 52 53 /** command handler argument */ 54 struct HandlerArg 55 { 56 int argc; 57 char **argv; 58 }; 59 60 PVDINTERFACE pVDIfs; 54 61 55 62 static DECLCALLBACK(void) handleVDError(void *pvUser, int rc, RT_SRC_POS_DECL, … … 71 78 } 72 79 73 int main(int argc, char *argv[]) 74 { 75 RTR3Init(); 76 int rc; 80 /** 81 * Print a usage synopsis and the syntax error message. 82 */ 83 int errorSyntax(const char *pszFormat, ...) 84 { 85 va_list args; 86 87 va_start(args, pszFormat); 88 RTPrintf("\n" 89 "Syntax error: %N\n", pszFormat, &args); 90 va_end(args); 91 return 1; 92 } 93 94 95 int handleSetUUID(HandlerArg *a) 96 { 77 97 const char *pszFilename = NULL; 78 98 char *pszFormat = NULL; … … 81 101 bool fSetImageUuid = false; 82 102 bool fSetParentUuid = false; 83 84 g_pszProgName = RTPathFilename(argv[0]);85 86 103 RTUuidClear(&imageUuid); 87 104 RTUuidClear(&parentUuid); 88 105 int rc; 106 89 107 /* Parse the command line. */ 108 static const RTGETOPTDEF s_aOptions[] = 109 { 110 { "--filename", 'f', RTGETOPT_REQ_STRING }, 111 { "--format", 'o', RTGETOPT_REQ_STRING }, 112 { "--uuid", 'u', RTGETOPT_REQ_UUID }, 113 { "--parentuuid", 'p', RTGETOPT_REQ_UUID }, 114 { "--zeroparentuuid", 'P', RTGETOPT_REQ_NOTHING } 115 }; 90 116 int ch; 91 117 RTGETOPTUNION ValueUnion; 92 118 RTGETOPTSTATE GetState; 93 RTGetOptInit(&GetState, a rgc, argv, s_aOptions, RT_ELEMENTS(s_aOptions), 1, 0 /* fFlags */);119 RTGetOptInit(&GetState, a->argc, a->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 0, 0 /* fFlags */); 94 120 while ((ch = RTGetOpt(&GetState, &ValueUnion))) 95 121 { … … 114 140 fSetParentUuid = true; 115 141 break; 116 case 'h': // --help 117 showUsage(); 118 return 0; 119 case 'V': // --version 120 RTPrintf("%sr%s\n", RTBldCfgVersion(), RTBldCfgRevisionStr()); 121 return 0; 142 122 143 default: 123 144 ch = RTGetOptPrintError(ch, &ValueUnion); … … 126 147 } 127 148 } 128 149 129 150 /* Check for mandatory parameters. */ 130 151 if (!pszFilename) 131 { 132 RTMsgError("Mandatory --filename option missing\n"); 133 showUsage(); 134 return 1; 135 } 136 152 return errorSyntax("Mandatory --filename option missing\n"); 153 137 154 /* Check for consistency of optional parameters. */ 138 155 if (fSetImageUuid && RTUuidIsNull(&imageUuid)) 139 { 140 RTMsgError("Invalid parameter to --uuid option\n"); 141 showUsage(); 142 return 1; 143 } 144 145 PVDINTERFACE pVDIfs = NULL; 156 return errorSyntax("Invalid parameter to --uuid option\n"); 157 158 /* Autodetect image format. */ 159 if (!pszFormat) 160 { 161 /* Don't pass error interface, as that would triggers error messages 162 * because some backends fail to open the image. */ 163 rc = VDGetFormat(NULL, pszFilename, &pszFormat); 164 if (RT_FAILURE(rc)) 165 return errorSyntax("Format autodetect failed: %Rrc\n", rc); 166 } 167 168 PVBOXHDD pVD = NULL; 169 rc = VDCreate(pVDIfs, &pVD); 170 if (RT_FAILURE(rc)) 171 return errorSyntax("Cannot create the virtual disk container: %Rrc\n", rc); 172 173 174 rc = VDOpen(pVD, pszFormat, pszFilename, VD_OPEN_FLAGS_NORMAL, NULL); 175 if (RT_FAILURE(rc)) 176 return errorSyntax("Cannot open the virtual disk image \"%s\": %Rrc\n", 177 pszFilename, rc); 178 179 RTUUID oldImageUuid; 180 rc = VDGetUuid(pVD, VD_LAST_IMAGE, &oldImageUuid); 181 if (RT_FAILURE(rc)) 182 return errorSyntax("Cannot get UUID of virtual disk image \"%s\": %Rrc\n", 183 pszFilename, rc); 184 185 RTPrintf("Old image UUID: %RTuuid\n", &oldImageUuid); 186 187 RTUUID oldParentUuid; 188 rc = VDGetParentUuid(pVD, VD_LAST_IMAGE, &oldParentUuid); 189 if (RT_FAILURE(rc)) 190 return errorSyntax("Cannot get parent UUID of virtual disk image \"%s\": %Rrc\n", 191 pszFilename, rc); 192 193 RTPrintf("Old parent UUID: %RTuuid\n", &oldParentUuid); 194 195 if (fSetImageUuid) 196 { 197 RTPrintf("New image UUID: %RTuuid\n", &imageUuid); 198 rc = VDSetUuid(pVD, VD_LAST_IMAGE, &imageUuid); 199 if (RT_FAILURE(rc)) 200 return errorSyntax("Cannot set UUID of virtual disk image \"%s\": %Rrc\n", 201 pszFilename, rc); 202 } 203 204 if (fSetParentUuid) 205 { 206 RTPrintf("New parent UUID: %RTuuid\n", &parentUuid); 207 rc = VDSetParentUuid(pVD, VD_LAST_IMAGE, &parentUuid); 208 if (RT_FAILURE(rc)) 209 return errorSyntax("Cannot set parent UUID of virtual disk image \"%s\": %Rrc\n", 210 pszFilename, rc); 211 } 212 213 rc = VDCloseAll(pVD); 214 if (RT_FAILURE(rc)) 215 return errorSyntax("Closing image failed! rc=%Rrc\n", rc); 216 217 if (pszFormat) 218 { 219 RTStrFree(pszFormat); 220 pszFormat = NULL; 221 } 222 223 return 0; 224 } 225 226 227 int handleConvert(HandlerArg *a) 228 { 229 const char *pszSrcFilename = NULL; 230 const char *pszDstFilename = NULL; 231 char *pszSrcFormat = NULL; 232 char *pszDstFormat = NULL; 233 const char *pszVariant = NULL; 234 PVBOXHDD pSrcDisk = NULL; 235 PVBOXHDD pDstDisk = NULL; 236 unsigned uImageFlags = VD_IMAGE_FLAGS_NONE; 237 int rc = VINF_SUCCESS; 238 239 /* Parse the command line. */ 240 static const RTGETOPTDEF s_aOptions[] = 241 { 242 { "--srcfilename", 'i', RTGETOPT_REQ_STRING }, 243 { "--dstfilename", 'o', RTGETOPT_REQ_STRING }, 244 { "--srcformat", 's', RTGETOPT_REQ_STRING }, 245 { "--dstformat", 'd', RTGETOPT_REQ_STRING }, 246 { "--variant", 'v', RTGETOPT_REQ_STRING } 247 }; 248 int ch; 249 RTGETOPTUNION ValueUnion; 250 RTGETOPTSTATE GetState; 251 RTGetOptInit(&GetState, a->argc, a->argv, s_aOptions, RT_ELEMENTS(s_aOptions), 0, 0 /* fFlags */); 252 while ((ch = RTGetOpt(&GetState, &ValueUnion))) 253 { 254 switch (ch) 255 { 256 case 'i': // --srcfilename 257 pszSrcFilename = ValueUnion.psz; 258 break; 259 case 'o': // --dstfilename 260 pszDstFilename = ValueUnion.psz; 261 break; 262 case 's': // --srcformat 263 pszSrcFormat = RTStrDup(ValueUnion.psz); 264 break; 265 case 'd': // --dstformat 266 pszDstFormat = RTStrDup(ValueUnion.psz); 267 break; 268 case 'v': // --variant 269 pszVariant = ValueUnion.psz; 270 break; 271 272 default: 273 ch = RTGetOptPrintError(ch, &ValueUnion); 274 showUsage(); 275 return ch; 276 } 277 } 278 279 /* Check for mandatory parameters. */ 280 if (!pszSrcFilename) 281 return errorSyntax("Mandatory --srcfilename option missing\n"); 282 if (!pszDstFilename) 283 return errorSyntax("Mandatory --dstfilename option missing\n"); 284 285 /* check the variant parameter */ 286 if (pszVariant) 287 { 288 char *psz = (char*)pszVariant; 289 while (psz && *psz && RT_SUCCESS(rc)) 290 { 291 size_t len; 292 const char *pszComma = strchr(psz, ','); 293 if (pszComma) 294 len = pszComma - psz; 295 else 296 len = strlen(psz); 297 if (len > 0) 298 { 299 if (!RTStrNICmp(pszVariant, "standard", len)) 300 uImageFlags |= VD_IMAGE_FLAGS_NONE; 301 else if (!RTStrNICmp(pszVariant, "fixed", len)) 302 uImageFlags |= VD_IMAGE_FLAGS_FIXED; 303 else if (!RTStrNICmp(pszVariant, "split2g", len)) 304 uImageFlags |= VD_VMDK_IMAGE_FLAGS_SPLIT_2G; 305 else if (!RTStrNICmp(pszVariant, "stream", len)) 306 uImageFlags |= VD_VMDK_IMAGE_FLAGS_STREAM_OPTIMIZED; 307 else if (!RTStrNICmp(pszVariant, "esx", len)) 308 uImageFlags |= VD_VMDK_IMAGE_FLAGS_ESX; 309 else 310 return errorSyntax("Invalid --variant option\n"); 311 } 312 if (pszComma) 313 psz += len + 1; 314 else 315 psz += len; 316 } 317 } 318 319 do 320 { 321 /* try to determine input format if not specified */ 322 if (!pszSrcFormat) 323 { 324 rc = VDGetFormat(NULL, pszSrcFilename, &pszSrcFormat); 325 if (RT_FAILURE(rc)) 326 { 327 errorSyntax("No file format specified, please specify format: %Rrc\n", rc); 328 break; 329 } 330 } 331 332 rc = VDCreate(pVDIfs, &pSrcDisk); 333 if (RT_FAILURE(rc)) 334 { 335 errorSyntax("Error while creating source disk container: %Rrc\n", rc); 336 break; 337 } 338 339 rc = VDOpen(pSrcDisk, pszSrcFormat, pszSrcFilename, VD_OPEN_FLAGS_READONLY, NULL); 340 if (RT_FAILURE(rc)) 341 { 342 errorSyntax("Error while opening source image: %Rrc\n", rc); 343 break; 344 } 345 346 /* output format defaults to VDI */ 347 if (!pszDstFormat) 348 pszDstFormat = "VDI"; 349 350 rc = VDCreate(pVDIfs, &pDstDisk); 351 if (RT_FAILURE(rc)) 352 { 353 errorSyntax("Error while creating the destination disk container: %Rrc\n", rc); 354 break; 355 } 356 357 uint64_t cbSize = VDGetSize(pSrcDisk, VD_LAST_IMAGE); 358 RTPrintf("Converting image \"%s\" with size %RU64 bytes (%RU64MB)...\n", pszSrcFilename, cbSize, (cbSize + _1M - 1) / _1M); 359 360 /* Create the output image */ 361 rc = VDCopy(pSrcDisk, VD_LAST_IMAGE, pDstDisk, pszDstFormat, 362 pszDstFilename, false, 0, uImageFlags, NULL, NULL, NULL, NULL); 363 if (RT_FAILURE(rc)) 364 { 365 errorSyntax("Error while copying the image: %Rrc\n", rc); 366 break; 367 } 368 369 } 370 while (0); 371 372 if (pDstDisk) 373 VDCloseAll(pDstDisk); 374 if (pSrcDisk) 375 VDCloseAll(pSrcDisk); 376 377 return RT_SUCCESS(rc) ? 0 : 1; 378 } 379 380 381 void showLogo() 382 { 383 RTPrintf(VBOX_PRODUCT" Disk Utility " 384 VBOX_VERSION_STRING "\n" 385 "(C) 2005-" VBOX_C_YEAR " " VBOX_VENDOR "\n" 386 "All rights reserved.\n" 387 "\n"); 388 } 389 390 391 int main(int argc, char *argv[]) 392 { 393 RTR3Init(); 394 int rc; 395 396 g_pszProgName = RTPathFilename(argv[0]); 397 398 bool fShowLogo = true; 399 int iCmd = 1; 400 int iCmdArg; 401 402 /* global options */ 403 for (int i = 1; i < argc || argc <= iCmd; i++) 404 { 405 if ( argc <= iCmd 406 || !strcmp(argv[i], "help") 407 || !strcmp(argv[i], "-?") 408 || !strcmp(argv[i], "-h") 409 || !strcmp(argv[i], "-help") 410 || !strcmp(argv[i], "--help")) 411 { 412 showLogo(); 413 showUsage(); 414 return 0; 415 } 416 417 if ( !strcmp(argv[i], "-v") 418 || !strcmp(argv[i], "-version") 419 || !strcmp(argv[i], "-Version") 420 || !strcmp(argv[i], "--version")) 421 { 422 /* Print version number, and do nothing else. */ 423 RTPrintf("%sr%d\n", VBOX_VERSION_STRING, RTBldCfgRevision()); 424 return 0; 425 } 426 427 if ( !strcmp(argv[i], "--nologo") 428 || !strcmp(argv[i], "-nologo") 429 || !strcmp(argv[i], "-q")) 430 { 431 /* suppress the logo */ 432 fShowLogo = false; 433 iCmd++; 434 } 435 else 436 { 437 break; 438 } 439 } 440 441 iCmdArg = iCmd + 1; 442 443 if (fShowLogo) 444 showLogo(); 445 446 /* initialize the VD backend with dummy handlers */ 146 447 VDINTERFACE vdInterfaceError; 147 448 VDINTERFACEERROR vdInterfaceErrorCallbacks; … … 150 451 vdInterfaceErrorCallbacks.pfnError = handleVDError; 151 452 vdInterfaceErrorCallbacks.pfnMessage = handleVDMessage; 152 453 153 454 rc = VDInterfaceAdd(&vdInterfaceError, "VBoxManage_IError", VDINTERFACETYPE_ERROR, 154 455 &vdInterfaceErrorCallbacks, NULL, &pVDIfs); 155 156 /* Autodetect image format. */ 157 if (!pszFormat) 158 { 159 /* Don't pass error interface, as that would triggers error messages 160 * because some backends fail to open the image. */ 161 rc = VDGetFormat(NULL, pszFilename, &pszFormat); 162 if (RT_FAILURE(rc)) 163 { 164 RTMsgError("Format autodetect failed: %Rrc\n", rc); 165 return 1; 166 } 167 } 168 169 PVBOXHDD pVD = NULL; 170 rc = VDCreate(pVDIfs, &pVD); 171 if (RT_FAILURE(rc)) 172 { 173 RTMsgError("Cannot create the virtual disk container: %Rrc\n", rc); 174 return 1; 175 } 176 177 rc = VDOpen(pVD, pszFormat, pszFilename, VD_OPEN_FLAGS_NORMAL, NULL); 178 if (RT_FAILURE(rc)) 179 { 180 RTMsgError("Cannot open the virtual disk image \"%s\": %Rrc\n", 181 pszFilename, rc); 182 return 1; 183 } 184 185 RTUUID oldImageUuid; 186 rc = VDGetUuid(pVD, VD_LAST_IMAGE, &oldImageUuid); 187 if (RT_FAILURE(rc)) 188 { 189 RTMsgError("Cannot get UUID of virtual disk image \"%s\": %Rrc\n", 190 pszFilename, rc); 191 return 1; 192 } 193 RTPrintf("Old image UUID: %RTuuid\n", &oldImageUuid); 194 195 RTUUID oldParentUuid; 196 rc = VDGetParentUuid(pVD, VD_LAST_IMAGE, &oldParentUuid); 197 if (RT_FAILURE(rc)) 198 { 199 RTMsgError("Cannot get parent UUID of virtual disk image \"%s\": %Rrc\n", 200 pszFilename, rc); 201 return 1; 202 } 203 RTPrintf("Old parent UUID: %RTuuid\n", &oldParentUuid); 204 205 if (fSetImageUuid) 206 { 207 RTPrintf("New image UUID: %RTuuid\n", &imageUuid); 208 rc = VDSetUuid(pVD, VD_LAST_IMAGE, &imageUuid); 209 if (RT_FAILURE(rc)) 210 { 211 RTMsgError("Cannot set UUID of virtual disk image \"%s\": %Rrc\n", 212 pszFilename, rc); 213 return 1; 214 } 215 } 216 217 if (fSetParentUuid) 218 { 219 RTPrintf("New parent UUID: %RTuuid\n", &parentUuid); 220 rc = VDSetParentUuid(pVD, VD_LAST_IMAGE, &parentUuid); 221 if (RT_FAILURE(rc)) 222 { 223 RTMsgError("Cannot set parent UUID of virtual disk image \"%s\": %Rrc\n", 224 pszFilename, rc); 225 return 1; 226 } 227 } 228 229 rc = VDCloseAll(pVD); 230 if (RT_FAILURE(rc)) 231 { 232 RTMsgError("Closing image failed! rc=%Rrc\n", rc); 233 return 1; 234 } 235 236 if (pszFormat) 237 { 238 RTStrFree(pszFormat); 239 pszFormat = NULL; 240 } 456 457 rc = VDInit(); 458 if (RT_FAILURE(rc)) 459 return errorSyntax("Initalizing backends failed! rc=%Rrc\n"); 460 461 /* 462 * All registered command handlers 463 */ 464 static const struct 465 { 466 const char *command; 467 int (*handler)(HandlerArg *a); 468 } s_commandHandlers[] = 469 { 470 { "setuuid", handleSetUUID }, 471 { "convert", handleConvert }, 472 { NULL, NULL } 473 }; 474 475 HandlerArg handlerArg = { 0, NULL }; 476 int commandIndex; 477 for (commandIndex = 0; s_commandHandlers[commandIndex].command != NULL; commandIndex++) 478 { 479 if (!strcmp(s_commandHandlers[commandIndex].command, argv[iCmd])) 480 { 481 handlerArg.argc = argc - iCmdArg; 482 handlerArg.argv = &argv[iCmdArg]; 483 484 rc = s_commandHandlers[commandIndex].handler(&handlerArg); 485 break; 486 } 487 } 488 if (!s_commandHandlers[commandIndex].command) 489 return errorSyntax("Invalid command '%s'", argv[iCmd]); 241 490 242 491 rc = VDShutdown(); 243 492 if (RT_FAILURE(rc)) 244 { 245 RTMsgError("Unloading backends failed! rc=%Rrc\n", rc); 246 return 1; 247 } 248 249 return 0; 250 } 251 493 return errorSyntax("Unloading backends failed! rc=%Rrc\n", rc); 494 495 return rc; 496 } 497 498 /* dummy stub for RuntimeR3 */ 499 #ifndef RT_OS_WINDOWS 500 RTDECL(bool) RTAssertShouldPanic(void) 501 { 502 return true; 503 } 504 #endif
Note:
See TracChangeset
for help on using the changeset viewer.