VirtualBox

Changeset 93895 in vbox for trunk


Ignore:
Timestamp:
Feb 23, 2022 12:48:02 PM (3 years ago)
Author:
vboxsync
Message:

Validation Kit/TxS: Implemented (local) copy file support for TxS. Useful for copying stuff around on guests. bugref:10195

Location:
trunk/src/VBox/ValidationKit
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/ValidationKit/testdriver/txsclient.py

    r93156 r93895  
    10871087    #def "LIST    "
    10881088
     1089    def taskCopyFile(self, sSrcFile, sDstFile, fMode, fFallbackOkay):
     1090        """ Copies a file within the remote from source to destination. """
     1091        # Note: If fMode is set to 0, it's up to the target OS' implementation with
     1092        #       what a file mode the destination file gets created (i.e. via umask).
     1093        rc = self.sendMsg('CPFILE', (fMode, sSrcFile, sDstFile,));
     1094        if rc is True:
     1095            rc = self.recvAckLogged('CPFILE');
     1096        return rc;
     1097
    10891098    def taskUploadFile(self, sLocalFile, sRemoteFile, fMode, fFallbackOkay):
    10901099        #
     
    17151724        return Session.calcFileXferTimeout(cbFile);
    17161725
     1726    def asyncCopyFile(self, sSrcFile, sDstFile,
     1727                      fMode = 0, fFallbackOkay = True, cMsTimeout = 30000, fIgnoreErrors = False):
     1728        """
     1729        Initiates a file copying task on the remote.
     1730
     1731        Returns True on success, False on failure (logged).
     1732
     1733        The task returns True on success, False on failure (logged).
     1734        """
     1735        return self.startTask(cMsTimeout, fIgnoreErrors, "cpfile",
     1736                              self.taskCopyFile, (sSrcFile, sDstFile, fMode, fFallbackOkay));
     1737
    17171738    def asyncUploadFile(self, sLocalFile, sRemoteFile,
    17181739                        fMode = 0, fFallbackOkay = True, cMsTimeout = 30000, fIgnoreErrors = False):
  • trunk/src/VBox/ValidationKit/testdriver/vbox.py

    r93115 r93895  
    36673667                              (sRemoteSymlink, self.adjustTimeoutMs(cMsTimeout), fIgnoreErrors));
    36683668
     3669    def txsCopyFile(self, oSession, oTxsSession, sSrcFile, sDstFile, fMode = 0, cMsTimeout = 30000, fIgnoreErrors = False):
     3670        return self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncCopyFile, \
     3671                              (sSrcFile, sDstFile, fMode, self.adjustTimeoutMs(cMsTimeout), fIgnoreErrors));
     3672
    36693673    def txsUploadFile(self, oSession, oTxsSession, sLocalFile, sRemoteFile, cMsTimeout = 30000, fIgnoreErrors = False):
    36703674        return self.txsDoTask(oSession, oTxsSession, oTxsSession.asyncUploadFile, \
  • trunk/src/VBox/ValidationKit/utils/TestExecServ/TestExecService.cpp

    r93747 r93895  
    660660 * @returns true if valid, false if invalid.
    661661 * @param   pPktHdr             The packet being unpacked.
    662  * @param   pszArgName           The argument name.
     662 * @param   pszArgName          The argument name.
    663663 * @param   psz                 Pointer to the string within pPktHdr.
    664664 * @param   ppszExp             Where to return the expanded string.  Must be
     
    10071007
    10081008    RTStrFree(pszPath);
     1009    return rc;
     1010}
     1011
     1012/**
     1013 * Copies a file from the source to the destination locally.
     1014 *
     1015 * @returns IPRT status code from send.
     1016 * @param   pPktHdr             The copy file packet.
     1017 */
     1018static int txsDoCopyFile(PCTXSPKTHDR pPktHdr)
     1019{
     1020    /* After the packet header follows a 32-bit file mode,
     1021     * the remainder of the packet are two zero terminated paths. */
     1022    size_t const cbMin = sizeof(TXSPKTHDR) + sizeof(RTFMODE) + 2;
     1023    if (pPktHdr->cb < cbMin)
     1024        return txsReplyBadMinSize(pPktHdr, cbMin);
     1025
     1026    RTFMODE const fMode = *(RTFMODE const *)(pPktHdr + 1);
     1027
     1028    int rc;
     1029
     1030    char       *pszSrc;
     1031    const char *pch;
     1032    if (txsIsStringValid(pPktHdr, "source", (const char *)(pPktHdr + 1) + sizeof(uint32_t) * 2, &pszSrc, &pch, &rc))
     1033    {
     1034        char *pszDst;
     1035        if (txsIsStringValid(pPktHdr, "dest", pch, &pszDst, NULL /* Check for string termination */, &rc))
     1036        {
     1037            rc = RTFileCopy(pszSrc, pszDst);
     1038            if (RT_SUCCESS(rc))
     1039            {
     1040                if (fMode) /* Do we need to set the file mode? */
     1041                {
     1042                    rc = RTPathSetMode(pszDst, fMode);
     1043                    if (RT_FAILURE(rc))
     1044                        rc = txsReplyRC(pPktHdr, rc, "RTPathSetMode(\"%s\", %#x)", pszDst, fMode);
     1045                }
     1046
     1047                if (RT_SUCCESS(rc))
     1048                    rc = txsReplyAck(pPktHdr);
     1049            }
     1050            else
     1051                rc = txsReplyRC(pPktHdr, rc, "RTFileCopy");
     1052            RTStrFree(pszDst);
     1053        }
     1054
     1055        RTStrFree(pszSrc);
     1056    }
     1057
    10091058    return rc;
    10101059}
     
    31053154        else if (txsIsSameOpcode(pPktHdr, "LIST    "))
    31063155            rc = txsDoList(pPktHdr);
     3156        else if (txsIsSameOpcode(pPktHdr, "CPFILE  "))
     3157            rc = txsDoCopyFile(pPktHdr);
    31073158        else if (txsIsSameOpcode(pPktHdr, "PUT FILE"))
    31083159            rc = txsDoPutFile(pPktHdr, false /*fHasMode*/);
     
    39734024    return rcExit;
    39744025}
    3975 
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