VirtualBox

Changeset 1708 in vbox


Ignore:
Timestamp:
Mar 26, 2007 5:54:16 PM (18 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
19859
Message:

Implemented WIN32 raw disk access setup (the rest was already generic).

File:
1 edited

Legend:

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

    r1695 r1708  
    3737#include <iprt/string.h>
    3838
    39 #ifdef __LINUX__
     39#ifdef __WIN32__
     40#include <windows.h>
     41#include <winioctl.h>
     42#elif __LINUX__
    4043#include <errno.h>
    4144#include <sys/ioctl.h>
    4245#include <linux/hdreg.h>
    4346#include <linux/fs.h>
    44 #endif /* __LINUX__ */
     47#endif /* !__WIN32__ && !__LINUX__ */
    4548
    4649#include "Builtins.h"
     
    326329        pThis->cSectors = 0;
    327330        pThis->enmTranslation = PDMBIOSTRANSLATION_AUTO;
    328 #if 0 /* def __WIN__ */
     331#ifdef __WIN32__
    329332        DISK_GEOMETRY DriveGeo;
    330         uint32_t cbDriveGeo;
    331         if (DeviceIOControl((HANDLE)pThis->HostDiskFile,
    332                             IOCTL_DISK_GET_GET_DRIVE_GEOMETRY, NULL, 0,
     333        DWORD cbDriveGeo;
     334        if (DeviceIoControl((HANDLE)pThis->HostDiskFile,
     335                            IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0,
    333336                            &DriveGeo, sizeof(DriveGeo), &cbDriveGeo, NULL))
    334 #elif __LINUX__
     337        {
     338            if (DriveGeo.MediaType == FixedMedia)
     339            {
     340                pThis->cCylinders = DriveGeo.Cylinders.QuadPart;
     341                pThis->cHeads = DriveGeo.TracksPerCylinder;
     342                pThis->cSectors = DriveGeo.SectorsPerTrack;
     343                pThis->enmTranslation = PDMBIOSTRANSLATION_NONE;
     344                if (!pThis->cbSize)
     345                {
     346                    /* Windows NT has no IOCTL_DISK_GET_LENGTH_INFORMATION
     347                     * ioctl. This was added to Windows XP, so use the
     348                     * available info from DriveGeo. */
     349                    pThis->cbSize =     DriveGeo.Cylinders.QuadPart
     350                                    *   DriveGeo.TracksPerCylinder
     351                                    *   DriveGeo.SectorsPerTrack
     352                                    *   DriveGeo.BytesPerSector;
     353                }
     354            }
     355            else
     356                rc = VERR_MEDIA_NOT_RECOGNIZED;
     357        }
     358        else
     359            rc = RTErrConvertFromWin32(GetLastError());
     360#elif defined(__LINUX__)
    335361        struct hd_geometry DriveGeo;
    336         if (ioctl(pThis->HostDiskFile, HDIO_GETGEO, &DriveGeo) < 0)
    337             rc = RTErrConvertFromErrno(errno);
    338         else
     362        if (!ioctl(pThis->HostDiskFile, HDIO_GETGEO, &DriveGeo))
    339363        {
    340364            pThis->cCylinders = DriveGeo.cylinders;
     
    347371                if (!ioctl(pThis->HostDiskFile, BLKGETSIZE, &cBlocks))
    348372                    pThis->cbSize = (uint64_t)cBlocks * 512;
     373                else
     374                    rc = RTErrConvertFromErrno(errno);
    349375            }
    350376        }
     377        else
     378            rc = RTErrConvertFromErrno(errno);
     379#else
     380        /** @todo add further host OS geometry detection mechanisms. */
     381        AssertMsgFail("Host disk support for this host is unimplemented.\n");
     382        rc = VERR_NOT_IMPLEMENTED;
    351383#endif
    352         /** @todo add further host OS geometry detection mechanisms. */
    353384    }
    354385
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