VirtualBox

Changeset 52222 in vbox


Ignore:
Timestamp:
Jul 29, 2014 6:33:59 AM (10 years ago)
Author:
vboxsync
Message:

Additions/common/VBoxGuestLib: re-write vbglR3DoIOCtl() for readability and fix a potential X Server segementation fault due to a missing symbol.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/common/VBoxGuestLib/VBoxGuestR3Lib.cpp

    r52210 r52222  
    394394    return RTErrConvertFromOS2(rc);
    395395
    396 #elif defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
     396#else
     397# if defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD)
    397398    VBGLBIGREQ Hdr;
    398399    Hdr.u32Magic = VBGLBIGREQ_MAGIC;
    399400    Hdr.cbData = cbData;
    400401    Hdr.pvDataR3 = pvData;
    401 # if HC_ARCH_BITS == 32
     402#  if HC_ARCH_BITS == 32
    402403    Hdr.u32Padding = 0;
    403 # endif
     404#  endif
     405    pvData = &Hdr;
    404406
    405407/** @todo test status code passing! Check that the kernel doesn't do any
     
    408410 *        header with an error code return field (much better alternative
    409411 *        actually). */
    410 #ifdef VBOX_VBGLR3_XSERVER
    411     int rc = xf86ioctl(g_File, iFunction, &Hdr);
    412 #else
    413     if (g_File == NIL_RTFILE)
    414         return VERR_INVALID_HANDLE;
    415     int rc = ioctl(RTFileToNative(g_File), iFunction, &Hdr);
    416 #endif
    417     if (rc == -1)
    418     {
    419         rc = errno;
    420         return RTErrConvertFromErrno(rc);
    421     }
    422     return VINF_SUCCESS;
    423 
    424 #elif defined(RT_OS_DARWIN) || defined(RT_OS_LINUX)
    425 # ifdef VBOX_VBGLR3_XSERVER
     412# elif defined(RT_OS_DARWIN) || defined(RT_OS_LINUX)
     413    NOREF(cbData);
     414# endif
     415
     416# if defined(RT_OS_SOLARIS) || defined(RT_OS_FREEBSD) || defined(RT_OS_DARWIN) || defined(RT_OS_LINUX)
     417#  ifdef VBOX_VBGLR3_XSERVER
    426418    int rc = xf86ioctl((int)g_File, iFunction, pvData);
    427 # else
     419#  else
    428420    if (g_File == NIL_RTFILE)
    429421        return VERR_INVALID_HANDLE;
    430422    int rc = ioctl(RTFileToNative(g_File), iFunction, pvData);
     423#  endif
     424# elif defined(RT_OS_HAIKU)
     425    /* The ioctl hook in Haiku does take the len parameter when specified,
     426     * so just use it. */
     427    int rc = ioctl((int)g_File, iFunction, pvData, cbData);
     428# else
     429#  error Port me!
    431430# endif
    432431    if (RT_LIKELY(rc == 0))
     
    442441        rc = RTErrConvertFromErrno(errno);
    443442# endif
    444     NOREF(cbData);
    445443    return rc;
    446444
    447 #elif defined(RT_OS_HAIKU)
    448     /* The ioctl hook in Haiku does take the len parameter when specified,
    449      * so just use it. */
    450     int rc = ioctl((int)g_File, iFunction, pvData, cbData);
    451     if (RT_LIKELY(rc == 0))
    452         return VINF_SUCCESS;
    453 
    454     /* Positive values are negated VBox error status codes. */
    455     if (rc > 0)
    456         rc = -rc;
    457     else
    458         rc = RTErrConvertFromErrno(errno);
    459     return rc;
    460 
    461 #elif defined(VBOX_VBGLR3_XSERVER)
    462     /* PORTME - This is preferred over the RTFileIOCtl variant below, just be careful with the (int). */
    463 /** @todo test status code passing! */
    464     int rc = xf86ioctl(g_File, iFunction, pvData);
    465     if (rc == -1)
    466         return VERR_FILE_IO_ERROR;  /* This is purely legacy stuff, it has to work and no more. */
    467     return VINF_SUCCESS;
    468 
    469 #else
    470     /* Default implementation - PORTME: Do not use this without testings that passing errors works! */
    471 /** @todo test status code passing! */
    472     int rc2 = VERR_INTERNAL_ERROR;
    473     int rc = RTFileIoCtl(g_File, (int)iFunction, pvData, cbData, &rc2);
    474     if (RT_SUCCESS(rc))
    475         rc = rc2;
    476     return rc;
    477445#endif
    478446}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette