VirtualBox

Changeset 64247 in vbox for trunk/src


Ignore:
Timestamp:
Oct 13, 2016 1:09:21 PM (8 years ago)
Author:
vboxsync
Message:

Devices/Storage/DrvHost*: Move determining the medai size to the host specific sources

Location:
trunk/src/VBox/Devices/Storage
Files:
2 edited

Legend:

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

    r64240 r64247  
    306306
    307307
    308 
    309 #ifdef RT_OS_LINUX
    310 /**
    311  * Get the media size.
    312  *
    313  * @returns VBox status code.
    314  * @param   pThis   The instance data.
    315  * @param   pcb     Where to store the size.
    316  */
    317 static DECLCALLBACK(int) drvHostDvdGetMediaSize(PDRVHOSTBASE pThis, uint64_t *pcb)
    318 {
    319     /*
    320      * Query the media size.
    321      */
    322     /* Clear the media-changed-since-last-call-thingy just to be on the safe side. */
    323     ioctl(RTFileToNative(pThis->hFileDevice), CDROM_MEDIA_CHANGED, CDSL_CURRENT);
    324     return RTFileSeek(pThis->hFileDevice, 0, RTFILE_SEEK_END, pcb);
    325 
    326 }
    327 #endif /* RT_OS_LINUX */
    328 
    329 
    330308#ifdef USE_MEDIA_POLLING
    331309/**
     
    532510            else
    533511                pThis->pfnPoll       = NULL;
    534 #endif
    535 #ifdef RT_OS_LINUX
    536             pThis->pfnGetMediaSize   = drvHostDvdGetMediaSize;
    537512#endif
    538513
  • trunk/src/VBox/Devices/Storage/DrvHostFloppy.cpp

    r62928 r64247  
    2828# include <sys/fcntl.h>
    2929# include <errno.h>
    30 
    31 # elif defined(RT_OS_WINDOWS)
    32 # include <iprt/win/windows.h>
    33 # include <dbt.h>
    34 
    35 #elif defined(RT_OS_L4)
    36 
    37 #else /* !RT_OS_WINDOWS nor RT_OS_LINUX nor RT_OS_L4 */
    38 # error "Unsupported Platform."
    39 #endif /* !RT_OS_WINDOWS nor RT_OS_LINUX nor RT_OS_L4 */
     30#endif
    4031
    4132#include <VBox/vmm/pdmdrv.h>
     
    6657
    6758
    68 
    69 #ifdef RT_OS_WINDOWS
    70 /**
    71  * Get media size - needs a special IOCTL.
    72  *
    73  * @param   pThis   The instance data.
    74  */
    75 static DECLCALLBACK(int) drvHostFloppyGetMediaSize(PDRVHOSTBASE pThis, uint64_t *pcb)
    76 {
    77     DISK_GEOMETRY   geom;
    78     DWORD           cbBytesReturned;
    79     int             rc;
    80     int             cbSectors;
    81 
    82     memset(&geom, 0, sizeof(geom));
    83     rc = DeviceIoControl((HANDLE)RTFileToNative(pThis->hFileDevice), IOCTL_DISK_GET_DRIVE_GEOMETRY,
    84                          NULL, 0, &geom, sizeof(geom), &cbBytesReturned,  NULL);
    85     if (rc) {
    86         cbSectors = geom.Cylinders.QuadPart * geom.TracksPerCylinder * geom.SectorsPerTrack;
    87         *pcb = cbSectors * geom.BytesPerSector;
    88         rc = VINF_SUCCESS;
    89     }
    90     else
    91     {
    92         DWORD   dwLastError;
    93 
    94         dwLastError = GetLastError();
    95         rc = RTErrConvertFromWin32(dwLastError);
    96         Log(("DrvHostFloppy: IOCTL_DISK_GET_DRIVE_GEOMETRY(%s) failed, LastError=%d rc=%Rrc\n",
    97              pThis->pszDevice, dwLastError, rc));
    98         return rc;
    99     }
    100 
    101     return rc;
    102 }
    103 #endif /* RT_OS_WINDOWS */
    104 
    105 #ifdef RT_OS_LINUX
    106 /**
    107  * Get media size and do change processing.
    108  *
    109  * @param   pThis   The instance data.
    110  */
    111 static DECLCALLBACK(int) drvHostFloppyGetMediaSize(PDRVHOSTBASE pThis, uint64_t *pcb)
    112 {
    113     int rc = ioctl(RTFileToNative(pThis->hFileDevice), FDFLUSH);
    114     if (rc)
    115     {
    116         rc = RTErrConvertFromErrno (errno);
    117         Log(("DrvHostFloppy: FDFLUSH ioctl(%s) failed, errno=%d rc=%Rrc\n", pThis->pszDevice, errno, rc));
    118         return rc;
    119     }
    120 
    121     floppy_drive_struct DrvStat;
    122     rc = ioctl(RTFileToNative(pThis->hFileDevice), FDGETDRVSTAT, &DrvStat);
    123     if (rc)
    124     {
    125         rc = RTErrConvertFromErrno(errno);
    126         Log(("DrvHostFloppy: FDGETDRVSTAT ioctl(%s) failed, errno=%d rc=%Rrc\n", pThis->pszDevice, errno, rc));
    127         return rc;
    128     }
    129     pThis->fReadOnly = !(DrvStat.flags & FD_DISK_WRITABLE);
    130 
    131     return RTFileSeek(pThis->hFileDevice, 0, RTFILE_SEEK_END, pcb);
    132 }
    133 #endif /* RT_OS_LINUX */
    134 
    135 
    13659#ifdef RT_OS_LINUX
    13760/**
     
    201124             * Override stuff.
    202125             */
    203 #ifdef RT_OS_WINDOWS
    204             pThis->Base.pfnGetMediaSize = drvHostFloppyGetMediaSize;
    205 #endif
    206126#ifdef RT_OS_LINUX
    207127            pThis->Base.pfnPoll         = drvHostFloppyPoll;
    208             pThis->Base.pfnGetMediaSize = drvHostFloppyGetMediaSize;
    209128#endif
    210129
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