VirtualBox

Changeset 86241 in vbox for trunk/src/VBox/Main/src-server


Ignore:
Timestamp:
Sep 23, 2020 2:31:55 PM (4 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
140510
Message:

Main: bugref:9224: Fixed the error when obtain the disk info in block mode in the MacOS

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/src-server/HostDriveImpl.cpp

    r85929 r86241  
    6666    m.partitions.clear();
    6767
    68     const char *pszDrivePath = drivePath.c_str();
    69 
    70 #ifdef RT_OS_DARWIN
    71     /*
    72      * Ensure the path specified for the drive in raw mode, i.e. drive name begins with 'r'
    73      * Otherwise, the RTFileOpen will always return the error about 'busy resource'
    74      */
    75     /** @todo r=bird: Shouldn't we make iokit.cpp just return the /dev/rdiskX*
    76      *        paths instead then? */
    77     com::Utf8Str strAdjustedDrivePath;
    78     const char *pszDriveName = RTPathFilename(pszDrivePath);
    79     if (pszDriveName && *pszDriveName != 'r')
    80     {
    81         strAdjustedDrivePath = drivePath.substr(0, (size_t)(pszDriveName - pszDrivePath));
    82         strAdjustedDrivePath.append('r');
    83         strAdjustedDrivePath.append(pszDriveName);
    84         pszDrivePath = strAdjustedDrivePath.c_str();
    85     }
    86 #endif
    87 
    8868    /*
    8969     * Try open the drive so we can extract futher details,
     
    9272    HRESULT hrc = E_FAIL;
    9373    RTFILE hRawFile = NIL_RTFILE;
    94     int vrc = RTFileOpen(&hRawFile, pszDrivePath, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
     74    int vrc = RTFileOpen(&hRawFile, drivePath.c_str(), RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    9575    if (RT_SUCCESS(vrc))
    9676    {
     
    192172    }
    193173    else
    194         hrc = Global::vboxStatusCodeToCOM(vrc);
     174    {
     175        /*
     176         * We don't use the Global::vboxStatusCodeToCOM(vrc) here
     177         * because RTFileOpen can return some error which causes
     178         * the assertion and breaks original idea of returning
     179         * the object in the limited state.
     180         */
     181        if (   vrc == VERR_RESOURCE_BUSY
     182            || vrc == VERR_ACCESS_DENIED)
     183            hrc = E_ACCESSDENIED;
     184        else
     185            hrc = VBOX_E_IPRT_ERROR;
     186    }
    195187
    196188    /* Confirm a successful initialization */
Note: See TracChangeset for help on using the changeset viewer.

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette