VirtualBox

Ignore:
Timestamp:
Sep 11, 2010 6:02:17 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
65796
Message:

scm cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/testcase/vbox-img.cpp

    r32395 r32431  
    8888{
    8989    va_list args;
    90    
     90
    9191    va_start(args, pszFormat);
    9292    RTPrintf("\n"
     
    9999{
    100100    va_list args;
    101    
     101
    102102    va_start(args, pszFormat);
    103103    RTPrintf("\n"
     
    120120    RTUuidClear(&parentUuid);
    121121    int rc;
    122    
     122
    123123    /* Parse the command line. */
    124124    static const RTGETOPTDEF s_aOptions[] =
     
    163163        }
    164164    }
    165    
     165
    166166    /* Check for mandatory parameters. */
    167167    if (!pszFilename)
    168168        return errorSyntax("Mandatory --filename option missing\n");
    169    
     169
    170170    /* Check for consistency of optional parameters. */
    171171    if (fSetImageUuid && RTUuidIsNull(&imageUuid))
    172172        return errorSyntax("Invalid parameter to --uuid option\n");
    173    
     173
    174174    /* Autodetect image format. */
    175175    if (!pszFormat)
     
    181181            return errorRuntime("Format autodetect failed: %Rrc\n", rc);
    182182    }
    183    
     183
    184184    PVBOXHDD pVD = NULL;
    185185    rc = VDCreate(pVDIfs, &pVD);
    186186    if (RT_FAILURE(rc))
    187187        return errorRuntime("Cannot create the virtual disk container: %Rrc\n", rc);
    188    
    189    
     188
     189
    190190    rc = VDOpen(pVD, pszFormat, pszFilename, VD_OPEN_FLAGS_NORMAL, NULL);
    191191    if (RT_FAILURE(rc))
    192192        return errorRuntime("Cannot open the virtual disk image \"%s\": %Rrc\n",
    193193                            pszFilename, rc);
    194    
     194
    195195    RTUUID oldImageUuid;
    196196    rc = VDGetUuid(pVD, VD_LAST_IMAGE, &oldImageUuid);
     
    198198        return errorRuntime("Cannot get UUID of virtual disk image \"%s\": %Rrc\n",
    199199                            pszFilename, rc);
    200    
     200
    201201    RTPrintf("Old image UUID:  %RTuuid\n", &oldImageUuid);
    202    
     202
    203203    RTUUID oldParentUuid;
    204204    rc = VDGetParentUuid(pVD, VD_LAST_IMAGE, &oldParentUuid);
     
    206206        return errorRuntime("Cannot get parent UUID of virtual disk image \"%s\": %Rrc\n",
    207207                            pszFilename, rc);
    208    
     208
    209209    RTPrintf("Old parent UUID: %RTuuid\n", &oldParentUuid);
    210    
     210
    211211    if (fSetImageUuid)
    212212    {
     
    217217                                pszFilename, rc);
    218218    }
    219    
     219
    220220    if (fSetParentUuid)
    221221    {
     
    226226                                pszFilename, rc);
    227227    }
    228    
     228
    229229    rc = VDCloseAll(pVD);
    230230    if (RT_FAILURE(rc))
    231231        return errorRuntime("Closing image failed! rc=%Rrc\n", rc);
    232    
     232
    233233    if (pszFormat)
    234234    {
     
    236236        pszFormat = NULL;
    237237    }
    238    
    239     return 0;   
     238
     239    return 0;
    240240}
    241241
     
    252252    unsigned uImageFlags = VD_IMAGE_FLAGS_NONE;
    253253    int rc = VINF_SUCCESS;
    254    
     254
    255255    /* Parse the command line. */
    256256    static const RTGETOPTDEF s_aOptions[] =
     
    292292        }
    293293    }
    294    
     294
    295295    /* Check for mandatory parameters. */
    296296    if (!pszSrcFilename)
     
    298298    if (!pszDstFilename)
    299299        return errorSyntax("Mandatory --dstfilename option missing\n");
    300    
     300
    301301    /* check the variant parameter */
    302302    if (pszVariant)
     
    332332        }
    333333    }
    334    
     334
    335335    do
    336336    {
     
    363363        if (!pszDstFormat)
    364364            pszDstFormat = "VDI";
    365        
     365
    366366        rc = VDCreate(pVDIfs, &pDstDisk);
    367367        if (RT_FAILURE(rc))
     
    370370            break;
    371371        }
    372        
     372
    373373        uint64_t cbSize = VDGetSize(pSrcDisk, VD_LAST_IMAGE);
    374374        RTPrintf("Converting image \"%s\" with size %RU64 bytes (%RU64MB)...\n", pszSrcFilename, cbSize, (cbSize + _1M - 1) / _1M);
    375        
     375
    376376        /* Create the output image */
    377377        rc = VDCopy(pSrcDisk, VD_LAST_IMAGE, pDstDisk, pszDstFormat,
     
    382382            break;
    383383        }
    384            
     384
    385385    }
    386386    while (0);
    387        
     387
    388388    if (pDstDisk)
    389389        VDCloseAll(pDstDisk);
    390390    if (pSrcDisk)
    391391        VDCloseAll(pSrcDisk);
    392    
     392
    393393    return RT_SUCCESS(rc) ? 0 : 1;
    394394}
     
    417417                pszFilename = ValueUnion.psz;
    418418                break;
    419                
     419
    420420            default:
    421421                ch = RTGetOptPrintError(ch, &ValueUnion);
     
    424424        }
    425425    }
    426    
     426
    427427    /* Check for mandatory parameters. */
    428428    if (!pszFilename)
    429429        return errorSyntax("Mandatory --filename option missing\n");
    430    
     430
    431431    /* just try it */
    432432    char *pszFormat = NULL;
     
    438438    if (RT_FAILURE(rc))
    439439        return errorRuntime("Error while creating the virtual disk container: %Rrc\n", rc);
    440    
     440
    441441    /* Open the image */
    442442    rc = VDOpen(pDisk, pszFormat, pszFilename, VD_OPEN_FLAGS_INFO, NULL);
    443443    if (RT_FAILURE(rc))
    444444        return errorRuntime("Error while opening the image: %Rrc\n", rc);
    445    
     445
    446446    VDDumpImages(pDisk);
    447    
     447
    448448    VDCloseAll(pDisk);
    449    
     449
    450450    return rc;
    451451}
     
    456456    PVBOXHDD pDisk = NULL;
    457457    const char *pszFilename = NULL;
    458    
     458
    459459    /* Parse the command line. */
    460460    static const RTGETOPTDEF s_aOptions[] =
     
    473473                pszFilename = ValueUnion.psz;
    474474                break;
    475                
     475
    476476            default:
    477477                ch = RTGetOptPrintError(ch, &ValueUnion);
     
    480480        }
    481481    }
    482    
     482
    483483    /* Check for mandatory parameters. */
    484484    if (!pszFilename)
    485485        return errorSyntax("Mandatory --filename option missing\n");
    486    
     486
    487487    /* just try it */
    488488    char *pszFormat = NULL;
     
    490490    if (RT_FAILURE(rc))
    491491        return errorSyntax("Format autodetect failed: %Rrc\n", rc);
    492    
     492
    493493    rc = VDCreate(pVDIfs, &pDisk);
    494494    if (RT_FAILURE(rc))
    495495        return errorRuntime("Error while creating the virtual disk container: %Rrc\n", rc);
    496    
     496
    497497    /* Open the image */
    498498    rc = VDOpen(pDisk, pszFormat, pszFilename, VD_OPEN_FLAGS_NORMAL, NULL);
    499499    if (RT_FAILURE(rc))
    500500        return errorRuntime("Error while opening the image: %Rrc\n", rc);
    501    
     501
    502502    rc = VDCompact(pDisk, 0, NULL);
    503503    if (RT_FAILURE(rc))
    504504        errorRuntime("Error while compacting image: %Rrc\n", rc);
    505    
     505
    506506    VDCloseAll(pDisk);
    507    
     507
    508508    return rc;
    509509}
     
    516516             "(C) 2005-" VBOX_C_YEAR " " VBOX_VENDOR "\n"
    517517             "All rights reserved.\n"
    518              "\n");   
     518             "\n");
    519519}
    520520
     
    530530    int  iCmd      = 1;
    531531    int  iCmdArg;
    532    
     532
    533533    /* global options */
    534534    for (int i = 1; i < argc || argc <= iCmd; i++)
     
    545545            return 0;
    546546        }
    547        
     547
    548548        if (   !strcmp(argv[i], "-v")
    549549            || !strcmp(argv[i], "-version")
     
    569569        }
    570570    }
    571    
     571
    572572    iCmdArg = iCmd + 1;
    573    
     573
    574574    if (fShowLogo)
    575575        showLogo();
     
    582582    vdInterfaceErrorCallbacks.pfnError     = handleVDError;
    583583    vdInterfaceErrorCallbacks.pfnMessage   = handleVDMessage;
    584    
     584
    585585    rc = VDInterfaceAdd(&vdInterfaceError, "VBoxManage_IError", VDINTERFACETYPE_ERROR,
    586586                        &vdInterfaceErrorCallbacks, NULL, &pVDIfs);
    587    
     587
    588588    rc = VDInit();
    589589    if (RT_FAILURE(rc))
    590590        return errorSyntax("Initalizing backends failed! rc=%Rrc\n");
    591    
     591
    592592    /*
    593593     * All registered command handlers
     
    614614            handlerArg.argc = argc - iCmdArg;
    615615            handlerArg.argv = &argv[iCmdArg];
    616            
     616
    617617            rc = s_commandHandlers[commandIndex].handler(&handlerArg);
    618618            break;
     
    620620    }
    621621    if (!s_commandHandlers[commandIndex].command)
    622         return errorSyntax("Invalid command '%s'", argv[iCmd]);       
     622        return errorSyntax("Invalid command '%s'", argv[iCmd]);
    623623
    624624    rc = VDShutdown();
    625625    if (RT_FAILURE(rc))
    626626        return errorSyntax("Unloading backends failed! rc=%Rrc\n", rc);
    627    
     627
    628628    return rc;
    629629}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette