- Timestamp:
- Oct 13, 2016 1:09:21 PM (8 years ago)
- Location:
- trunk/src/VBox/Devices/Storage
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DrvHostDVD.cpp
r64240 r64247 306 306 307 307 308 309 #ifdef RT_OS_LINUX310 /**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 330 308 #ifdef USE_MEDIA_POLLING 331 309 /** … … 532 510 else 533 511 pThis->pfnPoll = NULL; 534 #endif535 #ifdef RT_OS_LINUX536 pThis->pfnGetMediaSize = drvHostDvdGetMediaSize;537 512 #endif 538 513 -
trunk/src/VBox/Devices/Storage/DrvHostFloppy.cpp
r62928 r64247 28 28 # include <sys/fcntl.h> 29 29 # 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 40 31 41 32 #include <VBox/vmm/pdmdrv.h> … … 66 57 67 58 68 69 #ifdef RT_OS_WINDOWS70 /**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 else91 {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_LINUX106 /**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 136 59 #ifdef RT_OS_LINUX 137 60 /** … … 201 124 * Override stuff. 202 125 */ 203 #ifdef RT_OS_WINDOWS204 pThis->Base.pfnGetMediaSize = drvHostFloppyGetMediaSize;205 #endif206 126 #ifdef RT_OS_LINUX 207 127 pThis->Base.pfnPoll = drvHostFloppyPoll; 208 pThis->Base.pfnGetMediaSize = drvHostFloppyGetMediaSize;209 128 #endif 210 129
Note:
See TracChangeset
for help on using the changeset viewer.