Changeset 3113 in vbox for trunk/src/VBox/Devices/Storage/DrvHostBase.cpp
- Timestamp:
- Jun 14, 2007 6:29:54 PM (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Storage/DrvHostBase.cpp
r2981 r3113 457 457 458 458 /** @copydoc PDMIMOUNT::pfnUnmount */ 459 static DECLCALLBACK(int) drvHostBaseUnmount(PPDMIMOUNT pInterface )459 static DECLCALLBACK(int) drvHostBaseUnmount(PPDMIMOUNT pInterface, bool fForce) 460 460 { 461 461 LogFlow(("drvHostBaseUnmount: returns VERR_NOT_SUPPORTED\n")); … … 567 567 /** 568 568 * Gets the BSD Name (/dev/disc[0-9]+) for the service. 569 * 570 * This is done by recursing down the I/O registry until we hit upon an entry 571 * with a BSD Name. Usually we find it two levels down. (Further down under 569 * 570 * This is done by recursing down the I/O registry until we hit upon an entry 571 * with a BSD Name. Usually we find it two levels down. (Further down under 572 572 * the IOCDPartitionScheme, the volume (slices) BSD Name is found. We don't 573 573 * seem to have to go this far fortunately.) 574 * 574 * 575 575 * @return VINF_SUCCESS if found, VERR_FILE_NOT_FOUND otherwise. 576 576 * @param Entry The current I/O registry entry reference. 577 577 * @param pszName Where to store the name. 128 bytes. 578 * @param cRecursions Number of recursions. This is used as an precation 578 * @param cRecursions Number of recursions. This is used as an precation 579 579 * just to limit the depth and avoid blowing the stack 580 580 * should we hit a bug or something. … … 610 610 611 611 612 /** 612 /** 613 613 * Callback notifying us that the async DADiskClaim()/DADiskUnmount call has completed. 614 * 614 * 615 615 * @param DiskRef The disk that was attempted claimed / unmounted. 616 616 * @param DissenterRef NULL on success, contains details on failure. … … 630 630 /** 631 631 * Obtain exclusive access to the DVD device, umount it if necessary. 632 * 632 * 633 633 * @return VBox status code. 634 634 * @param pThis The driver instance. … … 644 644 if (irc == kIOReturnSuccess) 645 645 { 646 /* 646 /* 647 647 * This is a bit weird, but if we unmounted the DVD drive we also need to 648 648 * unlock it afterwards or the guest won't be able to eject it later on. … … 661 661 if (irc == kIOReturnExclusiveAccess) 662 662 return VERR_SHARING_VIOLATION; /* already used exclusivly. */ 663 if (irc != kIOReturnBusy) 663 if (irc != kIOReturnBusy) 664 664 return VERR_GENERAL_FAILURE; /* not mounted */ 665 665 666 666 /* 667 667 * Attempt to the unmount all volumes of the device. 668 * It seems we can can do this all in one go without having to enumerate the 669 * volumes (sessions) and deal with them one by one. This is very fortuitous 668 * It seems we can can do this all in one go without having to enumerate the 669 * volumes (sessions) and deal with them one by one. This is very fortuitous 670 670 * as the disk arbitration API is a bit cumbersome to deal with. 671 671 */ … … 683 683 if (pThis->pDADisk) 684 684 { 685 /* 685 /* 686 686 * Try claim the device. 687 687 */ … … 717 717 else 718 718 Log(("%s-%d: claim => rc32=%d & rcDA=%#x\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance, rc32, rcDA)); 719 719 720 720 CFRelease(pThis->pDADisk); 721 721 pThis->pDADisk = NULL; … … 1501 1501 1502 1502 #ifdef __DARWIN__ 1503 /* 1504 * The unclaiming doesn't seem to mean much, the DVD is actaully 1503 /* 1504 * The unclaiming doesn't seem to mean much, the DVD is actaully 1505 1505 * remounted when we release exclusive access. I'm not quite sure 1506 1506 * if I should put the unclaim first or not... … … 1563 1563 } 1564 1564 1565 if (RTCritSectIsInitialized(&pThis->CritSect)) 1565 /* Forget about the notifications. */ 1566 pThis->pDrvMountNotify = NULL; 1567 1568 /* Leave the instance operational if this is just a cleanup of the state 1569 * after an attach error happened. So don't destry the critsect then. */ 1570 if (!pThis->fKeepInstance && RTCritSectIsInitialized(&pThis->CritSect)) 1566 1571 RTCritSectDelete(&pThis->CritSect); 1567 1572 LogFlow(("%s-%d: drvHostBaseDestruct completed\n", pDrvIns->pDrvReg->szDriverName, pDrvIns->iInstance)); … … 1591 1596 */ 1592 1597 pThis->pDrvIns = pDrvIns; 1598 pThis->fKeepInstance = false; 1593 1599 pThis->ThreadPoller = NIL_RTTHREAD; 1594 1600 #ifdef __DARWIN__ … … 1722 1728 } 1723 1729 1730 /* Define whether attach failure is an error (default) or not. */ 1731 bool fAttachFailError; 1732 rc = CFGMR3QueryBool(pCfgHandle, "AttachFailError", &fAttachFailError); 1733 if (VBOX_FAILURE(rc)) 1734 fAttachFailError = true; 1735 pThis->fAttachFailError = fAttachFailError; 1736 1724 1737 /* name to open & watch for */ 1725 1738 #ifdef __WIN__ … … 1754 1767 int DRVHostBaseInitFinish(PDRVHOSTBASE pThis) 1755 1768 { 1769 int src = VINF_SUCCESS; 1756 1770 PPDMDRVINS pDrvIns = pThis->pDrvIns; 1757 1771 … … 1851 1865 pszDevice); 1852 1866 default: 1853 return rc; 1867 if (pThis->fAttachFailError) 1868 return rc; 1869 else 1870 { 1871 int erc = PDMDrvHlpVMSetRuntimeError(pDrvIns, 1872 false, "DrvHost_MOUNTFAIL", 1873 N_("Cannot attach to host device '%s'"), pszDevice); 1874 AssertRC(erc); 1875 src = rc; 1876 } 1854 1877 } 1855 1878 } 1856 1879 #ifdef __WIN__ 1857 DRVHostBaseMediaPresent(pThis); 1880 if (VBOX_SUCCESS(src)) 1881 DRVHostBaseMediaPresent(pThis); 1858 1882 #endif 1859 1883 … … 1873 1897 1874 1898 #ifndef __WIN__ 1875 /* 1876 * Create the event semaphore which the poller thread will wait on. 1877 */ 1878 rc = RTSemEventCreate(&pThis->EventPoller); 1879 if (VBOX_FAILURE(rc)) 1880 return rc; 1899 if (VBOX_SUCCESS(src)) 1900 { 1901 /* 1902 * Create the event semaphore which the poller thread will wait on. 1903 */ 1904 rc = RTSemEventCreate(&pThis->EventPoller); 1905 if (VBOX_FAILURE(rc)) 1906 return rc; 1907 } 1881 1908 #endif 1882 1909 … … 1888 1915 return rc; 1889 1916 1890 /* 1891 * Start the thread which will poll for the media. 1892 */ 1893 rc = RTThreadCreate(&pThis->ThreadPoller, drvHostBaseMediaThread, pThis, 0, 1894 RTTHREADTYPE_INFREQUENT_POLLER, RTTHREADFLAGS_WAITABLE, "DVDMEDIA"); 1895 if (VBOX_FAILURE(rc)) 1896 { 1897 AssertMsgFailed(("Failed to create poller thread. rc=%Vrc\n", rc)); 1917 if (VBOX_SUCCESS(src)) 1918 { 1919 /* 1920 * Start the thread which will poll for the media. 1921 */ 1922 rc = RTThreadCreate(&pThis->ThreadPoller, drvHostBaseMediaThread, pThis, 0, 1923 RTTHREADTYPE_INFREQUENT_POLLER, RTTHREADFLAGS_WAITABLE, "DVDMEDIA"); 1924 if (VBOX_FAILURE(rc)) 1925 { 1926 AssertMsgFailed(("Failed to create poller thread. rc=%Vrc\n", rc)); 1927 return rc; 1928 } 1929 1930 /* 1931 * Wait for the thread to start up (!w32:) and do one detection loop. 1932 */ 1933 rc = RTThreadUserWait(pThis->ThreadPoller, 10000); 1934 AssertRC(rc); 1935 #ifdef __WIN__ 1936 if (!pThis->hwndDeviceChange) 1937 return VERR_GENERAL_FAILURE; 1938 #endif 1939 } 1940 1941 if (VBOX_FAILURE(src)) 1942 return src; 1943 else 1898 1944 return rc; 1899 } 1900 1901 /* 1902 * Wait for the thread to start up (!w32:) and do one detection loop. 1903 */ 1904 rc = RTThreadUserWait(pThis->ThreadPoller, 10000); 1905 AssertRC(rc); 1906 #ifdef __WIN__ 1907 if (!pThis->hwndDeviceChange) 1908 return VERR_GENERAL_FAILURE; 1909 #endif 1910 1911 return rc; 1912 } 1913 1945 } 1946
Note:
See TracChangeset
for help on using the changeset viewer.