Changeset 68812 in vbox
- Timestamp:
- Sep 21, 2017 3:43:12 PM (7 years ago)
- Location:
- trunk/src/VBox/Additions/common/VBoxGuest
- Files:
-
- 2 edited
-
VBoxGuest-solaris.c (modified) (8 diffs)
-
lib/VBoxGuestR0LibIdc-solaris.cpp (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.c
r68793 r68812 483 483 /** 484 484 * User context entry points 485 */ 486 static int vgdrvSolarisOpen(dev_t *pDev, int fFlag, int fType, cred_t *pCred) 485 * 486 * @remarks fFlags are the flags passed to open() or to ldi_open_by_name. In 487 * the latter case the FKLYR flag is added to indicate that the caller 488 * is a kernel component rather than user land. 489 */ 490 static int vgdrvSolarisOpen(dev_t *pDev, int fFlags, int fType, cred_t *pCred) 487 491 { 488 492 int rc; … … 517 521 * Create a new session. 518 522 */ 519 rc = VGDrvCommonCreateUserSession(&g_DevExt, &pSession); 523 if (!(fFlags & FKLYR)) 524 rc = VGDrvCommonCreateUserSession(&g_DevExt, &pSession); 525 else 526 rc = VGDrvCommonCreateKernelSession(&g_DevExt, &pSession); 520 527 if (RT_SUCCESS(rc)) 521 528 { 522 pState->pvProcRef = proc_ref(); 529 if (!(fFlags & FKLYR)) 530 pState->pvProcRef = proc_ref(); 531 else 532 pState->pvProcRef = NULL; 523 533 pState->pSession = pSession; 524 534 *pDev = makedevice(getmajor(*pDev), iOpenInstance); … … 547 557 } 548 558 549 proc_unref(pState->pvProcRef); 559 if (pState->pvProcRef != NULL) 560 { 561 proc_unref(pState->pvProcRef); 562 pState->pvProcRef = NULL; 563 } 550 564 pSession = pState->pSession; 551 565 pState->pSession = NULL; … … 561 575 * Close the session. 562 576 */ 563 VGDrvCommonCloseSession(&g_DevExt, pSession); 577 if (pSession) 578 VGDrvCommonCloseSession(&g_DevExt, pSession); 564 579 return 0; 565 580 } … … 591 606 return 0; 592 607 } 608 609 610 /** @def IOCPARM_LEN 611 * Gets the length from the ioctl number. 612 * This is normally defined by sys/ioccom.h on BSD systems... 613 */ 614 #ifndef IOCPARM_LEN 615 # define IOCPARM_LEN(x) ( ((x) >> 16) & IOCPARM_MASK ) 616 #endif 593 617 594 618 … … 633 657 } 634 658 659 /* 660 * It's kind of simple if this is a kernel session, take slow path if user land. 661 */ 662 if (pSession->R0Process == NIL_RTR0PROCESS) 663 { 664 if (IOCPARM_LEN(iCmd) == sizeof(VBGLREQHDR)) 665 { 666 PVBGLREQHDR pHdr = (PVBGLREQHDR)iArgs; 667 int rc; 668 if (iCmd != VBGL_IOCTL_IDC_DISCONNECT) 669 rc =VGDrvCommonIoCtl(iCmd, &g_DevExt, pSession, pHdr, RT_MAX(pHdr->cbIn, pHdr->cbOut)); 670 else 671 { 672 pState->pSession = NULL; 673 rc = VGDrvCommonIoCtl(iCmd, &g_DevExt, pSession, pHdr, RT_MAX(pHdr->cbIn, pHdr->cbOut)); 674 if (RT_FAILURE(rc)) 675 pState->pSession = pSession; 676 } 677 return rc; 678 } 679 } 680 635 681 return vgdrvSolarisIOCtlSlow(pSession, iCmd, Mode, iArgs); 636 682 } 637 638 639 /** @def IOCPARM_LEN640 * Gets the length from the ioctl number.641 * This is normally defined by sys/ioccom.h on BSD systems...642 */643 #ifndef IOCPARM_LEN644 # define IOCPARM_LEN(x) ( ((x) >> 16) & IOCPARM_MASK )645 #endif646 683 647 684 … … 755 792 756 793 794 #if 0 757 795 /** 758 796 * @note This code is duplicated on other platforms with variations, so please … … 797 835 return rc; 798 836 } 799 837 #endif 800 838 801 839 -
trunk/src/VBox/Additions/common/VBoxGuest/lib/VBoxGuestR0LibIdc-solaris.cpp
r68793 r68812 41 41 ldi_handle_t hDev = NULL; 42 42 ldi_ident_t hIdent = ldi_ident_from_anon(); 43 /* Note! ldi_open_by_name actually opens the device and ends up creating a useless user session. 44 Wonder if there is any way to detect ldi_open_by_name and do I/O controls via hDev... */ 45 int rc = ldi_open_by_name(VBOXGUEST_DEVICE_NAME, FREAD, kcred, &hDev, hIdent); 43 int rc = ldi_open_by_name((char *)VBOXGUEST_DEVICE_NAME, FREAD, kcred, &hDev, hIdent); 46 44 ldi_ident_release(hIdent); 47 45 if (rc == 0) 48 46 { 49 rc = VBoxGuestIDC(NULL, VBGL_IOCTL_IDC_CONNECT, &pReq->Hdr, sizeof(*pReq)); 47 pHandle->s.hDev = hDev; 48 rc = VbglR0IdcCallRaw(pHandle, VBGL_IOCTL_IDC_CONNECT, &pReq->Hdr, sizeof(*pReq)); 50 49 if (RT_SUCCESS(rc) && RT_SUCCESS(pReq->Hdr.rc)) 51 {52 pHandle->s.hDev = hDev;53 50 return VINF_SUCCESS; 54 }55 51 ldi_close(hDev, FREAD, kcred); 56 52 } … … 64 60 int VBOXCALL vbglR0IdcNativeClose(PVBGLIDCHANDLE pHandle, PVBGLIOCIDCDISCONNECT pReq) 65 61 { 66 int rc = V BoxGuestIDC(pHandle->s.pvSession, VBGL_IOCTL_IDC_DISCONNECT, &pReq->Hdr, sizeof(*pReq));62 int rc = VbglR0IdcCallRaw(pHandle, VBGL_IOCTL_IDC_DISCONNECT, &pReq->Hdr, sizeof(*pReq)); 67 63 if (RT_SUCCESS(rc) && RT_SUCCESS(pReq->Hdr.rc)) 68 64 { … … 85 81 DECLR0VBGL(int) VbglR0IdcCallRaw(PVBGLIDCHANDLE pHandle, uintptr_t uReq, PVBGLREQHDR pReqHdr, uint32_t cbReq) 86 82 { 83 #if 0 87 84 return VBoxGuestIDC(pHandle->s.pvSession, uReq, pReqHdr, cbReq); 85 #else 86 int iIgn; 87 int rc = ldi_ioctl(pHandle->s.hDev, uReq, (intptr_t)pReqHdr, FKIOCTL | FNATIVE, kcred, &iIgn); 88 if (rc == 0) 89 return VINF_SUCCESS; 90 return RTErrConvertFromErrno(rc); 91 #endif 88 92 } 89 93
Note:
See TracChangeset
for help on using the changeset viewer.

