- Timestamp:
- Jan 14, 2011 1:37:32 PM (14 years ago)
- Location:
- trunk/src/VBox
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/ATAController.cpp
r35346 r35560 2288 2288 PDMCritSectLeave(&pCtl->lock); 2289 2289 rc = VMR3ReqCallWait(PDMDevHlpGetVM(pDevIns), VMCPUID_ANY, 2290 (PFNRT)s->pDrvMount->pfnUnmount, 2, s->pDrvMount, false); 2290 (PFNRT)s->pDrvMount->pfnUnmount, 3, s->pDrvMount, 2291 false /*=fForce*/, true /*=fEeject*/); 2291 2292 AssertReleaseRC(rc); 2292 2293 { -
trunk/src/VBox/Devices/Storage/DevAHCI.cpp
r35353 r35560 4039 4039 4040 4040 rc2 = VMR3ReqCallWait(PDMDevHlpGetVM(pDevIns), VMCPUID_ANY, 4041 (PFNRT)pAhciPort->pDrvMount->pfnUnmount, 2, pAhciPort->pDrvMount, false); 4041 (PFNRT)pAhciPort->pDrvMount->pfnUnmount, 3, 4042 pAhciPort->pDrvMount, false/*=fForce*/, true/*=fEject*/); 4042 4043 Assert(RT_SUCCESS(rc2) || (rc == VERR_PDM_MEDIA_LOCKED)); 4043 4044 } -
trunk/src/VBox/Devices/Storage/DevATA.cpp
r35353 r35560 2982 2982 PDMCritSectLeave(&pCtl->lock); 2983 2983 rc = VMR3ReqCallWait(PDMDevHlpGetVM(pDevIns), VMCPUID_ANY, 2984 (PFNRT)s->pDrvMount->pfnUnmount, 2, s->pDrvMount, false); 2984 (PFNRT)s->pDrvMount->pfnUnmount, 3, 2985 s->pDrvMount /*=fForce*/, true /*=fEject*/); 2985 2986 Assert(RT_SUCCESS(rc) || (rc == VERR_PDM_MEDIA_LOCKED)); 2986 2987 { -
trunk/src/VBox/Devices/Storage/DrvBlock.cpp
r35353 r35560 625 625 626 626 /** @copydoc PDMIMOUNT::pfnUnmount */ 627 static DECLCALLBACK(int) drvblockUnmount(PPDMIMOUNT pInterface, bool fForce )627 static DECLCALLBACK(int) drvblockUnmount(PPDMIMOUNT pInterface, bool fForce, bool fEject) 628 628 { 629 629 PDRVBLOCK pThis = PDMIMOUNT_2_DRVBLOCK(pInterface); -
trunk/src/VBox/Devices/Storage/DrvHostBase.cpp
r35346 r35560 478 478 479 479 /** @copydoc PDMIMOUNT::pfnUnmount */ 480 static DECLCALLBACK(int) drvHostBaseUnmount(PPDMIMOUNT pInterface, bool fForce )480 static DECLCALLBACK(int) drvHostBaseUnmount(PPDMIMOUNT pInterface, bool fForce, bool fEject) 481 481 { 482 482 LogFlow(("drvHostBaseUnmount: returns VERR_NOT_SUPPORTED\n")); -
trunk/src/VBox/Devices/Storage/DrvHostDVD.cpp
r35353 r35560 127 127 128 128 /** @copydoc PDMIMOUNT::pfnUnmount */ 129 static DECLCALLBACK(int) drvHostDvdUnmount(PPDMIMOUNT pInterface, bool fForce )130 { 131 132 133 134 135 136 137 138 139 129 static DECLCALLBACK(int) drvHostDvdUnmount(PPDMIMOUNT pInterface, bool fForce, bool fEject) 130 { 131 PDRVHOSTBASE pThis = PDMIMOUNT_2_DRVHOSTBASE(pInterface); 132 RTCritSectEnter(&pThis->CritSect); 133 134 /* 135 * Validate state. 136 */ 137 int rc = VINF_SUCCESS; 138 if (!pThis->fLocked || fForce) 139 { 140 140 /* Unlock drive if necessary. */ 141 141 if (pThis->fLocked) 142 142 drvHostDvdDoLock(pThis, false); 143 143 144 /* 145 * Eject the disc. 146 */ 144 if (fEject) 145 { 146 /* 147 * Eject the disc. 148 */ 147 149 #if defined(RT_OS_DARWIN) || defined(RT_OS_FREEBSD) 148 uint8_t abCmd[16] =149 {150 SCSI_START_STOP_UNIT, 0, 0, 0, 2 /*eject+stop*/, 0,151 0,0,0,0,0,0,0,0,0,0152 };153 rc = DRVHostBaseScsiCmd(pThis, abCmd, 6, PDMBLOCKTXDIR_NONE, NULL, NULL, NULL, 0, 0);150 uint8_t abCmd[16] = 151 { 152 SCSI_START_STOP_UNIT, 0, 0, 0, 2 /*eject+stop*/, 0, 153 0,0,0,0,0,0,0,0,0,0 154 }; 155 rc = DRVHostBaseScsiCmd(pThis, abCmd, 6, PDMBLOCKTXDIR_NONE, NULL, NULL, NULL, 0, 0); 154 156 155 157 #elif defined(RT_OS_LINUX) 156 rc = ioctl(pThis->FileDevice, CDROMEJECT, 0);157 if (rc < 0)158 {159 if (errno == EBUSY)160 rc = VERR_PDM_MEDIA_LOCKED;161 else if (errno == ENOSYS)162 rc = VERR_NOT_SUPPORTED;163 else164 rc = RTErrConvertFromErrno(errno);165 }158 rc = ioctl(pThis->FileDevice, CDROMEJECT, 0); 159 if (rc < 0) 160 { 161 if (errno == EBUSY) 162 rc = VERR_PDM_MEDIA_LOCKED; 163 else if (errno == ENOSYS) 164 rc = VERR_NOT_SUPPORTED; 165 else 166 rc = RTErrConvertFromErrno(errno); 167 } 166 168 167 169 #elif defined(RT_OS_SOLARIS) 168 rc = ioctl(pThis->FileRawDevice, DKIOCEJECT, 0); 169 if (rc < 0) 170 { 171 if (errno == EBUSY) 172 rc = VERR_PDM_MEDIA_LOCKED; 173 else if (errno == ENOSYS || errno == ENOTSUP) 174 rc = VERR_NOT_SUPPORTED; 175 else if (errno == ENODEV) 176 rc = VERR_PDM_MEDIA_NOT_MOUNTED; 170 rc = ioctl(pThis->FileRawDevice, DKIOCEJECT, 0); 171 if (rc < 0) 172 { 173 if (errno == EBUSY) 174 rc = VERR_PDM_MEDIA_LOCKED; 175 else if (errno == ENOSYS || errno == ENOTSUP) 176 rc = VERR_NOT_SUPPORTED; 177 else if (errno == ENODEV) 178 rc = VERR_PDM_MEDIA_NOT_MOUNTED; 179 else 180 rc = RTErrConvertFromErrno(errno); 181 } 182 183 #elif defined(RT_OS_WINDOWS) 184 RTFILE FileDevice = pThis->FileDevice; 185 if (FileDevice == NIL_RTFILE) /* obsolete crap */ 186 rc = RTFileOpen(&FileDevice, pThis->pszDeviceOpen, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE); 187 if (RT_SUCCESS(rc)) 188 { 189 /* do ioctl */ 190 DWORD cbReturned; 191 if (DeviceIoControl((HANDLE)FileDevice, IOCTL_STORAGE_EJECT_MEDIA, 192 NULL, 0, 193 NULL, 0, &cbReturned, 194 NULL)) 195 rc = VINF_SUCCESS; 196 else 197 rc = RTErrConvertFromWin32(GetLastError()); 198 199 /* clean up handle */ 200 if (FileDevice != pThis->FileDevice) 201 RTFileClose(FileDevice); 202 } 177 203 else 178 rc = RTErrConvertFromErrno(errno); 204 AssertMsgFailed(("Failed to open '%s' for ejecting this tray.\n", rc)); 205 206 207 #else 208 AssertMsgFailed(("Eject is not implemented!\n")); 209 rc = VINF_SUCCESS; 210 #endif 179 211 } 180 212 181 #elif defined(RT_OS_WINDOWS) 182 RTFILE FileDevice = pThis->FileDevice; 183 if (FileDevice == NIL_RTFILE) /* obsolete crap */ 184 rc = RTFileOpen(&FileDevice, pThis->pszDeviceOpen, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_NONE); 185 if (RT_SUCCESS(rc)) 186 { 187 /* do ioctl */ 188 DWORD cbReturned; 189 if (DeviceIoControl((HANDLE)FileDevice, IOCTL_STORAGE_EJECT_MEDIA, 190 NULL, 0, 191 NULL, 0, &cbReturned, 192 NULL)) 193 rc = VINF_SUCCESS; 194 else 195 rc = RTErrConvertFromWin32(GetLastError()); 196 197 /* clean up handle */ 198 if (FileDevice != pThis->FileDevice) 199 RTFileClose(FileDevice); 200 } 201 else 202 AssertMsgFailed(("Failed to open '%s' for ejecting this tray.\n", rc)); 203 204 205 #else 206 AssertMsgFailed(("Eject is not implemented!\n")); 207 rc = VINF_SUCCESS; 208 #endif 209 210 /* 211 * Media is no longer present. 212 */ 213 DRVHostBaseMediaNotPresent(pThis); /** @todo This isn't thread safe! */ 214 } 215 else 216 { 217 Log(("drvHostDvdUnmount: Locked\n")); 218 rc = VERR_PDM_MEDIA_LOCKED; 219 } 220 221 RTCritSectLeave(&pThis->CritSect); 222 LogFlow(("drvHostDvdUnmount: returns %Rrc\n", rc)); 223 return rc; 213 /* 214 * Media is no longer present. 215 */ 216 DRVHostBaseMediaNotPresent(pThis); /** @todo This isn't thread safe! */ 217 } 218 else 219 { 220 Log(("drvHostDvdUnmount: Locked\n")); 221 rc = VERR_PDM_MEDIA_LOCKED; 222 } 223 224 RTCritSectLeave(&pThis->CritSect); 225 LogFlow(("drvHostDvdUnmount: returns %Rrc\n", rc)); 226 return rc; 224 227 } 225 228 -
trunk/src/VBox/Main/src-client/ConsoleImpl2.cpp
r35374 r35560 2711 2711 AssertReturn(pIMount, VERR_INVALID_POINTER); 2712 2712 2713 /* Unmount the media .*/2714 rc = pIMount->pfnUnmount(pIMount, fForceUnmount );2713 /* Unmount the media (but do not eject the medium!) */ 2714 rc = pIMount->pfnUnmount(pIMount, fForceUnmount, false /*=fEject*/); 2715 2715 if (rc == VERR_PDM_MEDIA_NOT_MOUNTED) 2716 2716 rc = VINF_SUCCESS; 2717 /* for example if the medium is locked */ 2718 else if (RT_FAILURE(rc)) 2719 return rc; 2717 2720 } 2718 2721 }
Note:
See TracChangeset
for help on using the changeset viewer.