VirtualBox

Ignore:
Timestamp:
Jun 27, 2008 4:03:47 PM (16 years ago)
Author:
vboxsync
Message:

Make dynamic image default for VBoxManage convertdd, and just optionally create a static image.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp

    r10000 r10002  
    528528    if (u64Cmd & USAGE_CONVERTDD)
    529529    {
    530         RTPrintf("VBoxManage convertdd        <filename> <outputfile>\n"
    531                  "VBoxManage convertdd        stdin <outputfile> <bytes>\n"
     530        RTPrintf("VBoxManage convertdd        [-static] <filename> <outputfile>\n"
     531                 "VBoxManage convertdd        [-static] stdin <outputfile> <bytes>\n"
    532532                 "\n");
    533533    }
     
    33493349static int handleConvertDDImage(int argc, char *argv[])
    33503350{
    3351 #ifdef RT_OS_LINUX
    3352     const bool fReadFromStdIn = (argc >= 1) && !strcmp(argv[0], "stdin");
     3351    int arg = 0;
     3352    VDIIMAGETYPE enmImgType = VDI_IMAGE_TYPE_NORMAL;
     3353    if (argc >= 1 && !strcmp(argv[arg], "-static"))
     3354    {
     3355        arg++;
     3356        enmImgType = VDI_IMAGE_TYPE_FIXED;
     3357    }
     3358
     3359#if defined(RT_OS_LINUX) || defined(RT_OS_DARWIN) || defined(RT_OS_SOLARIS)
     3360    const bool fReadFromStdIn = (argc >= arg + 1) && !strcmp(argv[arg], "stdin");
    33533361#else
    33543362    const bool fReadFromStdIn = false;
    33553363#endif
    33563364
    3357     if ((!fReadFromStdIn && argc != 2) || (fReadFromStdIn && argc != 3))
     3365    if ((!fReadFromStdIn && argc != arg + 2) || (fReadFromStdIn && argc != arg + 3))
    33583366        return errorSyntax(USAGE_CONVERTDD, "Incorrect number of parameters");
    33593367
    33603368    RTPrintf("Converting VDI: from DD image file=\"%s\" to file=\"%s\"...\n",
    3361              argv[0], argv[1]);
     3369             argv[arg], argv[arg + 1]);
    33623370
    33633371    /* open raw image file. */
     
    33673375        File = 0;
    33683376    else
    3369         rc = RTFileOpen(&File, argv[0], RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);
     3377        rc = RTFileOpen(&File, argv[arg], RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);
    33703378    if (VBOX_FAILURE(rc))
    33713379    {
    3372         RTPrintf("File=\"%s\" open error: %Rrf\n", argv[0], rc);
     3380        RTPrintf("File=\"%s\" open error: %Rrf\n", argv[arg], rc);
    33733381        return rc;
    33743382    }
     
    33773385    /* get image size. */
    33783386    if (fReadFromStdIn)
    3379         cbFile = RTStrToUInt64(argv[2]);
     3387        cbFile = RTStrToUInt64(argv[arg + 2]);
    33803388    else
    33813389        rc = RTFileGetSize(File, &cbFile);
    33823390    if (VBOX_SUCCESS(rc))
    33833391    {
    3384         RTPrintf("Creating fixed image with size %RU64 bytes (%RU64MB)...\n", cbFile, (cbFile + _1M - 1) / _1M);
     3392        RTPrintf("Creating %s image with size %RU64 bytes (%RU64MB)...\n", (enmImgType == VDI_IMAGE_TYPE_FIXED) ? "fixed" : "dynamic", cbFile, (cbFile + _1M - 1) / _1M);
    33853393        char pszComment[256];
    3386         RTStrPrintf(pszComment, sizeof(pszComment), "Converted image from %s", argv[0]);
    3387         rc = VDICreateBaseImage(argv[1],
    3388                                 VDI_IMAGE_TYPE_FIXED,
     3394        RTStrPrintf(pszComment, sizeof(pszComment), "Converted image from %s", argv[arg]);
     3395        rc = VDICreateBaseImage(argv[arg + 1],
     3396                                enmImgType,
    33893397                                cbFile,
    33903398                                pszComment, NULL, NULL);
     
    33923400        {
    33933401            PVDIDISK pVdi = VDIDiskCreate();
    3394             rc = VDIDiskOpenImage(pVdi, argv[1], VDI_OPEN_FLAGS_NORMAL);
     3402            rc = VDIDiskOpenImage(pVdi, argv[arg + 1], VDI_OPEN_FLAGS_NORMAL);
    33953403            if (VBOX_SUCCESS(rc))
    33963404            {
     
    34273435                /* delete image on error */
    34283436                RTPrintf("Failed (%Vrc)!\n", rc);
    3429                 VDIDeleteImage(argv[1]);
     3437                VDIDeleteImage(argv[arg + 1]);
    34303438            }
    34313439        }
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