VirtualBox

Changeset 77848 in vbox for trunk/src/VBox


Ignore:
Timestamp:
Mar 22, 2019 1:24:24 PM (6 years ago)
Author:
vboxsync
Message:

SharedFoldersSvc: Added a function exposing RTFileCopy as well. bugref:9172

Location:
trunk/src/VBox/HostServices/SharedFolders
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostServices/SharedFolders/VBoxSharedFoldersSvc.cpp

    r77837 r77848  
    9898static STAMPROFILE g_StatQueryMapInfo;
    9999static STAMPROFILE g_StatQueryFeatures;
     100static STAMPROFILE g_StatCopyFile;
     101static STAMPROFILE g_StatCopyFileFail;
    100102static STAMPROFILE g_StatCopyFilePart;
    101103static STAMPROFILE g_StatCopyFilePartFail;
     
    15041506        }
    15051507
     1508        case SHFL_FN_COPY_FILE:
     1509        {
     1510            pStat     = &g_StatCopyFile;
     1511            pStatFail = &g_StatCopyFileFail;
     1512
     1513            /* Validate input: */
     1514            ASSERT_GUEST_STMT_BREAK(cParms == SHFL_CPARMS_COPY_FILE, rc = VERR_WRONG_PARAMETER_COUNT);
     1515            ASSERT_GUEST_STMT_BREAK(paParms[0].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* i32RootSrc  */
     1516            ASSERT_GUEST_STMT_BREAK(paParms[1].type == VBOX_HGCM_SVC_PARM_PTR, rc = VERR_WRONG_PARAMETER_TYPE);   /* pStrPathSrc */
     1517            PCSHFLSTRING pStrPathSrc = (PCSHFLSTRING)paParms[1].u.pointer.addr;
     1518            ASSERT_GUEST_STMT_BREAK(ShflStringIsValidIn(pStrPathSrc, paParms[1].u.pointer.size,
     1519                                                        RT_BOOL(pClient->fu32Flags & SHFL_CF_UTF8)),
     1520                                    rc = VERR_INVALID_PARAMETER);
     1521            ASSERT_GUEST_STMT_BREAK(paParms[2].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* i32RootDst  */
     1522            ASSERT_GUEST_STMT_BREAK(paParms[3].type == VBOX_HGCM_SVC_PARM_PTR, rc = VERR_WRONG_PARAMETER_TYPE);   /* pStrPathDst */
     1523            PCSHFLSTRING pStrPathDst = (PCSHFLSTRING)paParms[3].u.pointer.addr;
     1524            ASSERT_GUEST_STMT_BREAK(ShflStringIsValidIn(pStrPathDst, paParms[3].u.pointer.size,
     1525                                                        RT_BOOL(pClient->fu32Flags & SHFL_CF_UTF8)),
     1526                                    rc = VERR_INVALID_PARAMETER);
     1527            ASSERT_GUEST_STMT_BREAK(paParms[4].type == VBOX_HGCM_SVC_PARM_32BIT, rc = VERR_WRONG_PARAMETER_TYPE); /* f32Flags */
     1528            ASSERT_GUEST_STMT_BREAK(paParms[4].u.uint32 == 0, rc = VERR_INVALID_FLAGS);
     1529
     1530            /* Execute the function: */
     1531            rc = vbsfCopyFile(pClient, paParms[0].u.uint32, pStrPathSrc, paParms[2].u.uint64, pStrPathDst, paParms[3].u.uint32);
     1532            break;
     1533        }
     1534
     1535
    15061536        case SHFL_FN_COPY_FILE_PART:
    15071537        {
     
    15311561            break;
    15321562        }
    1533 
    15341563
    15351564        default:
     
    18411870             HGCMSvcHlpStamRegister(g_pHelpers, &g_StatQueryMapInfo,              STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_QUERY_MAP_INFO",                    "/HGCM/VBoxSharedFolders/FnQueryMapInfo");
    18421871             HGCMSvcHlpStamRegister(g_pHelpers, &g_StatQueryFeatures,             STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_QUERY_FEATURES",                    "/HGCM/VBoxSharedFolders/FnQueryFeatures");
     1872             HGCMSvcHlpStamRegister(g_pHelpers, &g_StatCopyFile,                  STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_COPY_FILE successes",               "/HGCM/VBoxSharedFolders/FnCopyFile");
     1873             HGCMSvcHlpStamRegister(g_pHelpers, &g_StatCopyFileFail,              STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_COPY_FILE failures",                "/HGCM/VBoxSharedFolders/FnCopyFileFail");
    18431874             HGCMSvcHlpStamRegister(g_pHelpers, &g_StatCopyFilePart,              STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_COPY_FILE_PART successes",          "/HGCM/VBoxSharedFolders/FnCopyFilePart");
    18441875             HGCMSvcHlpStamRegister(g_pHelpers, &g_StatCopyFilePartFail,          STAMTYPE_PROFILE, STAMVISIBILITY_ALWAYS, STAMUNIT_CALLS, "SHFL_FN_COPY_FILE_PART failures",           "/HGCM/VBoxSharedFolders/FnCopyFilePartFail");
  • trunk/src/VBox/HostServices/SharedFolders/vbsf.cpp

    r77838 r77848  
    121121}
    122122
    123 static int vbsfBuildFullPath(SHFLCLIENTDATA *pClient, SHFLROOT root, PSHFLSTRING pPath,
     123static int vbsfBuildFullPath(SHFLCLIENTDATA *pClient, SHFLROOT root, PCSHFLSTRING pPath,
    124124                             uint32_t cbPath, char **ppszFullPath, uint32_t *pcbFullPathRoot,
    125125                             bool fWildCard = false, bool fPreserveLastComponent = false)
     
    13681368}
    13691369
    1370 /** Implements SHFL_FN_COPY_FILE_PART (wrapping RTFileCopyPart).   */
     1370/**
     1371 * Implements SHFL_FN_COPY_FILE_PART (wrapping RTFileCopyPart).
     1372 */
    13711373int vbsfCopyFilePart(SHFLCLIENTDATA *pClient, SHFLROOT idRootSrc, SHFLHANDLE hFileSrc, uint64_t offSrc,
    13721374                     SHFLROOT idRootDst, SHFLHANDLE hFileDst, uint64_t offDst, uint64_t *pcbToCopy, uint32_t fFlags)
     
    13921394        if (RT_SUCCESS(rc))
    13931395        {
     1396            /*
     1397             * Do the job.
     1398             */
    13941399            rc = RTFileCopyPart(pHandleSrc->file.Handle, offSrc, pHandleDst->file.Handle, offDst, cbToCopy, 0, &cbTotal);
    13951400            *pcbToCopy = cbTotal;
     
    22922297}
    22932298
     2299/**
     2300 * Implements SHFL_FN_COPY_FILE (wrapping RTFileCopy).
     2301 */
     2302int vbsfCopyFile(SHFLCLIENTDATA *pClient, SHFLROOT idRootSrc, PCSHFLSTRING pStrPathSrc,
     2303                 SHFLROOT idRootDst, PCSHFLSTRING pStrPathDst, uint32_t fFlags)
     2304{
     2305    AssertPtrReturn(pClient, VERR_INVALID_PARAMETER);
     2306    if (pClient->fu32Flags & SHFL_CF_UTF8)
     2307        LogFunc(("pClient %p, idRootSrc %#RX32, '%.*s', idRootSrc %#RX32, '%.*s', fFlags %#x\n", pClient, idRootSrc,
     2308                 pStrPathSrc->u16Length, pStrPathSrc->String.ach, idRootDst, pStrPathDst->u16Length, pStrPathDst->String.ach, fFlags));
     2309    else
     2310        LogFunc(("pClient %p, idRootSrc %#RX32, '%.*ls', idRootSrc %#RX32, '%.*ls', fFlags %#x\n", pClient,
     2311                 idRootSrc, pStrPathSrc->u16Length / sizeof(RTUTF16), pStrPathSrc->String.ach,
     2312                 idRootDst, pStrPathDst->u16Length / sizeof(RTUTF16), pStrPathDst->String.ach, fFlags));
     2313
     2314    /*
     2315     * Build host paths.
     2316     */
     2317    char *pszPathSrc = NULL;
     2318    int rc = vbsfBuildFullPath(pClient, idRootSrc, pStrPathSrc, pStrPathSrc->u16Size + SHFLSTRING_HEADER_SIZE, &pszPathSrc, NULL);
     2319    if (RT_SUCCESS(rc))
     2320    {
     2321        char *pszPathDst = NULL;
     2322        rc = vbsfBuildFullPath(pClient, idRootDst, pStrPathDst, pStrPathDst->u16Size + SHFLSTRING_HEADER_SIZE, &pszPathDst, NULL);
     2323        if (RT_SUCCESS(rc))
     2324        {
     2325            /*
     2326             * Do the job.
     2327             */
     2328            rc = RTFileCopy(pszPathSrc, pszPathDst);
     2329
     2330            vbsfFreeFullPath(pszPathDst);
     2331        }
     2332        vbsfFreeFullPath(pszPathSrc);
     2333    }
     2334
     2335    RT_NOREF(fFlags);
     2336    LogFunc(("returns %Rrc\n", rc));
     2337    return rc;
     2338}
     2339
    22942340#ifdef UNITTEST
    22952341/** Unit test the SHFL_FN_SYMLINK API.  Located here as a form of API
  • trunk/src/VBox/HostServices/SharedFolders/vbsf.h

    r77837 r77848  
    4242int vbsfRemove(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLSTRING *pPath, uint32_t cbPath, uint32_t flags);
    4343int vbsfRename(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLSTRING *pSrc, SHFLSTRING *pDest, uint32_t flags);
     44int vbsfCopyFile(SHFLCLIENTDATA *pClient, SHFLROOT idRootSrc, PCSHFLSTRING pStrPathSrc,
     45                 SHFLROOT idRootDst, PCSHFLSTRING pStrPathDst, uint32_t fFlags);
    4446int vbsfDirList(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLHANDLE Handle, SHFLSTRING *pPath, uint32_t flags, uint32_t *pcbBuffer, uint8_t *pBuffer, uint32_t *pIndex, uint32_t *pcFiles);
    4547int vbsfFileInfo(SHFLCLIENTDATA *pClient, SHFLROOT root, SHFLHANDLE Handle, uint32_t flags, uint32_t *pcbBuffer, uint8_t *pBuffer);
  • trunk/src/VBox/HostServices/SharedFolders/vbsfpath.cpp

    r76553 r77848  
    429429
    430430int vbsfPathGuestToHost(SHFLCLIENTDATA *pClient, SHFLROOT hRoot,
    431                         PSHFLSTRING pGuestString, uint32_t cbGuestString,
     431                        PCSHFLSTRING pGuestString, uint32_t cbGuestString,
    432432                        char **ppszHostPath, uint32_t *pcbHostPathRoot,
    433433                        uint32_t fu32Options,
     
    472472        /* UTF-8 */
    473473        cbGuestPath = pGuestString->u16Length;
    474         pchGuestPath = (char *)&pGuestString->String.utf8[0];
     474        pchGuestPath = pGuestString->String.ach;
    475475    }
    476476    else
    477477    {
    478478        /* UTF-16 */
    479         uint32_t cwcSrc;
    480         PRTUTF16 pwszSrc;
    481479
    482480#ifdef RT_OS_DARWIN /* Misplaced hack! See todo! */
    483         cwcSrc = 0;
    484         pwszSrc = NULL;
     481        uint32_t cwcSrc = 0;
     482        PRTUTF16 pwszSrc = NULL;
    485483        rc = vbsfNormalizeStringDarwin(&pGuestString->String.ucs2[0],
    486484                                       pGuestString->u16Length / sizeof(RTUTF16),
    487485                                       &pwszSrc, &cwcSrc);
    488486#else
    489         cwcSrc  = pGuestString->u16Length / sizeof(RTUTF16);
    490         pwszSrc = &pGuestString->String.ucs2[0];
     487        uint32_t  const cwcSrc  = pGuestString->u16Length / sizeof(RTUTF16);
     488        PCRTUTF16 const pwszSrc = &pGuestString->String.ucs2[0];
    491489#endif
    492490
  • trunk/src/VBox/HostServices/SharedFolders/vbsfpath.h

    r76570 r77848  
    4444 */
    4545int vbsfPathGuestToHost(SHFLCLIENTDATA *pClient, SHFLROOT hRoot,
    46                         PSHFLSTRING pGuestString, uint32_t cbGuestString,
     46                        PCSHFLSTRING pGuestString, uint32_t cbGuestString,
    4747                        char **ppszHostPath, uint32_t *pcbHostPathRoot,
    4848                        uint32_t fu32Options, uint32_t *pfu32PathFlags);
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