VirtualBox

Changeset 71781 in vbox


Ignore:
Timestamp:
Apr 9, 2018 3:43:14 PM (7 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
121884
Message:

Guest Control/VBoxService: Resolved a @todo, logging adjustments, a bit of cleanup.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/src/VBox/Additions/common/VBoxService/VBoxServiceControlSession.cpp

    r71432 r71781  
    183183            if (RT_SUCCESS(rc))
    184184            {
    185                 /** @todo r=bird: Plase, use RTStrCopy for stuff like this! */
    186                 RTStrPrintf(pFile->szName, sizeof(pFile->szName), "%s", szFile);
     185                RTStrCopy(pFile->szName, sizeof(pFile->szName), szFile);
    187186
    188187                uint64_t fFlags;
    189188                rc = RTFileModeToFlagsEx(szAccess, szDisposition, NULL /* pszSharing, not used yet */, &fFlags);
    190                 VGSvcVerbose(4, "[File %s]: Opening with fFlags=0x%x, rc=%Rrc\n", pFile->szName, fFlags, rc);
     189                VGSvcVerbose(4, "[File %s] Opening with fFlags=0x%x, rc=%Rrc\n", pFile->szName, fFlags, rc);
    191190
    192191                if (RT_SUCCESS(rc))
     
    199198                    rc = RTFileSeek(pFile->hFile, (int64_t)offOpen, RTFILE_SEEK_BEGIN, NULL /* Current offset */);
    200199                    if (RT_FAILURE(rc))
    201                         VGSvcError("[File %s]: Seeking to offset %RU64 failed; rc=%Rrc\n", pFile->szName, offOpen, rc);
     200                        VGSvcError("[File %s] Seeking to offset %RU64 failed; rc=%Rrc\n", pFile->szName, offOpen, rc);
    202201                }
    203202                else if (RT_FAILURE(rc))
    204                     VGSvcError("[File %s]: Opening failed with rc=%Rrc\n", pFile->szName, rc);
     203                    VGSvcError("[File %s] Opening failed with rc=%Rrc\n", pFile->szName, rc);
    205204            }
    206205
     
    212211                RTListAppend(&pSession->lstFiles, &pFile->Node);
    213212
    214                 VGSvcVerbose(3, "[File %s]: Opened (ID=%RU32)\n", pFile->szName, pFile->uHandle);
     213                VGSvcVerbose(2, "[File %s] Opened (ID=%RU32)\n", pFile->szName, pFile->uHandle);
    215214            }
    216215
     
    233232    }
    234233
    235 #ifdef DEBUG
    236     VGSvcVerbose(4, "Opening file '%s' (open mode='%s', disposition='%s', creation mode=0x%x returned rc=%Rrc\n",
     234    VGSvcVerbose(4, "[File %s] Opening (open mode='%s', disposition='%s', creation mode=0x%x) returned rc=%Rrc\n",
    237235                 szFile, szAccess, szDisposition, uCreationMode, rc);
    238 #endif
    239236    return rc;
    240237}
     
    246243    AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
    247244
    248     PVBOXSERVICECTRLFILE pFile = NULL;
    249 
    250245    uint32_t uHandle = 0;
    251246    int rc = VbglR3GuestCtrlFileGetClose(pHostCtx, &uHandle /* File handle to close */);
    252247    if (RT_SUCCESS(rc))
    253248    {
    254         pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle);
     249        PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle);
    255250        if (pFile)
     251        {
     252            VGSvcVerbose(2, "[File %s] Closing (handle=%RU32)\n", pFile ? pFile->szName : "<Not found>", uHandle);
     253
    256254            rc = vgsvcGstCtrlSessionFileDestroy(pFile);
     255        }
    257256        else
    258257            rc = VERR_NOT_FOUND;
     
    266265    }
    267266
    268 #ifdef DEBUG
    269     VGSvcVerbose(4, "Closing file '%s' (handle=%RU32) returned rc=%Rrc\n", pFile ? pFile->szName : "<Not found>", uHandle, rc);
    270 #endif
    271267    return rc;
    272268}
     
    278274    AssertPtrReturn(pSession, VERR_INVALID_POINTER);
    279275    AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
    280 
    281     PVBOXSERVICECTRLFILE pFile = NULL;
    282276
    283277    uint32_t uHandle = 0;
     
    289283        size_t cbRead = 0;
    290284
    291         pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle);
     285        PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle);
    292286        if (pFile)
    293287        {
     
    310304            rc = VERR_NOT_FOUND;
    311305
     306        VGSvcVerbose(4, "[File %s] Read %zu/%RU32 bytes, rc=%Rrc\n", pFile ? pFile->szName : "<Not found>", cbRead, cbToRead, rc);
     307
    312308        /* Report back in any case. */
    313309        int rc2 = VbglR3GuestCtrlFileCbRead(pHostCtx, rc, pvDataRead, (uint32_t)cbRead);
     
    322318    }
    323319
    324 #ifdef DEBUG
    325     VGSvcVerbose(4, "Reading file '%s' (handle=%RU32) returned rc=%Rrc\n", pFile ? pFile->szName : "<Not found>", uHandle, rc);
    326 #endif
    327320    return rc;
    328321}
     
    334327    AssertPtrReturn(pSession, VERR_INVALID_POINTER);
    335328    AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
    336 
    337     PVBOXSERVICECTRLFILE pFile = NULL;
    338329
    339330    uint32_t uHandle = 0;
     
    346337        size_t cbRead = 0;
    347338
    348         pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle);
     339        PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle);
    349340        if (pFile)
    350341        {
     
    360351                if (RT_SUCCESS(rc))
    361352                    rc = RTFileReadAt(pFile->hFile, (RTFOFF)offReadAt, pvDataRead, cbToRead, &cbRead);
     353
     354                VGSvcVerbose(4, "[File %s] Read %zu bytes @ %RU64, rc=%Rrc\n",
     355                             pFile ? pFile->szName : "<Not found>", cbRead, offReadAt, rc);
    362356            }
    363357            else
     
    379373    }
    380374
    381 #ifdef DEBUG
    382     VGSvcVerbose(4, "Reading file '%s' at offset (handle=%RU32) returned rc=%Rrc\n",
    383                  pFile ? pFile->szName : "<Not found>", uHandle, rc);
    384 #endif
    385375    return rc;
    386376}
     
    395385    AssertPtrReturn(cbScratchBuf, VERR_INVALID_PARAMETER);
    396386
    397     PVBOXSERVICECTRLFILE pFile = NULL;
    398 
    399387    uint32_t uHandle = 0;
    400388    uint32_t cbToWrite;
     
    403391    {
    404392        size_t cbWritten = 0;
    405         pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle);
     393        PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle);
    406394        if (pFile)
    407395        {
    408396            rc = RTFileWrite(pFile->hFile, pvScratchBuf, cbToWrite, &cbWritten);
    409397#ifdef DEBUG
    410             VGSvcVerbose(4, "[File %s]: Writing pvScratchBuf=%p, cbToWrite=%RU32, cbWritten=%zu, rc=%Rrc\n",
     398            VGSvcVerbose(4, "[File %s] Writing pvScratchBuf=%p, cbToWrite=%RU32, cbWritten=%zu, rc=%Rrc\n",
    411399                         pFile->szName, pvScratchBuf, cbToWrite, cbWritten, rc);
    412400#endif
     
    423411    }
    424412
    425 #ifdef DEBUG
    426     VGSvcVerbose(4, "Writing file '%s' (handle=%RU32) returned rc=%Rrc\n", pFile ? pFile->szName : "<Not found>", uHandle, rc);
    427 #endif
    428413    return rc;
    429414}
     
    438423    AssertPtrReturn(cbScratchBuf, VERR_INVALID_PARAMETER);
    439424
    440     PVBOXSERVICECTRLFILE pFile = NULL;
    441 
    442425    uint32_t uHandle = 0;
    443426    uint32_t cbToWrite;
     
    448431    {
    449432        size_t cbWritten = 0;
    450         pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle);
     433        PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle);
    451434        if (pFile)
    452435        {
    453436            rc = RTFileWriteAt(pFile->hFile, (RTFOFF)offWriteAt, pvScratchBuf, cbToWrite, &cbWritten);
    454437#ifdef DEBUG
    455             VGSvcVerbose(4, "[File %s]: Writing offWriteAt=%RI64, pvScratchBuf=%p, cbToWrite=%RU32, cbWritten=%zu, rc=%Rrc\n",
     438            VGSvcVerbose(4, "[File %s] Writing offWriteAt=%RI64, pvScratchBuf=%p, cbToWrite=%RU32, cbWritten=%zu, rc=%Rrc\n",
    456439                         pFile->szName, offWriteAt, pvScratchBuf, cbToWrite, cbWritten, rc);
    457440#endif
     
    468451    }
    469452
    470 #ifdef DEBUG
    471     VGSvcVerbose(4, "Writing file '%s' at offset (handle=%RU32) returned rc=%Rrc\n",
    472                  pFile ? pFile->szName : "<Not found>", uHandle, rc);
    473 #endif
    474453    return rc;
    475454}
     
    480459    AssertPtrReturn(pSession, VERR_INVALID_POINTER);
    481460    AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
    482 
    483     PVBOXSERVICECTRLFILE pFile = NULL;
    484461
    485462    uint32_t uHandle = 0;
     
    490467    {
    491468        uint64_t offActual = 0;
    492         pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle);
     469        PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle);
    493470        if (pFile)
    494471        {
     
    534511    }
    535512
    536 #ifdef DEBUG
    537     VGSvcVerbose(4, "Seeking file '%s' (handle=%RU32) returned rc=%Rrc\n", pFile ? pFile->szName : "<Not found>", uHandle, rc);
    538 #endif
    539513    return rc;
    540514}
     
    546520    AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
    547521
    548     PVBOXSERVICECTRLFILE pFile = NULL;
    549 
    550522    uint32_t uHandle = 0;
    551523    int rc = VbglR3GuestCtrlFileGetTell(pHostCtx, &uHandle);
    552524    if (RT_SUCCESS(rc))
    553525    {
    554         uint64_t off = 0;
    555         pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle);
     526        uint64_t uOffCurrent = 0;
     527        PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle);
    556528        if (pFile)
    557529        {
    558             off = RTFileTell(pFile->hFile);
     530            uOffCurrent = RTFileTell(pFile->hFile);
    559531#ifdef DEBUG
    560             VGSvcVerbose(4, "[File %s]: Telling off=%RU64\n", pFile->szName, off);
     532            VGSvcVerbose(4, "[File %s]: Telling uOffCurrent=%RU64\n", pFile->szName, uOffCurrent);
    561533#endif
    562534        }
     
    565537
    566538        /* Report back in any case. */
    567         int rc2 = VbglR3GuestCtrlFileCbTell(pHostCtx, rc, off);
     539        int rc2 = VbglR3GuestCtrlFileCbTell(pHostCtx, rc, uOffCurrent);
    568540        if (RT_FAILURE(rc2))
    569541            VGSvcError("Failed to report file tell status, rc=%Rrc\n", rc2);
     
    572544    }
    573545
    574 #ifdef DEBUG
    575     VGSvcVerbose(4, "Telling file '%s' (handle=%RU32) returned rc=%Rrc\n", pFile ? pFile->szName : "<Not found>", uHandle, rc);
    576 #endif
    577546    return rc;
    578547}
Note: See TracChangeset for help on using the changeset viewer.

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