VirtualBox

Changeset 8512 in vbox for trunk/src/VBox/Devices


Ignore:
Timestamp:
Apr 30, 2008 3:13:02 PM (17 years ago)
Author:
vboxsync
Message:

Disabled file locking for windows hosts. Open read/write file in DENY_WRITE mode too.

File:
1 edited

Legend:

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

    r8155 r8512  
    441441            }
    442442        }
    443 
     443#ifndef RT_OS_WINDOWS
    444444        rc = RTFileLock(pImage->File,
    445445                        RTFILE_LOCK_WRITE | RTFILE_LOCK_IMMEDIATELY, 0, cbLock);
     
    449449            goto l_create_failed;
    450450        }
    451 
     451#endif
    452452        if (enmType == VDI_IMAGE_TYPE_FIXED)
    453453        {
     
    542542    l_create_failed:
    543543
     544#ifndef RT_OS_WINDOWS
    544545        if (cbLock)
    545546            RTFileUnlock(pImage->File, 0, cbLock);
    546 
     547#endif
    547548        RTFileClose(pImage->File);
    548549
     
    601602                        fOpen & VDI_OPEN_FLAGS_READONLY
    602603                        ? RTFILE_O_READ      | RTFILE_O_OPEN | RTFILE_O_DENY_NONE
    603                         : RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
     604                        : RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);
    604605    if (VBOX_FAILURE(rc))
    605606    {
     
    622623    pImage->fReadOnly = !!(pImage->fOpen & VDI_OPEN_FLAGS_READONLY);
    623624
     625#ifndef RT_OS_WINDOWS
    624626    /*
    625627     * Set initial file lock for reading header only.
     
    633635        goto l_open_failed;
    634636    }
     637#endif
    635638
    636639    /* Read pre-header. */
     
    734737    pImage->fModified = VDI_IMAGE_MODIFIED_FIRST;
    735738
     739#ifndef RT_OS_WINDOWS
    736740    /* Image is validated, set working file lock on it. */
    737741    rc = RTFileUnlock(pImage->File, 0, cbLock);
     
    759763        goto l_open_failed;
    760764    }
     765#endif
    761766
    762767    /* Allocate memory for blocks array. */
     
    785790    if (pImage->paBlocks)
    786791        RTMemFree(pImage->paBlocks);
     792#ifndef RT_OS_WINDOWS
    787793    if (cbLock)
    788794        RTFileUnlock(pImage->File, 0, cbLock);
     795#endif
    789796    RTFileClose(pImage->File);
    790797    RTMemFree(pImage);
     
    964971
    965972    VDIFlushImage(pImage);
     973#ifndef RT_OS_WINDOWS
    966974    RTFileUnlock(pImage->File,
    967975                 0,
    968976                 pImage->offStartData
    969977               + ((uint64_t)getImageBlocks(&pImage->Header) << pImage->uShiftIndex2Offset));
     978#endif
    970979    RTFileClose(pImage->File);
    971980
     
    19461955    if (VBOX_SUCCESS(rc))
    19471956    {
     1957#ifndef RT_OS_WINDOWS
    19481958        /* lock new image exclusively to close any wrong access by VDI API calls. */
    19491959        rc = RTFileLock(File, RTFILE_LOCK_WRITE | RTFILE_LOCK_IMMEDIATELY, 0, cbFile);
    19501960        if (VBOX_SUCCESS(rc))
     1961#endif
    19511962        {
    19521963            /* Set the size of a new file. */
     
    20382049            }
    20392050
     2051#ifndef RT_OS_WINDOWS
    20402052            RTFileUnlock(File, 0, cbFile);
     2053#endif
    20412054        }
    20422055
     
    33193332    VDIFlushImage(pImage);
    33203333
     3334#ifdef RT_OS_WINDOWS
     3335    int rc = VINF_SUCCESS;
     3336#else
    33213337    /* Change image locking. */
    33223338    uint64_t cbLock = pImage->offStartData
     
    33283344                              0,
    33293345                              cbLock);
     3346#endif
    33303347    if (VBOX_SUCCESS(rc))
    33313348    {
     
    33363353    }
    33373354
     3355#ifndef RT_OS_WINDOWS
    33383356    /* Check for the most bad error in the world. Damn! It must never happens in real life! */
    33393357    if (rc == VERR_FILE_LOCK_LOST)
     
    33523370            rc = VERR_FILE_LOCK_VIOLATION;
    33533371    }
     3372#endif
    33543373
    33553374    Log(("vdiChangeImageMode: Image \"%s\" mode change failed with rc=%Vrc, mode is %s\n",
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