Changeset 6434 in vbox for trunk/src/VBox
- Timestamp:
- Jan 22, 2008 7:10:54 AM (17 years ago)
- Location:
- trunk/src/VBox/Additions/common
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/common/VBoxGuest/VBoxGuest-solaris.c
r6422 r6434 664 664 665 665 666 /** @def IOCPARM_LEN 667 * Gets the length from the ioctl number. 668 * This is normally defined by sys/ioccom.h on BSD systems... 669 */ 670 #ifndef IOCPARM_LEN 671 # define IOCPARM_LEN(Code) (((Code) >> 16) & IOCPARM_MASK) 672 #endif 673 674 666 675 /** 667 676 * Driver ioctl, an alternate entry point for this character driver. … … 722 731 #endif /* USE_SESSION_HASH */ 723 732 724 /** @todo r=bird: This is not the way I told you to implement this. Just do it exactly like the support725 * driver, i.e. the request is just a fixed size header containing the buffer pointer and size of the726 * real request (SUPREQHDR). Trying to save the extra ddi_copyin isn't worth the effort and inflexibility. */727 #if 0728 733 /* 729 734 * Read and validate the request wrapper. … … 732 737 if (IOCPARM_LEN(Cmd) != sizeof(ReqWrap)) 733 738 { 734 Log((DEVICE_NAME ": VBoxAddSolarisIOCtl: bad request %#x \n", Cmd));739 Log((DEVICE_NAME ": VBoxAddSolarisIOCtl: bad request %#x size=%d expected=%d\n", Cmd, IOCPARM_LEN(Cmd), sizeof(ReqWrap))); 735 740 return ENOTTY; 736 741 } 737 742 738 rc = ddi_copyin((void *)pArg, &ReqWrap, sizeof(ReqWrap), Mode);743 int rc = ddi_copyin((void *)pArg, &ReqWrap, sizeof(ReqWrap), Mode); 739 744 if (RT_UNLIKELY(rc)) 740 745 { … … 742 747 return EINVAL; 743 748 } 744 745 749 if (ReqWrap.u32Magic != VBGLBIGREQ_MAGIC) 746 750 { … … 755 759 } 756 760 757 #else758 uint32_t cbBuf = 0;759 int rc = 0;760 int requestType = 0;761 if (VBOXGUEST_IOCTL_NUMBER(Cmd) == VBOXGUEST_IOCTL_NUMBER(VBOXGUEST_IOCTL_VMMREQUEST(0)))762 {763 cbBuf = sizeof(VMMDevRequestHeader);764 requestType = 1;765 LogFlow((DEVICE_NAME ":VBOXGUEST_IOCTL_VMMREQUEST %#x", Cmd));766 }767 #ifdef VBOX_HGCM768 else if (VBOXGUEST_IOCTL_NUMBER(Cmd) == VBOXGUEST_IOCTL_NUMBER(VBOXGUEST_IOCTL_HGCM_CALL(0)))769 {770 cbBuf = sizeof(VBoxGuestHGCMCallInfo);771 requestType = 2;772 LogFlow((DEVICE_NAME ":VBOXGUEST_IOCTL_HGCM_CALL %#x", Cmd));773 }774 #endif /* VBOX_HGCM */775 else if (VBOXGUEST_IOCTL_NUMBER(Cmd) == VBOXGUEST_IOCTL_NUMBER(VBOXGUEST_IOCTL_LOG(0)))776 {777 cbBuf = VBOXGUEST_IOCTL_SIZE(Cmd);778 LogFlow((DEVICE_NAME ":VBOXGUEST_IOCTL_LOG Cmd=%#x cbBuf=%d", Cmd, cbBuf));779 char *pszLogMsg = RTMemTmpAlloc(cbBuf);780 if (RT_UNLIKELY(!pszLogMsg))781 {782 LogRel((DEVICE_NAME ":RTMemAlloc failed to alloc %d bytes\n", cbBuf));783 return ENOMEM;784 }785 rc = ddi_copyin((void *)pArg, pszLogMsg, cbBuf, Mode);786 if (RT_UNLIKELY(rc))787 LogRel((DEVICE_NAME ":ddi_copyin failed. rc=%d\n", rc));788 else789 /** @todo r=bird: this should be handled by generic code and not here so it works 100% the same everywhere. */790 Log(("%.*s", cbBuf, pszLogMsg));791 RTMemTmpFree(pszLogMsg);792 return rc;793 }794 else795 {796 switch (Cmd)797 {798 case VBOXGUEST_IOCTL_GETVMMDEVPORT:799 cbBuf = sizeof(VBoxGuestPortInfo);800 LogFlow((DEVICE_NAME ":VBOXGUEST_IOCTL_GETVMMDEVPORT"));801 break;802 803 case VBOXGUEST_IOCTL_WAITEVENT:804 cbBuf = sizeof(VBoxGuestWaitEventInfo);805 LogFlow((DEVICE_NAME ":VBOXGUEST_IOCTL_WAITEVENT"));806 break;807 808 case VBOXGUEST_IOCTL_CTL_FILTER_MASK:809 cbBuf = sizeof(VBoxGuestFilterMaskInfo);810 LogFlow((DEVICE_NAME ":VBOXGUEST_IOCTL_CTL_FILTER_MASK"));811 break;812 813 #ifdef VBOX_HGCM814 case VBOXGUEST_IOCTL_HGCM_CONNECT:815 cbBuf = sizeof(VBoxGuestHGCMConnectInfo);816 LogFlow((DEVICE_NAME ":VBOXGUEST_IOCTL_HGCM_CONNECT"));817 break;818 819 case VBOXGUEST_IOCTL_HGCM_DISCONNECT:820 cbBuf = sizeof(VBoxGuestHGCMDisconnectInfo);821 LogFlow((DEVICE_NAME ":VBOXGUEST_IOCTL_HGCM_DISCONNECT"));822 break;823 824 case VBOXGUEST_IOCTL_CLIPBOARD_CONNECT:825 cbBuf = sizeof(uint32_t);826 LogFlow((DEVICE_NAME ":VBOXGUEST_IOCTL_CLIPBOARD_CONNECT"));827 break;828 #endif /* VBOX_HGCM */829 830 default:831 {832 LogRel((DEVICE_NAME ":VBoxAddSolarisIOCtl: Unkown request %d\n", Cmd));833 return VERR_NOT_SUPPORTED;834 }835 }836 }837 838 /*839 * Read the header.840 */841 if (requestType == 1)842 {843 VMMDevRequestHeader Hdr;844 rc = ddi_copyin((void *)pArg, &Hdr, sizeof(Hdr), Mode);845 if (RT_UNLIKELY(rc))846 {847 Log((DEVICE_NAME ":VBoxAddSolarisIOCtl: ddi_copyin failed to read header pArg=%p Cmd=%d. rc=%d.\n", pArg, Cmd, rc));848 return EINVAL;849 }850 851 cbBuf = Hdr.size;852 if (RT_UNLIKELY(cbBuf < sizeof(Hdr)))853 {854 Log((DEVICE_NAME ":VBoxAddSolarisIOCtl: Invalid request size (%d) in header.\n", cbBuf));855 return EINVAL;856 }857 }858 else if (requestType == 2)859 {860 VBoxGuestHGCMCallInfo Hdr;861 rc = ddi_copyin((void *)pArg, &Hdr, sizeof(Hdr), Mode);862 if (RT_UNLIKELY(rc))863 {864 Log((DEVICE_NAME ":VBoxAddSolarisIOCtl: ddi_copyin failed to read header pArg=%p Cmd=%d. rc=%d.\n", pArg, Cmd, rc));865 return EINVAL;866 }867 868 if (RT_UNLIKELY(Hdr.cParms <= 0))869 {870 Log((DEVICE_NAME ":VBoxAddSolarisIOCtl: Invalid request size. cParms=%d in HCGM call info header.\n", Hdr.cParms));871 return EINVAL;872 }873 cbBuf += Hdr.cParms * sizeof(HGCMFunctionParameter);874 }875 #endif876 877 761 /* 878 762 * Read the request. 879 763 */ 880 #if 0 881 void *pvBuf = RTMemTmpAlloc(ReqWrap.cbData); 882 #else 764 uint32_t cbBuf = ReqWrap.cbData; 883 765 void *pvBuf = RTMemTmpAlloc(cbBuf); 884 #endif885 766 if (RT_UNLIKELY(!pvBuf)) 886 767 { … … 889 770 } 890 771 891 #if 0 892 rc = ddi_copyin((void *)pArg, (void *)(uintptr_t)ReqWrap.pvData, ReqWrap.cbData, Mode); 893 #else 894 rc = ddi_copyin((void *)pArg, pvBuf, cbBuf, Mode); 895 #endif 772 rc = ddi_copyin((void *)(uintptr_t)ReqWrap.pvDataR3, pvBuf, ReqWrap.cbData, Mode); 896 773 if (RT_UNLIKELY(rc)) 897 774 { … … 900 777 return EFAULT; 901 778 } 902 if (RT_UNLIKELY(cbBuf != 0 && !VALID_PTR(pvBuf))) 779 if (RT_UNLIKELY( cbBuf != 0 780 && !VALID_PTR(pvBuf))) 903 781 { 904 782 RTMemTmpFree(pvBuf); 905 783 Log((DEVICE_NAME ":VBoxAddSolarisIOCtl: pvBuf invalid pointer %p\n", pvBuf)); 784 return EINVAL; 906 785 } 907 786 Log((DEVICE_NAME ":VBoxAddSolarisIOCtl: pSession=%p pid=%d.\n", pSession, (int)RTProcSelf())); … … 919 798 cbDataReturned = cbBuf; 920 799 } 921 #if 0 922 rc = ddi_copyout(pvBuf, (void *)(uintptr_t)ReqWrap.pvData, cbDataReturned, Mode); 923 #else 924 rc = ddi_copyout(pvBuf, (void *)pArg, cbDataReturned, Mode); 925 #endif 800 rc = ddi_copyout(pvBuf, (void *)(uintptr_t)ReqWrap.pvDataR3, cbDataReturned, Mode); 926 801 if (RT_UNLIKELY(rc)) 927 802 { -
trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3Lib.cpp
r6425 r6434 37 37 # include <sys/types.h> 38 38 # include <sys/stat.h> 39 # include <errno.h> 39 40 # include <stdio.h> 40 41 # include <stdlib.h> … … 174 175 return RTErrConvertFromOS2(rc); 175 176 176 #elif defined(RT_OS_SOLARIS) && 0177 #elif defined(RT_OS_SOLARIS) 177 178 VBGLBIGREQ Hdr; 178 179 Hdr.u32Magic = VBGLBIGREQ_MAGIC; 179 180 Hdr.cbData = cbData; 180 Hdr.pvData = pvData; 181 Assert(_IOC_SIZE(iFunction) == sizeof(Hdr)); 182 183 int rc = ioctl((int)File, iFunction, &Hdr); 181 Hdr.pvDataR3 = pvData; 182 183 int rc = ioctl((int)g_File, iFunction, &Hdr); 184 184 if (rc == -1) 185 185 rc = errno; 186 186 return rc; 187 187 188 /* PORTME */189 188 #else 190 189 /* Default implementation (linux, solaris). */
Note:
See TracChangeset
for help on using the changeset viewer.