VirtualBox

Ignore:
Timestamp:
May 17, 2019 2:11:07 PM (6 years ago)
Author:
vboxsync
Message:

winnt/vboxsf: Converted vbsfNtSetEndOfFile to use new HGCM IDC interface. bugref:9172

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/SharedFolders/driver/info.cpp

    r78564 r78569  
    18821882 * Worker for VBoxMRxSetFileInfo.
    18831883 */
    1884 static NTSTATUS vbsfNtSetEndOfFile(IN OUT struct _RX_CONTEXT * RxContext, IN uint64_t cbNewFileSize)
     1884static NTSTATUS vbsfNtSetEndOfFile(PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension, PFILE_OBJECT pFileObj,
     1885                                   PMRX_VBOX_FOBX pVBoxFobX, PMRX_FCB pFcb, PVBSFNTFCBEXT pVBoxFcbX, uint64_t cbNewFileSize)
    18851886{
    1886     NTSTATUS Status = STATUS_SUCCESS;
    1887 
    1888     RxCaptureFcb;
    1889     RxCaptureFobx;
    1890 
    1891     PMRX_VBOX_NETROOT_EXTENSION pNetRootExtension = VBoxMRxGetNetRootExtension(capFcb->pNetRoot);
    1892     PVBSFNTFCBEXT pVBoxFcbx = VBoxMRxGetFcbExtension(capFcb);
    1893     PMRX_VBOX_FOBX pVBoxFobx = VBoxMRxGetFileObjectExtension(capFobx);
    1894 
    1895     PSHFLFSOBJINFO pObjInfo;
    1896     uint32_t cbBuffer;
    1897     int vrc;
    1898 
    1899     Log(("VBOXSF: vbsfNtSetEndOfFile: New size = %RX64\n",
    1900          cbNewFileSize));
    1901 
    1902     Assert(pVBoxFobx && pNetRootExtension);
    1903 
    1904     cbBuffer = sizeof(SHFLFSOBJINFO);
    1905     pObjInfo = (SHFLFSOBJINFO *)vbsfNtAllocNonPagedMem(cbBuffer);
    1906     if (!pObjInfo)
    1907     {
    1908         AssertFailed();
    1909         return STATUS_INSUFFICIENT_RESOURCES;
    1910     }
    1911 
    1912     RtlZeroMemory(pObjInfo, cbBuffer);
    1913     pObjInfo->cbObject = cbNewFileSize;
    1914 
    1915     vrc = VbglR0SfFsInfo(&g_SfClient, &pNetRootExtension->map, pVBoxFobx->hFile,
    1916                          SHFL_INFO_SET | SHFL_INFO_SIZE, &cbBuffer, (PSHFLDIRINFO)pObjInfo);
    1917 
    1918     Log(("VBOXSF: vbsfNtSetEndOfFile: VbglR0SfFsInfo returned %Rrc\n", vrc));
    1919 
    1920     Status = vbsfNtVBoxStatusToNt(vrc);
    1921     if (Status == STATUS_SUCCESS)
    1922     {
    1923         pVBoxFobx->fTimestampsImplicitlyUpdated |= VBOX_FOBX_F_INFO_LASTWRITE_TIME;
    1924         if (pVBoxFcbx->pFobxLastWriteTime != pVBoxFobx)
    1925             pVBoxFcbx->pFobxLastWriteTime = NULL;
    1926 
    1927         Log(("VBOXSF: vbsfNtSetEndOfFile: VbglR0SfFsInfo new allocation size = %RX64\n",
    1928              pObjInfo->cbAllocated));
    1929 
    1930         /** @todo update the file stats! */
    1931     }
    1932 
    1933     if (pObjInfo)
    1934         vbsfNtFreeNonPagedMem(pObjInfo);
    1935 
    1936     Log(("VBOXSF: vbsfNtSetEndOfFile: Returned 0x%08X\n", Status));
     1887    Log(("VBOXSF: vbsfNtSetEndOfFile: New size = %RX64\n", cbNewFileSize));
     1888
     1889    /*
     1890     * Allocate a request buffer and call the host with the new file size.
     1891     */
     1892    NTSTATUS          Status;
     1893    VBOXSFOBJINFOREQ *pReq = (VBOXSFOBJINFOREQ *)VbglR0PhysHeapAlloc(sizeof(*pReq));
     1894    if (pReq)
     1895    {
     1896        RT_ZERO(pReq->ObjInfo);
     1897        pReq->ObjInfo.cbObject = cbNewFileSize;
     1898        int vrc = VbglR0SfHostReqSetFileSizeOld(pNetRootExtension->map.root, pReq, pVBoxFobX->hFile);
     1899        if (RT_SUCCESS(vrc))
     1900        {
     1901            /*
     1902             * Update related data.
     1903             */
     1904            pVBoxFobX->fTimestampsImplicitlyUpdated |= VBOX_FOBX_F_INFO_LASTWRITE_TIME;
     1905            if (pVBoxFcbX->pFobxLastWriteTime != pVBoxFobX)
     1906                pVBoxFcbX->pFobxLastWriteTime = NULL;
     1907            vbsfNtCopyInfo(pVBoxFobX, &pReq->ObjInfo, pVBoxFcbX, 0, pFileObj, pFcb);
     1908            Log(("VBOXSF: vbsfNtSetEndOfFile: VbglR0SfHostReqSetFileSizeOld returns new allocation size = %RX64\n",
     1909                 pReq->ObjInfo.cbAllocated));
     1910            Status = STATUS_SUCCESS;
     1911        }
     1912        else
     1913        {
     1914            Log(("VBOXSF: vbsfNtSetEndOfFile: VbglR0SfHostReqSetFileSizeOld(%#RX64,%#RX64) failed %Rrc\n",
     1915                 pVBoxFobX->hFile, cbNewFileSize, vrc));
     1916            Status = vbsfNtVBoxStatusToNt(vrc);
     1917        }
     1918        VbglR0PhysHeapFree(pReq);
     1919    }
     1920    else
     1921        Status = STATUS_INSUFFICIENT_RESOURCES;
     1922    Log(("VBOXSF: vbsfNtSetEndOfFile: Returns %#010x\n", Status));
    19371923    return Status;
    19381924}
     
    22172203                /** @todo get up to date EOF from host?  We may risk accidentally growing the
    22182204                 *        file here if the host (or someone else) truncated it. */
    2219                 Status = vbsfNtSetEndOfFile(RxContext, pInfo->AllocationSize.QuadPart);
     2205                Status = vbsfNtSetEndOfFile(pNetRootExtension, RxContext->pFobx->AssociatedFileObject, pVBoxFobx,
     2206                                            capFcb, VBoxMRxGetFcbExtension(capFcb), pInfo->AllocationSize.QuadPart);
    22202207            }
    22212208            break;
     
    22452232                 pInfo->EndOfFile.QuadPart, capFcb->Header.FileSize.QuadPart));
    22462233
    2247             Status = vbsfNtSetEndOfFile(RxContext, pInfo->EndOfFile.QuadPart);
     2234            Status = vbsfNtSetEndOfFile(pNetRootExtension, RxContext->pFobx->AssociatedFileObject, pVBoxFobx,
     2235                                        capFcb, VBoxMRxGetFcbExtension(capFcb), pInfo->EndOfFile.QuadPart);
    22482236
    22492237            Log(("VBOXSF: MrxSetFileInfo: FileEndOfFileInformation: Status 0x%08X\n",
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