VirtualBox

Changeset 31173 in vbox for trunk/src/VBox/VMM


Ignore:
Timestamp:
Jul 28, 2010 4:17:36 PM (14 years ago)
Author:
vboxsync
Message:

AsyncCompletion: Add a flag to prevent write locking an image.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/VMM/PDMAsyncCompletionFile.cpp

    r30952 r31173  
    800800    PDMACFILEEPBACKEND enmEpBackend = pEpClassFile->enmEpBackendDefault;
    801801
    802     AssertMsgReturn((fFlags & ~(PDMACEP_FILE_FLAGS_READ_ONLY | PDMACEP_FILE_FLAGS_CACHING)) == 0,
     802    AssertMsgReturn((fFlags & ~(PDMACEP_FILE_FLAGS_READ_ONLY | PDMACEP_FILE_FLAGS_CACHING | PDMACEP_FILE_FLAGS_DONT_LOCK)) == 0,
    803803                    ("PDMAsyncCompletion: Invalid flag specified\n"), VERR_INVALID_PARAMETER);
    804804
    805     unsigned fFileFlags = fFlags & PDMACEP_FILE_FLAGS_READ_ONLY
    806                          ? RTFILE_O_READ      | RTFILE_O_OPEN | RTFILE_O_DENY_NONE
    807                          : RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE;
     805    unsigned fFileFlags = RTFILE_O_OPEN;
     806
     807    if (fFlags & PDMACEP_FILE_FLAGS_READ_ONLY)
     808        fFlags |= RTFILE_O_READ | RTFILE_O_DENY_NONE;
     809    else
     810    {
     811        fFlags |= RTFILE_O_READWRITE;
     812
     813        /*
     814         * Opened in read/write mode. Check whether the caller wants to
     815         * avoid the lock. Return an error in case caching is enabled
     816         * because this can lead to data corruption.
     817         */
     818        if (fFlags & PDMACEP_FILE_FLAGS_DONT_LOCK)
     819        {
     820            if (fFlags & PDMACEP_FILE_FLAGS_CACHING)
     821                return VERR_NOT_SUPPORTED;
     822            else
     823                fFlags |= RTFILE_O_DENY_NONE;
     824        }
     825        else
     826            fFlags |= RTFILE_O_DENY_WRITE;
     827    }
    808828
    809829    if (enmMgrType == PDMACEPFILEMGRTYPE_ASYNC)
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