VirtualBox

Changeset 70225 in vbox


Ignore:
Timestamp:
Dec 19, 2017 6:22:08 PM (7 years ago)
Author:
vboxsync
Message:

VDVfs.cpp: Snapshot chain support.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Storage/VDVfs.cpp

    r69977 r70225  
    593593    if (pElement->cArgs < 1)
    594594        return VERR_VFS_CHAIN_AT_LEAST_ONE_ARG;
    595     if (pElement->cArgs > 2)
    596         return VERR_VFS_CHAIN_AT_MOST_TWO_ARGS;
    597595
    598596    /*
     
    603601    if (pElement->cArgs > 1)
    604602    {
    605         const char *psz = pElement->paArgs[1].psz;
     603        pElement->paArgs[pElement->cArgs - 1].uProvider = true; /* indicates flags  */
     604        const char *psz = pElement->paArgs[pElement->cArgs - 1].psz;
    606605        if (*psz)
    607606        {
     
    617616                fFlags |= VD_OPEN_FLAGS_NORMAL;
    618617            }
     618            else if (strlen(psz) <= 4)
     619            {
     620                *poffError = pElement->paArgs[pElement->cArgs - 1].offSpec;
     621                return RTErrInfoSet(pErrInfo, VERR_VFS_CHAIN_INVALID_ARGUMENT, "Expected 'ro' or 'rw' as argument");
     622            }
    619623            else
    620             {
    621                 *poffError = pElement->paArgs[0].offSpec;
    622                 return RTErrInfoSet(pErrInfo, VERR_VFS_CHAIN_INVALID_ARGUMENT, "Expected 'ro' or 'rw' as argument");
    623             }
     624                pElement->paArgs[pElement->cArgs - 1].uProvider = false; /* indicates no flags  */
    624625        }
    625626    }
    626627
    627628    pElement->uProvider = fFlags;
     629    if (   pElement->cArgs > 2
     630        || (pElement->cArgs == 2 && !pElement->paArgs[pElement->cArgs - 1].uProvider))
     631           pElement->uProvider |= RT_BIT_64(63);
    628632    return VINF_SUCCESS;
    629633}
     
    650654        if (RT_SUCCESS(rc))
    651655        {
    652             rc = VDOpen(pDisk, pszFormat, pElement->paArgs[0].psz, (uint32_t)pElement->uProvider, NULL);
     656            if (!(pElement->uProvider & RT_BIT_64(63)))
     657                rc = VDOpen(pDisk, pszFormat, pElement->paArgs[0].psz, (uint32_t)pElement->uProvider, NULL);
     658            else
     659            {
     660                uint32_t cChain = pElement->cArgs;
     661                if (pElement->cArgs == 2 && pElement->paArgs[pElement->cArgs - 1].uProvider != 0)
     662                    cChain--;
     663                uint32_t const  fFinal    = (uint32_t)pElement->uProvider;
     664                uint32_t const  fReadOnly = (fFinal & ~(VD_OPEN_FLAGS_READONLY | VD_OPEN_FLAGS_NORMAL)) | VD_OPEN_FLAGS_READONLY;
     665                uint32_t        iChain;
     666                for (iChain = 0; iChain < cChain && RT_SUCCESS(rc); iChain++)
     667                    rc = VDOpen(pDisk, pszFormat, pElement->paArgs[iChain].psz, iChain + 1 >= cChain ? fFinal : fReadOnly, NULL);
     668            }
    653669            if (RT_SUCCESS(rc))
    654670            {
     
    694710    /* pszName = */             "vd",
    695711    /* ListEntry = */           { NULL, NULL },
    696     /* pszHelp = */             "Opens a container image using the VD API.\n",
     712    /* pszHelp = */             "Opens a container image using the VD API.\n"
     713                                "To open a snapshot chain, start with the root image and end with the more recent diff image.\n"
     714                                "The final argument can be a flag 'ro' or 'r' for read-only, 'rw' for read-write.",
    697715    /* pfnValidate = */         vdVfsChain_Validate,
    698716    /* pfnInstantiate = */      vdVfsChain_Instantiate,
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