Changeset 68566 in vbox for trunk/src/VBox/Additions/common
- Timestamp:
- Aug 31, 2017 12:10:27 PM (7 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxGuest
- Files:
-
- 1 deleted
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.c
r68565 r68566 759 759 760 760 761 /** 762 * @note This code is duplicated on other platforms with variations, so please 763 * keep them all up to date when making changes! 764 */ 765 int VBOXCALL VBoxGuestIDC(void *pvSession, uintptr_t uReq, PVBGLREQHDR pReqHdr, size_t cbReq) 766 { 767 /* 768 * Simple request validation (common code does the rest). 769 */ 770 int rc; 771 if ( RT_VALID_PTR(pReqHdr) 772 && cbReq >= sizeof(*pReqHdr)) 773 { 774 /* 775 * All requests except the connect one requires a valid session. 776 */ 777 PVBOXGUESTSESSION pSession = (PVBOXGUESTSESSION)pvSession; 778 if (pSession) 779 { 780 if ( RT_VALID_PTR(pSession) 781 && pSession->pDevExt == &g_DevExt) 782 rc = VGDrvCommonIoCtl(uReq, &g_DevExt, pSession, pReqHdr, cbReq); 783 else 784 rc = VERR_INVALID_HANDLE; 785 } 786 else if (uReq == VBGL_IOCTL_IDC_CONNECT) 787 { 788 /* Reference ourselves to make sure we don't go away. 789 Note! Would be better if the IDC code did this. */ 790 mutex_enter(&g_LdiMtx); 791 if (g_LdiHandle) 792 { 793 ++g_cLdiOpens; 794 rc = VINF_SUCCESS; 795 } 796 else 797 { 798 ldi_ident_t DevIdent = ldi_ident_from_anon(); 799 rc = ldi_open_by_name(VBOXGUEST_DEVICE_NAME, FREAD, kcred, &g_LdiHandle, DevIdent); 800 ldi_ident_release(DevIdent); 801 if (!rc) 802 ++g_cLdiOpens; 803 else 804 { 805 LogRel(("VBoxGuestIDCOpen: ldi_open_by_name failed. rc=%d\n", rc)); 806 rc = VERR_OPEN_FAILED; 807 } 808 } 809 mutex_exit(&g_LdiMtx); 810 811 if (RT_SUCCESS(rc)) 812 { 813 rc = VGDrvCommonCreateKernelSession(&g_DevExt, &pSession); 814 if (RT_SUCCESS(rc)) 815 { 816 rc = VGDrvCommonIoCtl(uReq, &g_DevExt, pSession, pReqHdr, cbReq); 817 if (RT_FAILURE(rc)) 818 VGDrvCommonCloseSession(&g_DevExt, pSession); 819 } 820 } 821 } 822 else 823 rc = VERR_INVALID_HANDLE; 824 825 /* 826 * Dereference the driver on disconnect and failed connect. 827 */ 828 if (RT_UNLIKELY( ( uReq == VBGL_IOCTL_IDC_CONNECT 829 && RT_FAILURE(rc)) 830 || ( uReq == VBGL_IOCTL_IDC_DISCONNECT 831 && RT_SUCCESS(rc)) )) 832 { 833 mutex_enter(&g_LdiMtx); 834 if (g_cLdiOpens > 0) 835 --g_cLdiOpens; 836 if ( g_cLdiOpens == 0 837 && g_LdiHandle) 838 { 839 ldi_close(g_LdiHandle, FREAD, kcred); 840 g_LdiHandle = NULL; 841 } 842 mutex_exit(&g_LdiMtx); 843 } 844 } 845 else 846 rc = VERR_INVALID_POINTER; 847 return rc; 848 } 849 850 851 761 852 static int vgdrvSolarisPoll(dev_t Dev, short fEvents, int fAnyYet, short *pReqEvents, struct pollhead **ppPollHead) 762 853 { … … 782 873 return 0; 783 874 } 784 else 785 { 786 Log(("vgdrvSolarisPoll: no state data for %d\n", getminor(Dev))); 787 return EINVAL; 788 } 875 876 Log(("vgdrvSolarisPoll: no state data for %d\n", getminor(Dev))); 877 return EINVAL; 789 878 } 790 879 … … 1023 1112 } 1024 1113 1025 1026 /* Common code that depend on g_DevExt. */1027 #include "VBoxGuestIDC-unix.c.h"1028
Note:
See TracChangeset
for help on using the changeset viewer.