VirtualBox

Changeset 77853 in vbox for trunk/include


Ignore:
Timestamp:
Mar 22, 2019 8:54:14 PM (6 years ago)
Author:
vboxsync
Message:

linux/vboxsf: Implemented the copy_file_range method and fixed a recently introduced bug in vbsf_reg_write_iter_locking where vbsf_reg_write_sync_page_cache was called with the wrong range length. bugref:9172

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/VBoxGuestLibSharedFoldersInline.h

    r77561 r77853  
    6363extern VBGLSFCLIENT g_SfClient; /**< Move this into the parameters? */
    6464
     65/** Request structure for VbglR0SfHostReqQueryFeatures. */
     66typedef struct VBOXSFQUERYFEATURES
     67{
     68    VBGLIOCIDCHGCMFASTCALL  Hdr;
     69    VMMDevHGCMCall          Call;
     70    VBoxSFParmQueryFeatures Parms;
     71} VBOXSFQUERYFEATURES;
     72
     73/**
     74 * SHFL_FN_QUERY_FEATURES request.
     75 */
     76DECLINLINE(int) VbglR0SfHostReqQueryFeatures(VBOXSFQUERYFEATURES *pReq)
     77{
     78    VBGLIOCIDCHGCMFASTCALL_INIT(&pReq->Hdr, VbglR0PhysHeapGetPhysAddr(pReq), &pReq->Call, g_SfClient.idClient,
     79                                SHFL_FN_QUERY_FEATURES, SHFL_CPARMS_QUERY_FEATURES, sizeof(*pReq));
     80
     81    pReq->Parms.f64Features.type          = VMMDevHGCMParmType_64bit;
     82    pReq->Parms.f64Features.u.value64     = 0;
     83
     84    pReq->Parms.u32LastFunction.type      = VMMDevHGCMParmType_32bit;
     85    pReq->Parms.u32LastFunction.u.value32 = 0;
     86
     87    int vrc = VbglR0HGCMFastCall(g_SfClient.handle, &pReq->Hdr, sizeof(*pReq));
     88    if (RT_SUCCESS(vrc))
     89        vrc = pReq->Call.header.result;
     90
     91    /*
     92     * Provide fallback values based on g_fHostFeatures to simplify
     93     * compatibility with older hosts and avoid duplicating this logic.
     94     */
     95    if (RT_FAILURE(vrc))
     96    {
     97        pReq->Parms.f64Features.u.value64     = 0;
     98        pReq->Parms.u32LastFunction.u.value32 = g_fHostFeatures & VMMDEV_HVF_HGCM_NO_BOUNCE_PAGE_LIST
     99                                              ?  SHFL_FN_SET_FILE_SIZE : SHFL_FN_SET_SYMLINKS;
     100        if (vrc == VERR_NOT_SUPPORTED)
     101            vrc = VINF_NOT_SUPPORTED;
     102    }
     103    return vrc;
     104}
     105
     106
     107/**
     108 * SHFL_FN_QUERY_FEATURES request, simplified version.
     109 */
     110DECLINLINE(int) VbglR0SfHostReqQueryFeaturesSimple(uint64_t *pfFeatures, uint32_t *puLastFunction)
     111{
     112    VBOXSFQUERYFEATURES *pReq = (VBOXSFQUERYFEATURES *)VbglR0PhysHeapAlloc(sizeof(*pReq));
     113    if (pReq)
     114    {
     115        int rc = VbglR0SfHostReqQueryFeatures(pReq);
     116        if (pfFeatures)
     117            *pfFeatures = pReq->Parms.f64Features.u.value64;
     118        if (puLastFunction)
     119            *puLastFunction = pReq->Parms.u32LastFunction.u.value32;
     120
     121        VbglR0PhysHeapFree(pReq);
     122        return rc;
     123    }
     124    return VERR_NO_MEMORY;
     125}
     126
     127
     128
    65129/** Request structure for VbglR0SfHostReqMapFolderWithBuf.  */
    66130typedef struct VBOXSFMAPFOLDERWITHBUFREQ
     
    10291093    return vrc;
    10301094}
     1095
     1096
     1097/** Request structure for VbglR0SfHostReqCopyFilePart.  */
     1098typedef struct VBOXSFCOPYFILEPARTREQ
     1099{
     1100    VBGLIOCIDCHGCMFASTCALL  Hdr;
     1101    VMMDevHGCMCall          Call;
     1102    VBoxSFParmCopyFilePart  Parms;
     1103} VBOXSFCOPYFILEPARTREQ;
     1104
     1105/**
     1106 * SHFL_FN_CREATE request.
     1107 */
     1108DECLINLINE(int) VbglR0SfHostReqCopyFilePart(SHFLROOT idRootSrc, SHFLHANDLE hHostFileSrc, uint64_t offSrc,
     1109                                            SHFLROOT idRootDst, SHFLHANDLE hHostFileDst, uint64_t offDst,
     1110                                            uint64_t cbToCopy, uint32_t fFlags, VBOXSFCOPYFILEPARTREQ *pReq)
     1111{
     1112    VBGLIOCIDCHGCMFASTCALL_INIT(&pReq->Hdr, VbglR0PhysHeapGetPhysAddr(pReq), &pReq->Call, g_SfClient.idClient,
     1113                                SHFL_FN_COPY_FILE_PART, SHFL_CPARMS_COPY_FILE_PART, sizeof(*pReq));
     1114
     1115    pReq->Parms.id32RootSrc.type        = VMMDevHGCMParmType_32bit;
     1116    pReq->Parms.id32RootSrc.u.value32   = idRootSrc;
     1117
     1118    pReq->Parms.u64HandleSrc.type       = VMMDevHGCMParmType_64bit;
     1119    pReq->Parms.u64HandleSrc.u.value64  = hHostFileSrc;
     1120
     1121    pReq->Parms.off64Src.type           = VMMDevHGCMParmType_64bit;
     1122    pReq->Parms.off64Src.u.value64      = offSrc;
     1123
     1124    pReq->Parms.id32RootDst.type        = VMMDevHGCMParmType_32bit;
     1125    pReq->Parms.id32RootDst.u.value32   = idRootDst;
     1126
     1127    pReq->Parms.u64HandleDst.type       = VMMDevHGCMParmType_64bit;
     1128    pReq->Parms.u64HandleDst.u.value64  = hHostFileDst;
     1129
     1130    pReq->Parms.off64Dst.type           = VMMDevHGCMParmType_64bit;
     1131    pReq->Parms.off64Dst.u.value64      = offDst;
     1132
     1133    pReq->Parms.cb64ToCopy.type         = VMMDevHGCMParmType_64bit;
     1134    pReq->Parms.cb64ToCopy.u.value64    = cbToCopy;
     1135
     1136    pReq->Parms.f32Flags.type           = VMMDevHGCMParmType_32bit;
     1137    pReq->Parms.f32Flags.u.value32      = fFlags;
     1138
     1139    int vrc = VbglR0HGCMFastCall(g_SfClient.handle, &pReq->Hdr, sizeof(*pReq));
     1140    if (RT_SUCCESS(vrc))
     1141        vrc = pReq->Call.header.result;
     1142    return vrc;
     1143}
     1144
     1145
    10311146
    10321147/** Request structure for VbglR0SfHostReqListDirContig2x() and
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