VirtualBox

Changeset 6235 in vbox


Ignore:
Timestamp:
Jan 3, 2008 5:41:38 PM (17 years ago)
Author:
vboxsync
Message:

Fixed obvious typo in RTFileOpen call. Eliminated unecessary code duplication (solaris/linux). Fixed bug in the string stepping in VbglR3WriteLog. Hope it still compiles.

File:
1 edited

Legend:

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

    r6231 r6235  
    3333#include <iprt/mem.h>
    3434#include <VBox/VBoxGuest.h>
     35
    3536
    3637/*******************************************************************************
     
    9798    g_File = hf;
    9899
    99 #elif defined(RT_OS_SOLARIS) || defined(RT_OS_LINUX)
     100     /* PORTME */
     101#else
     102    /* the default implemenation. (linux, solaris) */
    100103    RTFILE File;
    101     int rc = RTFileOpen(&File, VBOXGUEST_DEVICE_NAME, RTFILE_O_READWRITE);
    102     if (RT_FAILURE(rc))
    103         return rc;
    104     g_File = File;
    105 
    106 #else
    107 # error port me  /** @note isn't it nicer to put a todo error here than to
    108                      put in a flag which will assert where no-one sees it? */
    109     /* the default implemenation. */
    110     RTFILE File;
    111     int rc = RTFileOpen(&File, VBOXGUEST_DEVICE_NAME, RTFILE_O_DENY_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
     104    int rc = RTFileOpen(&File, VBOXGUEST_DEVICE_NAME, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
    112105    if (RT_FAILURE(rc))
    113106        return rc;
     
    163156    return RTErrConvertFromOS2(rc);
    164157
    165 #elif defined(RT_OS_LINUX) || defined(RT_OS_SOLARIS)
     158    /* PORTME */
     159#else
     160    /* Defalut implementation (linux, solaris). */
    166161    int rc2 = VERR_INTERNAL_ERROR;
    167162    int rc = RTFileIoCtl(g_File, (int)iFunction, pvData, cbData, &rc2);
     
    169164        rc = rc2;
    170165    return rc;
    171 #else
    172 # error "PORTME"
    173 # if 0 /* if this works for anyone I'd be amazed. */
    174     int rc2 = VERR_INTERNAL_ERROR;
    175     int rc = RTFileIoCtl(g_File, (int)iFunction, pvData, cbData, &rc2);
    176     if (RT_SUCCESS(rc))
    177         rc = rc2;
    178     return rc;
    179 # endif
    180166#endif
    181167}
     
    245231}
    246232
     233
    247234/**
    248235 * Write to the backdoor logger from ring 3 guest code.
    249  * @note this currently does not accept more than 255 bytes of data at
    250  * one time.  It should probably be rewritten to use pass a pointer
    251  * in the IOCtl.
    252  *
     236 *
    253237 * @returns IPRT status code
     238 *
     239 * @remakes This currently does not accept more than 255 bytes of data at
     240 *          one time. It should probably be rewritten to use pass a pointer
     241 *          in the IOCtl.
    254242 */
    255243VBGLR3DECL(int) VbglR3WriteLog(const char *pch, size_t cb)
    256244{
     245    /*
     246     * Solaris does not accept more than 255 bytes of data per ioctl request,
     247     * so split large string into 128 byte chunks to prevent truncation.
     248     */
     249#define STEP 128
    257250    int rc = VINF_SUCCESS;
    258 
    259     /* Solaris does not accept more than 255 bytes of data. */
    260 #define STEP 128
    261     for (size_t iOffs = 0; (iOffs < cb) && (RT_SUCCESS(rc)); iOffs += STEP)
     251    for (size_t off = 0; off < cb && RT_SUCCESS(rc); off += STEP)
    262252    {
    263         rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_LOG(cb), (void *) (pch + iOffs),
    264                            iOffs + STEP < cb ? STEP : cb - iOffs);
     253        size_t cbStep = RT_MIN(cb - off, STEP);
     254        rc = vbglR3DoIOCtl(VBOXGUEST_IOCTL_LOG(cbStep), pch + off, cbStep);
    265255    }
    266256#undef STEP
    267257    return rc;
    268258}
     259
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