VirtualBox

Changeset 7576 in vbox


Ignore:
Timestamp:
Mar 26, 2008 1:25:36 PM (17 years ago)
Author:
vboxsync
Message:

File open cache (important for windows raw partition access), quoting of comment strings and small cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Storage/VmdkHDDCore.cpp

    r7157 r7576  
    3636*   Constants And Macros, Structures and Typedefs                              *
    3737*******************************************************************************/
     38
     39/** Maximum encoded string size (including NUL) we allow for VMDK images.
     40 * Deliberately not set high to avoid running out of descriptor space. */
     41#define VMDK_ENCRYPTED_COMMENT_MAX 1024
    3842
    3943/** VMDK descriptor DDB entry for PCHS cylinders. */
     
    231235
    232236/**
     237 * Extents files entry. Used for opening a particular file only once.
     238 */
     239typedef struct VMDKFILE
     240{
     241    /** Pointer to filename. Local copy. */
     242    const char *pszFilename;
     243    /** File open flags for consistency checking. */
     244    unsigned    fOpen;
     245    /** File handle. */
     246    RTFILE      File;
     247    /** Reference counter. */
     248    unsigned    uReferences;
     249    /** Flag whether the file should be deleted on last close. */
     250    bool        fDelete;
     251    /** Pointer to next file descriptor. Singly linked list is fast enough. */
     252    struct VMDKFILE *pNext;
     253} VMDKFILE, *PVMDKFILE;
     254
     255/**
    233256 * Grain table cache size. Allocated per image.
    234257 */
     
    312335    /** Number of image extents. */
    313336    unsigned        cExtents;
     337    /** Pointer to the files list, for opening a file referenced multiple
     338     * times only once (happens mainly with raw partition access). */
     339    PVMDKFILE       pFiles;
    314340
    315341    /** Base image name. */
     
    359385*******************************************************************************/
    360386
    361 static int vmdkReadGrainDirectory(PVMDKEXTENT pExtent);
    362387static void vmdkFreeGrainDirectory(PVMDKEXTENT pExtent);
    363388
    364 static int vmdkPreprocessDescriptor(PVMDKIMAGE pImage, char *pDescData, size_t cbDescData, PVMDKDESCRIPTOR pDescriptor);
    365 static int vmdkReadMetaSparseExtent(PVMDKEXTENT pExtent);
    366 static int vmdkWriteMetaSparseExtent(PVMDKEXTENT pExtent);
    367 #ifdef VBOX_WITH_VMDK_ESX
    368 static int vmdkReadMetaESXSparseExtent(PVMDKEXTENT pExtent);
    369 #endif /* VBOX_WITH_VMDK_ESX */
    370 static void vmdkFreeExtentData(PVMDKEXTENT pExtent, bool fDelete);
     389static void vmdkFreeExtentData(PVMDKIMAGE pImage, PVMDKEXTENT pExtent,
     390                               bool fDelete);
    371391
    372392static int vmdkCreateExtents(PVMDKIMAGE pImage, unsigned cExtents);
     
    392412
    393413/**
     414 * Internal: open a file (using a file descriptor cache to ensure each file
     415 * is only opened once - anything else can cause locking problems).
     416 */
     417static int vmdkFileOpen(PVMDKIMAGE pImage, PRTFILE pFile,
     418                        const char *pszFilename, unsigned fOpen)
     419{
     420    int rc = VINF_SUCCESS;
     421    PVMDKFILE pVmdkFile;
     422
     423    for (pVmdkFile = pImage->pFiles;
     424         pVmdkFile != NULL;
     425         pVmdkFile = pVmdkFile->pNext)
     426    {
     427        if (!strcmp(pszFilename, pVmdkFile->pszFilename))
     428        {
     429            Assert(fOpen == pVmdkFile->fOpen);
     430            pVmdkFile->uReferences++;
     431            *pFile = pVmdkFile->File;
     432            return rc;
     433        }
     434    }
     435
     436    /* If we get here, there's no matching entry in the cache. */
     437    pVmdkFile = (PVMDKFILE)RTMemAllocZ(sizeof(VMDKFILE));
     438    if (!VALID_PTR(pVmdkFile))
     439    {
     440        *pFile = NIL_RTFILE;
     441        return VERR_NO_MEMORY;
     442    }
     443
     444    pVmdkFile->pszFilename = RTStrDup(pszFilename);
     445    if (!VALID_PTR(pVmdkFile->pszFilename))
     446    {
     447        RTMemFree(pVmdkFile);
     448        *pFile = NIL_RTFILE;
     449        return VERR_NO_MEMORY;
     450    }
     451    pVmdkFile->fOpen = fOpen;
     452    rc = RTFileOpen(&pVmdkFile->File, pszFilename, fOpen);
     453    if (VBOX_SUCCESS(rc))
     454    {
     455        pVmdkFile->uReferences = 1;
     456        pVmdkFile->pNext = pImage->pFiles;
     457        pImage->pFiles = pVmdkFile;
     458        *pFile = pVmdkFile->File;
     459    }
     460    else
     461    {
     462        RTMemFree(pVmdkFile);
     463        *pFile = NIL_RTFILE;
     464    }
     465
     466    return rc;
     467}
     468
     469/**
     470 * Internal: close a file, updating the file descriptor cache.
     471 */
     472static int vmdkFileClose(PVMDKIMAGE pImage, PRTFILE pFile, bool fDelete)
     473{
     474    int rc = VINF_SUCCESS;
     475    RTFILE File;
     476    PVMDKFILE pVmdkFile, pPrev;
     477
     478    Assert(VALID_PTR(pFile) && *pFile != NIL_RTFILE);
     479    File = *pFile;
     480
     481    pPrev = NULL;
     482    for (pVmdkFile = pImage->pFiles;
     483         pVmdkFile != NULL;
     484         pVmdkFile = pVmdkFile->pNext)
     485    {
     486        if (File == pVmdkFile->File)
     487        {
     488            pVmdkFile->fDelete |= fDelete;
     489            Assert(pVmdkFile->uReferences);
     490            pVmdkFile->uReferences--;
     491            if (pVmdkFile->uReferences == 0)
     492            {
     493                /* Unchain the element from the list. */
     494                if (pPrev == NULL)
     495                    pImage->pFiles = pVmdkFile->pNext;
     496                else
     497                    pPrev->pNext = pVmdkFile->pNext;
     498                rc = RTFileClose(File);
     499                *pFile = NIL_RTFILE;
     500                if (VBOX_SUCCESS(rc) && pVmdkFile->fDelete)
     501                    rc = RTFileDelete(pVmdkFile->pszFilename);
     502                RTStrFree((char *)(void *)pVmdkFile->pszFilename);
     503                RTMemFree(pVmdkFile);
     504            }
     505            return rc;
     506        }
     507        pPrev = pVmdkFile;
     508    }
     509
     510    AssertMsgFailed(("trying to close unknown file %#p", File));
     511    return VERR_INVALID_PARAMETER;
     512}
     513
     514/**
     515 * Internal: check if all files are closed, prevent leaking resources.
     516 */
     517static int vmdkFileCheckAllClose(PVMDKIMAGE pImage)
     518{
     519    int rc = VINF_SUCCESS, rc2;
     520    PVMDKFILE pVmdkFile;
     521
     522    Assert(pImage->pFiles == NULL);
     523    for (pVmdkFile = pImage->pFiles;
     524         pVmdkFile != NULL;
     525         pVmdkFile = pVmdkFile->pNext)
     526    {
     527        LogRel(("VMDK: leaking reference to file \"%s\"\n",
     528                pVmdkFile->pszFilename));
     529        pImage->pFiles = pVmdkFile->pNext;
     530        rc2 = RTFileClose(pVmdkFile->File);
     531        if (VBOX_SUCCESS(rc) && pVmdkFile->fDelete)
     532            rc2 = RTFileDelete(pVmdkFile->pszFilename);
     533        RTStrFree((char *)(void *)pVmdkFile->pszFilename);
     534        RTMemFree(pVmdkFile);
     535        if (VBOX_SUCCESS(rc))
     536            rc = rc2;
     537    }
     538    return rc;
     539}
     540
     541/**
    394542 * Internal: truncate a string (at a UTF8 code point boundary) and encode the
    395543 * critical non-ASCII characters.
     
    397545static char *vmdkEncodeString(const char *psz)
    398546{
    399     /** @todo implement me. */
    400     return RTStrDup(psz);
     547    char szEnc[VMDK_ENCRYPTED_COMMENT_MAX + 3];
     548    char *pszDst = szEnc;
     549
     550    Assert(VALID_PTR(psz));
     551
     552    for (; *psz; psz = RTStrNextCp(psz))
     553    {
     554        char *pszDstPrev = pszDst;
     555        RTUNICP Cp = RTStrGetCp(psz);
     556        if (Cp == '\\')
     557        {
     558            pszDst = RTStrPutCp(pszDst, Cp);
     559            pszDst = RTStrPutCp(pszDst, Cp);
     560        }
     561        else if (Cp == '\n')
     562        {
     563            pszDst = RTStrPutCp(pszDst, '\\');
     564            pszDst = RTStrPutCp(pszDst, 'n');
     565        }
     566        else if (Cp == '\r')
     567        {
     568            pszDst = RTStrPutCp(pszDst, '\\');
     569            pszDst = RTStrPutCp(pszDst, 'r');
     570        }
     571        else
     572            pszDst = RTStrPutCp(pszDst, Cp);
     573        if (pszDst - szEnc >= VMDK_ENCRYPTED_COMMENT_MAX - 1)
     574        {
     575            pszDst = pszDstPrev;
     576            break;
     577        }
     578    }
     579    *pszDst = '\0';
     580    return RTStrDup(szEnc);
    401581}
    402582
     
    406586static int vmdkDecodeString(const char *pszEncoded, char *psz, size_t cb)
    407587{
    408     /** @todo implement me. */
     588    int rc = VINF_SUCCESS;
     589    char szBuf[4];
     590
    409591    if (!cb)
    410         return VINF_SUCCESS;
    411     strncpy(psz, pszEncoded, cb);
    412     psz[cb - 1] = '\0';
    413     return VINF_SUCCESS;
     592        return VERR_BUFFER_OVERFLOW;
     593
     594    Assert(VALID_PTR(psz));
     595
     596    for (; *pszEncoded; pszEncoded = RTStrNextCp(pszEncoded))
     597    {
     598        char *pszDst = szBuf;
     599        RTUNICP Cp = RTStrGetCp(pszEncoded);
     600        if (Cp == '\\')
     601        {
     602            pszEncoded = RTStrNextCp(pszEncoded);
     603            RTUNICP CpQ = RTStrGetCp(pszEncoded);
     604            if (CpQ == 'n')
     605                RTStrPutCp(pszDst, '\n');
     606            else if (CpQ == 'r')
     607                RTStrPutCp(pszDst, '\r');
     608            else if (CpQ == '\0')
     609            {
     610                rc = VERR_VDI_INVALID_HEADER;
     611                break;
     612            }
     613            else
     614                RTStrPutCp(pszDst, CpQ);
     615        }
     616        else
     617            pszDst = RTStrPutCp(pszDst, Cp);
     618
     619        /* Need to leave space for terminating NUL. */
     620        if ((size_t)(pszDst - szBuf) + 1 >= cb)
     621        {
     622            rc = VERR_BUFFER_OVERFLOW;
     623            break;
     624        }
     625        memcpy(psz, szBuf, pszDst - szBuf);
     626        psz += pszDst - szBuf;
     627    }
     628    *psz = '\0';
     629    return rc;
    414630}
    415631
     
    16541870 * Internal: read metadata belonging to a sparse extent.
    16551871 */
    1656 static int vmdkReadMetaSparseExtent(PVMDKEXTENT pExtent)
     1872static int vmdkReadMetaSparseExtent(PVMDKIMAGE pImage, PVMDKEXTENT pExtent)
    16571873{
    16581874    SparseExtentHeader Header;
     
    17431959out:
    17441960    if (VBOX_FAILURE(rc))
    1745         vmdkFreeExtentData(pExtent, false);
     1961        vmdkFreeExtentData(pImage, pExtent, false);
    17461962
    17471963    return rc;
     
    18512067out:
    18522068    if (VBOX_FAILURE(rc))
    1853         vmdkFreeExtentData(pExtent, false);
     2069        vmdkFreeExtentData(pImage, pExtent, false);
    18542070
    18552071    return rc;
     
    18612077 * deleting the referenced files.
    18622078 */
    1863 static void vmdkFreeExtentData(PVMDKEXTENT pExtent, bool fDelete)
     2079static void vmdkFreeExtentData(PVMDKIMAGE pImage, PVMDKEXTENT pExtent,
     2080                               bool fDelete)
    18642081{
    18652082    vmdkFreeGrainDirectory(pExtent);
     
    18712088    if (pExtent->File != NIL_RTFILE)
    18722089    {
    1873         RTFileClose(pExtent->File);
    1874         pExtent->File = NIL_RTFILE;
    1875         if (    fDelete
    1876             &&  strcmp(pExtent->pszFullname, pExtent->pszBasename) != 0
    1877             && pExtent->pszFullname)
    1878             RTFileDelete(pExtent->pszFullname);
     2090        vmdkFileClose(pImage, &pExtent->File,
     2091                         fDelete
     2092                      && pExtent->pszFullname
     2093                      && strcmp(pExtent->pszFullname, pExtent->pszBasename));
    18792094    }
    18802095    if (pExtent->pszBasename)
     
    19652180    pImage->uOpenFlags = uOpenFlags;
    19662181
    1967     /** @todo check whether the same file is used somewhere else. don't open any file twice, leads to locking problems and can cause trouble with file caching. */
    1968 
    19692182    /*
    19702183     * Open the image.
    19712184     */
    1972     rc = RTFileOpen(&File, pImage->pszFilename,
    1973                     uOpenFlags & VD_OPEN_FLAGS_READONLY
    1974                      ? RTFILE_O_READ      | RTFILE_O_OPEN | RTFILE_O_DENY_NONE
    1975                      : RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
     2185    rc = vmdkFileOpen(pImage, &File, pImage->pszFilename,
     2186                      uOpenFlags & VD_OPEN_FLAGS_READONLY
     2187                       ? RTFILE_O_READ      | RTFILE_O_OPEN | RTFILE_O_DENY_NONE
     2188                       : RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
    19762189    if (VBOX_FAILURE(rc))
    19772190    {
     
    20022215        pExtent->File = File;
    20032216        pImage->File = NIL_RTFILE;
    2004         rc = vmdkReadMetaSparseExtent(pExtent);
     2217        rc = vmdkReadMetaSparseExtent(pImage, pExtent);
    20052218        if (VBOX_FAILURE(rc))
    20062219            goto out;
     
    21182331            {
    21192332                case VMDKETYPE_HOSTED_SPARSE:
    2120                     rc = RTFileOpen(&pExtent->File, pExtent->pszFullname,
    2121                                     uOpenFlags & VD_OPEN_FLAGS_READONLY
    2122                                       ? RTFILE_O_READ      | RTFILE_O_OPEN | RTFILE_O_DENY_NONE
    2123                                       : RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
     2333                    rc = vmdkFileOpen(pImage, &pExtent->File, pExtent->pszFullname,
     2334                                      uOpenFlags & VD_OPEN_FLAGS_READONLY
     2335                                        ? RTFILE_O_READ      | RTFILE_O_OPEN | RTFILE_O_DENY_NONE
     2336                                        : RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
    21242337                    if (VBOX_FAILURE(rc))
    21252338                    {
     
    21292342                        goto out;
    21302343                    }
    2131                     rc = vmdkReadMetaSparseExtent(pExtent);
     2344                    rc = vmdkReadMetaSparseExtent(pImage, pExtent);
    21322345                    if (VBOX_FAILURE(rc))
    21332346                        goto out;
     
    21412354                    break;
    21422355                case VMDKETYPE_FLAT:
    2143                     rc = RTFileOpen(&pExtent->File, pExtent->pszFullname,
    2144                                     uOpenFlags & VD_OPEN_FLAGS_READONLY
    2145                                       ? RTFILE_O_READ      | RTFILE_O_OPEN | RTFILE_O_DENY_NONE
    2146                                       : RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
     2356                    rc = vmdkFileOpen(pImage, &pExtent->File, pExtent->pszFullname,
     2357                                      uOpenFlags & VD_OPEN_FLAGS_READONLY
     2358                                        ? RTFILE_O_READ      | RTFILE_O_OPEN | RTFILE_O_DENY_NONE
     2359                                        : RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
    21472360                    if (VBOX_FAILURE(rc))
    21482361                    {
     
    22422455            return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not create new extent list in '%s'"), pImage->pszFilename);
    22432456        pExtent = &pImage->pExtents[0];
    2244         /* Create raw disk descriptor file. */
    2245         rc = RTFileOpen(&pImage->File, pImage->pszFilename,
    2246                         RTFILE_O_READWRITE | RTFILE_O_CREATE | RTFILE_O_DENY_WRITE | RTFILE_O_NOT_CONTENT_INDEXED);
     2457        /* Create raw disk descriptor file. */
     2458        rc = vmdkFileOpen(pImage, &pImage->File, pImage->pszFilename,
     2459                          RTFILE_O_READWRITE | RTFILE_O_CREATE | RTFILE_O_DENY_WRITE | RTFILE_O_NOT_CONTENT_INDEXED);
    22472460        if (VBOX_FAILURE(rc))
    22482461            return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not create new file '%s'"), pImage->pszFilename);
     
    22662479
    22672480        /* Open flat image, the raw disk. */
    2268         rc = RTFileOpen(&pExtent->File, pExtent->pszFullname,
    2269                         RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
     2481        rc = vmdkFileOpen(pImage, &pExtent->File, pExtent->pszFullname,
     2482                          RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
    22702483        if (VBOX_FAILURE(rc))
    22712484            return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not open raw disk file '%s'"), pExtent->pszFullname);
     
    23152528
    23162529        /* Create raw partition descriptor file. */
    2317         rc = RTFileOpen(&pImage->File, pImage->pszFilename,
    2318                         RTFILE_O_READWRITE | RTFILE_O_CREATE | RTFILE_O_DENY_WRITE | RTFILE_O_NOT_CONTENT_INDEXED);
     2530        rc = vmdkFileOpen(pImage, &pImage->File, pImage->pszFilename,
     2531                          RTFILE_O_READWRITE | RTFILE_O_CREATE | RTFILE_O_DENY_WRITE | RTFILE_O_NOT_CONTENT_INDEXED);
    23192532        if (VBOX_FAILURE(rc))
    23202533            return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not create new file '%s'"), pImage->pszFilename);
     
    23862599
    23872600                /* Create partition table flat image. */
    2388                 rc = RTFileOpen(&pExtent->File, pExtent->pszFullname,
    2389                                 RTFILE_O_READWRITE | RTFILE_O_CREATE | RTFILE_O_DENY_WRITE | RTFILE_O_NOT_CONTENT_INDEXED);
     2601                rc = vmdkFileOpen(pImage, &pExtent->File, pExtent->pszFullname,
     2602                                  RTFILE_O_READWRITE | RTFILE_O_CREATE | RTFILE_O_DENY_WRITE | RTFILE_O_NOT_CONTENT_INDEXED);
    23902603                if (VBOX_FAILURE(rc))
    23912604                    return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not create new partition data file '%s'"), pExtent->pszFullname);
     
    24332646
    24342647                    /* Open flat image, the raw partition. */
    2435                     rc = RTFileOpen(&pExtent->File, pExtent->pszFullname,
    2436                                     RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
     2648                    rc = vmdkFileOpen(pImage, &pExtent->File, pExtent->pszFullname,
     2649                                      RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
    24372650                    if (VBOX_FAILURE(rc))
    24382651                        return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not open raw partition file '%s'"), pExtent->pszFullname);
     
    25052718    if (cExtents != 1 || enmType == VD_IMAGE_TYPE_FIXED)
    25062719    {
    2507         rc = RTFileOpen(&pImage->File, pImage->pszFilename,
    2508                         RTFILE_O_READWRITE | RTFILE_O_CREATE | RTFILE_O_DENY_WRITE | RTFILE_O_NOT_CONTENT_INDEXED);
     2720        rc = vmdkFileOpen(pImage, &pImage->File, pImage->pszFilename,
     2721                          RTFILE_O_READWRITE | RTFILE_O_CREATE | RTFILE_O_DENY_WRITE | RTFILE_O_NOT_CONTENT_INDEXED);
    25092722        if (VBOX_FAILURE(rc))
    25102723            return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not create new sparse descriptor file '%s'"), pImage->pszFilename);
     
    25742787
    25752788        /* Create file for extent. */
    2576         rc = RTFileOpen(&pExtent->File, pExtent->pszFullname,
    2577                         RTFILE_O_READWRITE | RTFILE_O_CREATE | RTFILE_O_DENY_WRITE | RTFILE_O_NOT_CONTENT_INDEXED);
     2789        rc = vmdkFileOpen(pImage, &pExtent->File, pExtent->pszFullname,
     2790                          RTFILE_O_READWRITE | RTFILE_O_CREATE | RTFILE_O_DENY_WRITE | RTFILE_O_NOT_CONTENT_INDEXED);
    25782791        if (VBOX_FAILURE(rc))
    25792792            return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: could not create new file '%s'"), pExtent->pszFullname);
     
    28663079    {
    28673080        for (unsigned i = 0 ; i < pImage->cExtents; i++)
    2868             vmdkFreeExtentData(&pImage->pExtents[i], fDelete);
     3081            vmdkFreeExtentData(pImage, &pImage->pExtents[i], fDelete);
    28693082        RTMemFree(pImage->pExtents);
    28703083        pImage->pExtents = NULL;
    28713084    }
    28723085    if (pImage->File != NIL_RTFILE)
    2873     {
    2874         RTFileClose(pImage->File);
    2875         pImage->File = NIL_RTFILE;
    2876     }
    2877     if (fDelete && pImage->pszFilename)
    2878         RTFileDelete(pImage->pszFilename);
     3086        vmdkFileClose(pImage, &pImage->File, fDelete);
     3087    vmdkFileCheckAllClose(pImage);
    28793088}
    28803089
     
    32273436    pImage->File = NIL_RTFILE;
    32283437    pImage->pExtents = NULL;
     3438    pImage->pFiles = NULL;
    32293439    pImage->pGTCache = NULL;
    32303440    pImage->pDescData = NULL;
     
    32763486    pImage->File = NIL_RTFILE;
    32773487    pImage->pExtents = NULL;
     3488    pImage->pFiles = NULL;
    32783489    pImage->pGTCache = NULL;
    32793490    pImage->pDescData = NULL;
     
    33333544    pImage->File = NIL_RTFILE;
    33343545    pImage->pExtents = NULL;
     3546    pImage->pFiles = NULL;
    33353547    pImage->pGTCache = NULL;
    33363548    pImage->pDescData = NULL;
     
    39444156    {
    39454157        if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY))
    3946         {
     4158        {
    39474159            pImage->ImageUuid = *pUuid;
    39484160            rc = vmdkDescDDBSetUuid(pImage, &pImage->Descriptor,
     
    39514163                return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error storing image UUID in descriptor in '%s'"), pImage->pszFilename);
    39524164            rc = VINF_SUCCESS;
    3953         }
    3954         else
    3955             rc = VERR_VDI_IMAGE_READ_ONLY;
     4165        }
     4166        else
     4167            rc = VERR_VDI_IMAGE_READ_ONLY;
    39564168    }
    39574169    else
     
    39954207    {
    39964208        if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY))
    3997         {
     4209        {
    39984210            pImage->ModificationUuid = *pUuid;
    39994211            rc = vmdkDescDDBSetUuid(pImage, &pImage->Descriptor,
     
    40024214                return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error storing modification UUID in descriptor in '%s'"), pImage->pszFilename);
    40034215            rc = VINF_SUCCESS;
    4004         }
    4005         else
    4006             rc = VERR_VDI_IMAGE_READ_ONLY;
     4216        }
     4217        else
     4218            rc = VERR_VDI_IMAGE_READ_ONLY;
    40074219    }
    40084220    else
     
    40464258    {
    40474259        if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY))
    4048         {
     4260        {
    40494261            pImage->ParentUuid = *pUuid;
    40504262            rc = vmdkDescDDBSetUuid(pImage, &pImage->Descriptor,
     
    40534265                return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error storing parent image UUID in descriptor in '%s'"), pImage->pszFilename);
    40544266            rc = VINF_SUCCESS;
    4055         }
    4056         else
    4057             rc = VERR_VDI_IMAGE_READ_ONLY;
     4267        }
     4268        else
     4269            rc = VERR_VDI_IMAGE_READ_ONLY;
    40584270    }
    40594271    else
     
    40974309    {
    40984310        if (!(pImage->uOpenFlags & VD_OPEN_FLAGS_READONLY))
    4099         {
     4311        {
    41004312            pImage->ParentModificationUuid = *pUuid;
    41014313            rc = vmdkDescDDBSetUuid(pImage, &pImage->Descriptor,
     
    41044316                return vmdkError(pImage, rc, RT_SRC_POS, N_("VMDK: error storing parent image UUID in descriptor in '%s'"), pImage->pszFilename);
    41054317            rc = VINF_SUCCESS;
    4106         }
    4107         else
    4108             rc = VERR_VDI_IMAGE_READ_ONLY;
     4318        }
     4319        else
     4320            rc = VERR_VDI_IMAGE_READ_ONLY;
    41094321    }
    41104322    else
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