VirtualBox

Changeset 85945 in vbox for trunk/src/VBox/Storage


Ignore:
Timestamp:
Aug 28, 2020 9:14:21 PM (5 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
140140
Message:

Storage/VMDK: Simplify vmdkRawDescWinMakePartitionName by using IOCTL_STORAGE_GET_DEVICE_NUMBER instead of path parsing. bugref:9224

File:
1 edited

Legend:

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

    r85903 r85945  
    37693769                                           char **ppszRawPartition)
    37703770{
     3771# if 1
     3772    /*
     3773     * Ask the drive handle for its device number rather than mess about extracting
     3774     * it from the path (discovered this later when doing the path verification).
     3775     */
     3776    int                   rc         = VINF_SUCCESS;
     3777    DWORD                 cbReturned = 0;
     3778    STORAGE_DEVICE_NUMBER DevNum;
     3779    RT_ZERO(DevNum);
     3780    if (DeviceIoControl((HANDLE)RTFileToNative(hRawDrive), IOCTL_STORAGE_GET_DEVICE_NUMBER,
     3781                        NULL /*pvInBuffer*/, 0 /*cbInBuffer*/, &DevNum, sizeof(DevNum), &cbReturned, NULL /*pOverlapped*/))
     3782        RTStrAPrintf(ppszRawPartition, "\\\\.\\Harddisk%uPartition%u", DevNum.DeviceNumber, idxPartition);
     3783    else
     3784        rc = vdIfError(pImage->pIfError, RTErrConvertFromWin32(GetLastError()), RT_SRC_POS,
     3785                       N_("VMDK: Image path: '%s'. IOCTL_STORAGE_GET_DEVICE_NUMBER failed on '%s': %u"),
     3786                       pImage->pszFilename, pszRawDrive, GetLastError());
     3787    return rc;
     3788
     3789# else
    37713790    /*
    37723791     * First variant is \\.\PhysicalDriveX -> \\.\HarddiskXPartition{idxPartition}
     
    38293848                       pImage->pszFilename, pszRawDrive, idxPartition, rc);
    38303849    return rc;
     3850# endif
    38313851}
    38323852#endif /* RT_OS_WINDOWS */
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