VirtualBox

Ignore:
Timestamp:
Jun 22, 2019 12:05:44 AM (6 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
131488
Message:

GuestCtrlSvc,Main,VBoxService: Implemented IGuestFile::SetSize. bugref:9320

File:
1 edited

Legend:

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

    r79261 r79287  
    316316                uint64_t fFlags;
    317317                rc = RTFileModeToFlagsEx(szAccess, szDisposition, NULL /* pszSharing, not used yet */, &fFlags);
    318                 VGSvcVerbose(4, "[File %s] Opening with fFlags=0x%x, rc=%Rrc\n", pFile->szName, fFlags, rc);
     318                VGSvcVerbose(4, "[File %s] Opening with fFlags=%#RX64 -> rc=%Rrc\n", pFile->szName, fFlags, rc);
    319319                if (RT_SUCCESS(rc))
    320320                {
     321                    fFlags |= (uCreationMode << RTFILE_O_CREATE_MODE_SHIFT) & RTFILE_O_CREATE_MODE_MASK;
    321322                    rc = RTFileOpen(&pFile->hFile, pFile->szName, fFlags);
    322323                    if (RT_SUCCESS(rc))
     
    766767
    767768
     769static int vgsvcGstCtrlSessionHandleFileSetSize(const PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx)
     770{
     771    AssertPtrReturn(pSession, VERR_INVALID_POINTER);
     772    AssertPtrReturn(pHostCtx, VERR_INVALID_POINTER);
     773
     774    /*
     775     * Retrieve the request.
     776     */
     777    uint32_t uHandle = 0;
     778    uint64_t cbNew = 0;
     779    int rc = VbglR3GuestCtrlFileGetSetSize(pHostCtx, &uHandle, &cbNew);
     780    if (RT_SUCCESS(rc))
     781    {
     782        /*
     783         * Locate the file and ask for the current position.
     784         */
     785        PVBOXSERVICECTRLFILE pFile = vgsvcGstCtrlSessionFileGetLocked(pSession, uHandle);
     786        if (pFile)
     787        {
     788            rc = RTFileSetSize(pFile->hFile, cbNew);
     789            VGSvcVerbose(5, "[File %s]: Changing size to %RU64 (%#RX64), rc=%Rrc\n", pFile->szName, cbNew, cbNew, rc);
     790        }
     791        else
     792        {
     793            VGSvcError("File %u (%#x) not found!\n", uHandle, uHandle);
     794            cbNew = UINT64_MAX;
     795            rc = VERR_NOT_FOUND;
     796        }
     797
     798        /*
     799         * Report result back to host.
     800         */
     801        int rc2 = VbglR3GuestCtrlFileCbSetSize(pHostCtx, rc, cbNew);
     802        if (RT_FAILURE(rc2))
     803        {
     804            VGSvcError("Failed to report file tell status, rc=%Rrc\n", rc2);
     805            if (RT_SUCCESS(rc))
     806                rc = rc2;
     807        }
     808    }
     809    else
     810    {
     811        VGSvcError("Error fetching parameters for file tell operation: %Rrc\n", rc);
     812        VbglR3GuestCtrlMsgSkip(pHostCtx->uClientID, rc, UINT32_MAX);
     813    }
     814    return rc;
     815}
     816
     817
    768818static int vgsvcGstCtrlSessionHandlePathRename(PVBOXSERVICECTRLSESSION pSession, PVBGLR3GUESTCTRLCMDCTX pHostCtx)
    769819{
     
    12871337            if (fImpersonated)
    12881338                rc = vgsvcGstCtrlSessionHandleFileTell(pSession, pHostCtx);
     1339            break;
     1340
     1341        case HOST_MSG_FILE_SET_SIZE:
     1342            if (fImpersonated)
     1343                rc = vgsvcGstCtrlSessionHandleFileSetSize(pSession, pHostCtx);
    12891344            break;
    12901345
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