GuestSessionImpl.cpp revision df3d97ef4590e6a4ca98e649e2a78bea3a9d28bb
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/* $Id$ */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/** @file
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * VirtualBox Main - XXX.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/*
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * Copyright (C) 2012 Oracle Corporation
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync *
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * available from http://www.virtualbox.org. This file is free software;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * you can redistribute it and/or modify it under the terms of the GNU
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * General Public License (GPL) as published by the Free Software
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/*******************************************************************************
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync* Header Files *
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync*******************************************************************************/
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync#include "GuestImpl.h"
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#include "GuestSessionImpl.h"
7b9f0c34e9ea328981c99e97054bdf8684d9d620vboxsync#include "GuestCtrlImplPrivate.h"
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#include "Global.h"
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#include "AutoCaller.h"
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync#include "ProgressImpl.h"
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
b1cc3e87518139898395f96974ecff9e6bf228fbvboxsync#include <memory> /* For auto_ptr. */
b1cc3e87518139898395f96974ecff9e6bf228fbvboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync#include <iprt/env.h>
388b6b190a5407548753b7fde12fa58134ec3563vboxsync#include <iprt/file.h> /* For CopyTo/From. */
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#include <VBox/com/array.h>
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync#include <VBox/version.h>
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync// constructor / destructor
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/////////////////////////////////////////////////////////////////////////////
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncDEFINE_EMPTY_CTOR_DTOR(GuestSession)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncHRESULT GuestSession::FinalConstruct(void)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync LogFlowThisFunc(("\n"));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync return BaseFinalConstruct();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncvoid GuestSession::FinalRelease(void)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync LogFlowThisFuncEnter();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync uninit();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync BaseFinalRelease();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync LogFlowThisFuncLeave();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync// session task classes
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync/////////////////////////////////////////////////////////////////////////////
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsyncGuestSessionTask::GuestSessionTask(GuestSession *pSession)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync mSession = pSession;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncGuestSessionTask::~GuestSessionTask(void)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsyncint GuestSessionTask::setProgress(ULONG uPercent)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if (mProgress.isNull()) /* Progress is optional. */
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync return VINF_SUCCESS;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync BOOL fCanceled;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync && fCanceled)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return VERR_CANCELLED;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync BOOL fCompleted;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if ( SUCCEEDED(mProgress->COMGETTER(Completed(&fCompleted)))
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync && !fCompleted)
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync return VINF_SUCCESS;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync HRESULT hr = mProgress->SetCurrentOperationProgress(uPercent);
386a7cc6c736c97bb8839df94eef779de7fbfdc1vboxsync if (FAILED(hr))
386a7cc6c736c97bb8839df94eef779de7fbfdc1vboxsync return VERR_COM_UNEXPECTED;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return VINF_SUCCESS;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncint GuestSessionTask::setProgressSuccess(void)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if (mProgress.isNull()) /* Progress is optional. */
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync return VINF_SUCCESS;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync BOOL fCanceled;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync BOOL fCompleted;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync && !fCanceled
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync && SUCCEEDED(mProgress->COMGETTER(Completed(&fCompleted)))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync && !fCompleted)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync {
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync HRESULT hr = mProgress->notifyComplete(S_OK);
b1cc3e87518139898395f96974ecff9e6bf228fbvboxsync if (FAILED(hr))
b1cc3e87518139898395f96974ecff9e6bf228fbvboxsync return VERR_COM_UNEXPECTED; /** @todo Find a better rc. */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync }
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return VINF_SUCCESS;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncint GuestSessionTask::setProgressErrorMsg(HRESULT hr, const Utf8Str &strMsg)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if (mProgress.isNull()) /* Progress is optional. */
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync return VINF_SUCCESS;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync BOOL fCanceled;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync BOOL fCompleted;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync && !fCanceled
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync && SUCCEEDED(mProgress->COMGETTER(Completed(&fCompleted)))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync && !fCompleted)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync {
b1cc3e87518139898395f96974ecff9e6bf228fbvboxsync HRESULT hr2 = mProgress->notifyComplete(hr,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync COM_IIDOF(IGuestSession),
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync GuestSession::getStaticComponentName(),
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync strMsg.c_str());
b1cc3e87518139898395f96974ecff9e6bf228fbvboxsync if (FAILED(hr2))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return VERR_COM_UNEXPECTED;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync }
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return VINF_SUCCESS;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsyncSessionTaskCopyTo::SessionTaskCopyTo(GuestSession *pSession,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags)
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync : GuestSessionTask(pSession)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync mSource = strSource;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync mDest = strDest;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync mCopyFileFlags = uFlags;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncSessionTaskCopyTo::~SessionTaskCopyTo(void)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncint SessionTaskCopyTo::Run(void)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
388b6b190a5407548753b7fde12fa58134ec3563vboxsync LogFlowThisFuncEnter();
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
388b6b190a5407548753b7fde12fa58134ec3563vboxsync ComObjPtr<GuestSession> pSession = mSession;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync Assert(!pSession.isNull());
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
388b6b190a5407548753b7fde12fa58134ec3563vboxsync AutoCaller autoCaller(pSession);
388b6b190a5407548753b7fde12fa58134ec3563vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if (mCopyFileFlags)
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync return setProgressErrorMsg(VBOX_E_IPRT_ERROR,
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync Utf8StrFmt(GuestSession::tr("Copy flags (%#x) not implemented yet"),
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync mCopyFileFlags));
388b6b190a5407548753b7fde12fa58134ec3563vboxsync int rc;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /** @todo Make use of exceptions (+ finally block) here! */
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
388b6b190a5407548753b7fde12fa58134ec3563vboxsync try
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
388b6b190a5407548753b7fde12fa58134ec3563vboxsync /* Does our source file exist? */
388b6b190a5407548753b7fde12fa58134ec3563vboxsync if (!RTFileExists(mSource.c_str()))
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
388b6b190a5407548753b7fde12fa58134ec3563vboxsync rc = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
388b6b190a5407548753b7fde12fa58134ec3563vboxsync Utf8StrFmt(GuestSession::tr("Source file \"%s\" does not exist or is not a file"),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync mSource.c_str()));
388b6b190a5407548753b7fde12fa58134ec3563vboxsync }
388b6b190a5407548753b7fde12fa58134ec3563vboxsync else
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
388b6b190a5407548753b7fde12fa58134ec3563vboxsync RTFILE fileSource;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync rc = RTFileOpen(&fileSource, mSource.c_str(),
388b6b190a5407548753b7fde12fa58134ec3563vboxsync RTFILE_O_OPEN | RTFILE_O_READ | RTFILE_O_DENY_WRITE);
388b6b190a5407548753b7fde12fa58134ec3563vboxsync if (RT_FAILURE(rc))
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
388b6b190a5407548753b7fde12fa58134ec3563vboxsync rc = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
388b6b190a5407548753b7fde12fa58134ec3563vboxsync Utf8StrFmt(GuestSession::tr("Could not open source file \"%s\" for reading (%Rrc)"),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync mSource.c_str(), rc));
388b6b190a5407548753b7fde12fa58134ec3563vboxsync }
388b6b190a5407548753b7fde12fa58134ec3563vboxsync else
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
388b6b190a5407548753b7fde12fa58134ec3563vboxsync uint64_t cbFileSize;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync rc = RTFileGetSize(fileSource, &cbFileSize);
388b6b190a5407548753b7fde12fa58134ec3563vboxsync if (RT_FAILURE(rc))
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
388b6b190a5407548753b7fde12fa58134ec3563vboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
5366e994777f9d9391cf809dc77610f57270d75dvboxsync Utf8StrFmt(GuestSession::tr("Could not query file size of \"%s\": %Rrc"),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync mSource.c_str(), rc));
388b6b190a5407548753b7fde12fa58134ec3563vboxsync }
388b6b190a5407548753b7fde12fa58134ec3563vboxsync else
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync GuestProcessStartupInfo procInfo;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync procInfo.mName = Utf8StrFmt(GuestSession::tr("Copying file \"%s\" to the guest to \"%s\" (%RU64 bytes)"),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync mSource.c_str(), mDest.c_str(), cbFileSize);
388b6b190a5407548753b7fde12fa58134ec3563vboxsync procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_CAT);
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync procInfo.mFlags = ProcessCreateFlag_Hidden;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
388b6b190a5407548753b7fde12fa58134ec3563vboxsync /* Set arguments.*/
388b6b190a5407548753b7fde12fa58134ec3563vboxsync procInfo.mArguments.push_back(Utf8StrFmt("--output=%s", mDest.c_str())); /** @todo Do we need path conversion? */
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
388b6b190a5407548753b7fde12fa58134ec3563vboxsync /* Startup process. */
388b6b190a5407548753b7fde12fa58134ec3563vboxsync ComObjPtr<GuestProcess> pProcess;
386a7cc6c736c97bb8839df94eef779de7fbfdc1vboxsync rc = pSession->processCreateExInteral(procInfo, pProcess);
388b6b190a5407548753b7fde12fa58134ec3563vboxsync if (RT_SUCCESS(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync rc = pProcess->startProcess();
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_FAILURE(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
5366e994777f9d9391cf809dc77610f57270d75dvboxsync Utf8StrFmt(GuestSession::tr("Unable to start guest process: %Rrc"), rc));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync else
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
388b6b190a5407548753b7fde12fa58134ec3563vboxsync GuestProcessWaitResult waitRes;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync BYTE byBuf[_64K];
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
388b6b190a5407548753b7fde12fa58134ec3563vboxsync BOOL fCanceled = FALSE;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync uint64_t cbWrittenTotal = 0;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync uint64_t cbToRead = cbFileSize;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
388b6b190a5407548753b7fde12fa58134ec3563vboxsync for (;;)
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
388b6b190a5407548753b7fde12fa58134ec3563vboxsync rc = pProcess->waitFor(ProcessWaitForFlag_StdIn,
388b6b190a5407548753b7fde12fa58134ec3563vboxsync 30 * 1000 /* Timeout */, waitRes);
388b6b190a5407548753b7fde12fa58134ec3563vboxsync if ( RT_FAILURE(rc)
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync || waitRes.mResult == ProcessWaitResult_Terminate
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync || waitRes.mResult == ProcessWaitResult_Error
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync || waitRes.mResult == ProcessWaitResult_Timeout)
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
388b6b190a5407548753b7fde12fa58134ec3563vboxsync break;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync }
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
388b6b190a5407548753b7fde12fa58134ec3563vboxsync size_t cbRead = 0;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync if (cbFileSize) /* If we have nothing to write, take a shortcut. */
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
388b6b190a5407548753b7fde12fa58134ec3563vboxsync /** @todo Not very efficient, but works for now. */
388b6b190a5407548753b7fde12fa58134ec3563vboxsync rc = RTFileSeek(fileSource, cbWrittenTotal,
388b6b190a5407548753b7fde12fa58134ec3563vboxsync RTFILE_SEEK_BEGIN, NULL /* poffActual */);
388b6b190a5407548753b7fde12fa58134ec3563vboxsync if (RT_SUCCESS(rc))
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
388b6b190a5407548753b7fde12fa58134ec3563vboxsync rc = RTFileRead(fileSource, (uint8_t*)byBuf,
388b6b190a5407548753b7fde12fa58134ec3563vboxsync RT_MIN(cbToRead, sizeof(byBuf)), &cbRead);
388b6b190a5407548753b7fde12fa58134ec3563vboxsync /*
388b6b190a5407548753b7fde12fa58134ec3563vboxsync * Some other error occured? There might be a chance that RTFileRead
388b6b190a5407548753b7fde12fa58134ec3563vboxsync * could not resolve/map the native error code to an IPRT code, so just
388b6b190a5407548753b7fde12fa58134ec3563vboxsync * print a generic error.
388b6b190a5407548753b7fde12fa58134ec3563vboxsync */
388b6b190a5407548753b7fde12fa58134ec3563vboxsync if (RT_FAILURE(rc))
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
388b6b190a5407548753b7fde12fa58134ec3563vboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
388b6b190a5407548753b7fde12fa58134ec3563vboxsync Utf8StrFmt(GuestSession::tr("Could not read from file \"%s\" (%Rrc)"),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync mSource.c_str(), rc));
388b6b190a5407548753b7fde12fa58134ec3563vboxsync break;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync }
388b6b190a5407548753b7fde12fa58134ec3563vboxsync }
388b6b190a5407548753b7fde12fa58134ec3563vboxsync else
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
388b6b190a5407548753b7fde12fa58134ec3563vboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
388b6b190a5407548753b7fde12fa58134ec3563vboxsync Utf8StrFmt(GuestSession::tr("Seeking file \"%s\" offset %RU64 failed: %Rrc"),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync mSource.c_str(), cbWrittenTotal, rc));
388b6b190a5407548753b7fde12fa58134ec3563vboxsync break;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync }
388b6b190a5407548753b7fde12fa58134ec3563vboxsync }
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
388b6b190a5407548753b7fde12fa58134ec3563vboxsync uint32_t fFlags = ProcessInputFlag_None;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
388b6b190a5407548753b7fde12fa58134ec3563vboxsync /* Did we reach the end of the content we want to transfer (last chunk)? */
388b6b190a5407548753b7fde12fa58134ec3563vboxsync if ( (cbRead < sizeof(byBuf))
388b6b190a5407548753b7fde12fa58134ec3563vboxsync /* Did we reach the last block which is exactly _64K? */
388b6b190a5407548753b7fde12fa58134ec3563vboxsync || (cbToRead - cbRead == 0)
388b6b190a5407548753b7fde12fa58134ec3563vboxsync /* ... or does the user want to cancel? */
388b6b190a5407548753b7fde12fa58134ec3563vboxsync || ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
388b6b190a5407548753b7fde12fa58134ec3563vboxsync && fCanceled)
388b6b190a5407548753b7fde12fa58134ec3563vboxsync )
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
388b6b190a5407548753b7fde12fa58134ec3563vboxsync fFlags |= ProcessInputFlag_EndOfFile;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync }
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
388b6b190a5407548753b7fde12fa58134ec3563vboxsync uint32_t cbWritten;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync Assert(sizeof(byBuf) >= cbRead);
388b6b190a5407548753b7fde12fa58134ec3563vboxsync rc = pProcess->writeData(0 /* StdIn */, fFlags,
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync byBuf, cbRead,
388b6b190a5407548753b7fde12fa58134ec3563vboxsync 30 * 1000 /* Timeout */, &cbWritten);
388b6b190a5407548753b7fde12fa58134ec3563vboxsync if (RT_FAILURE(rc))
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
388b6b190a5407548753b7fde12fa58134ec3563vboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
388b6b190a5407548753b7fde12fa58134ec3563vboxsync Utf8StrFmt(GuestSession::tr("Writing to file \"%s\" (offset %RU64) failed: %Rrc"),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync mSource.c_str(), cbWrittenTotal, rc));
388b6b190a5407548753b7fde12fa58134ec3563vboxsync break;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync }
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync#ifdef DEBUG
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync LogFlowThisFunc(("cbWritten=%RU32, cbToRead=%RU64, cbWrittenTotal=%RU64, cbFileSize=%RU64\n",
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync cbWritten, cbToRead - cbWritten, cbWrittenTotal + cbWritten, cbFileSize));
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync#endif
388b6b190a5407548753b7fde12fa58134ec3563vboxsync /* Only subtract bytes reported written by the guest. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync Assert(cbToRead >= cbWritten);
388b6b190a5407548753b7fde12fa58134ec3563vboxsync cbToRead -= cbWritten;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
388b6b190a5407548753b7fde12fa58134ec3563vboxsync /* Update total bytes written to the guest. */
388b6b190a5407548753b7fde12fa58134ec3563vboxsync cbWrittenTotal += cbWritten;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync Assert(cbWrittenTotal <= cbFileSize);
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
388b6b190a5407548753b7fde12fa58134ec3563vboxsync /* Did the user cancel the operation above? */
388b6b190a5407548753b7fde12fa58134ec3563vboxsync if (fCanceled)
388b6b190a5407548753b7fde12fa58134ec3563vboxsync break;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync /* Update the progress.
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync * Watch out for division by zero. */
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync cbFileSize > 0
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync ? rc = setProgress((ULONG)(cbWrittenTotal * 100 / cbFileSize))
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync : rc = setProgress(100);
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if (RT_FAILURE(rc))
388b6b190a5407548753b7fde12fa58134ec3563vboxsync break;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
388b6b190a5407548753b7fde12fa58134ec3563vboxsync /* End of file reached? */
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if (!cbToRead)
388b6b190a5407548753b7fde12fa58134ec3563vboxsync break;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync } /* for */
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
388b6b190a5407548753b7fde12fa58134ec3563vboxsync if ( !fCanceled
388b6b190a5407548753b7fde12fa58134ec3563vboxsync || RT_SUCCESS(rc))
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
388b6b190a5407548753b7fde12fa58134ec3563vboxsync /*
388b6b190a5407548753b7fde12fa58134ec3563vboxsync * Even if we succeeded until here make sure to check whether we really transfered
388b6b190a5407548753b7fde12fa58134ec3563vboxsync * everything.
388b6b190a5407548753b7fde12fa58134ec3563vboxsync */
388b6b190a5407548753b7fde12fa58134ec3563vboxsync if ( cbFileSize > 0
388b6b190a5407548753b7fde12fa58134ec3563vboxsync && cbWrittenTotal == 0)
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
388b6b190a5407548753b7fde12fa58134ec3563vboxsync /* If nothing was transfered but the file size was > 0 then "vbox_cat" wasn't able to write
388b6b190a5407548753b7fde12fa58134ec3563vboxsync * to the destination -> access denied. */
388b6b190a5407548753b7fde12fa58134ec3563vboxsync rc = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
388b6b190a5407548753b7fde12fa58134ec3563vboxsync Utf8StrFmt(GuestSession::tr("Access denied when copying file \"%s\" to \"%s\""),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync mSource.c_str(), mDest.c_str()));
388b6b190a5407548753b7fde12fa58134ec3563vboxsync }
388b6b190a5407548753b7fde12fa58134ec3563vboxsync else if (cbWrittenTotal < cbFileSize)
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
388b6b190a5407548753b7fde12fa58134ec3563vboxsync /* If we did not copy all let the user know. */
388b6b190a5407548753b7fde12fa58134ec3563vboxsync rc = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
388b6b190a5407548753b7fde12fa58134ec3563vboxsync Utf8StrFmt(GuestSession::tr("Copying file \"%s\" failed (%RU64/%RU64 bytes transfered)"),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync mSource.c_str(), cbWrittenTotal, cbFileSize));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync else
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync rc = pProcess->waitFor(ProcessWaitForFlag_Terminate,
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync 30 * 1000 /* Timeout */, waitRes);
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if ( RT_FAILURE(rc)
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync || waitRes.mResult != ProcessWaitResult_Terminate)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if (RT_FAILURE(rc))
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync rc = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync Utf8StrFmt(GuestSession::tr("Waiting on termination for copying file \"%s\" failed: %Rrc"),
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync mSource.c_str(), rc));
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync else
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync rc = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync Utf8StrFmt(GuestSession::tr("Waiting on termination for copying file \"%s\" failed with wait result %ld"),
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync mSource.c_str(), waitRes.mResult));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if (RT_SUCCESS(rc))
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync {
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync ProcessStatus_T procStatus;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync LONG exitCode;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if ( ( SUCCEEDED(pProcess->COMGETTER(Status(&procStatus)))
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync && procStatus != ProcessStatus_TerminatedNormally)
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync || ( SUCCEEDED(pProcess->COMGETTER(ExitCode(&exitCode)))
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync && exitCode != 0)
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync )
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync {
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync rc = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync Utf8StrFmt(GuestSession::tr("Copying file \"%s\" failed with status %ld, exit code %ld"),
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync mSource.c_str(), procStatus, exitCode)); /**@todo Add stringify methods! */
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync }
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync }
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if (RT_SUCCESS(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync rc = setProgressSuccess();
388b6b190a5407548753b7fde12fa58134ec3563vboxsync }
388b6b190a5407548753b7fde12fa58134ec3563vboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync pProcess->close();
388b6b190a5407548753b7fde12fa58134ec3563vboxsync } /* processCreateExInteral */
388b6b190a5407548753b7fde12fa58134ec3563vboxsync } /* RTFileGetSize */
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
388b6b190a5407548753b7fde12fa58134ec3563vboxsync RTFileClose(fileSource);
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
388b6b190a5407548753b7fde12fa58134ec3563vboxsync } /* RTFileOpen */
388b6b190a5407548753b7fde12fa58134ec3563vboxsync } /* RTFileExists */
388b6b190a5407548753b7fde12fa58134ec3563vboxsync }
388b6b190a5407548753b7fde12fa58134ec3563vboxsync catch (int rc2)
388b6b190a5407548753b7fde12fa58134ec3563vboxsync {
388b6b190a5407548753b7fde12fa58134ec3563vboxsync rc = rc2;
388b6b190a5407548753b7fde12fa58134ec3563vboxsync }
388b6b190a5407548753b7fde12fa58134ec3563vboxsync
388b6b190a5407548753b7fde12fa58134ec3563vboxsync LogFlowFuncLeaveRC(rc);
388b6b190a5407548753b7fde12fa58134ec3563vboxsync return rc;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsyncint SessionTaskCopyTo::RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync LogFlowThisFunc(("strDesc=%s, strSource=%s, strDest=%s, mCopyFileFlags=%x\n",
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync strDesc.c_str(), mSource.c_str(), mDest.c_str(), mCopyFileFlags));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync mDesc = strDesc;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync mProgress = pProgress;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync int rc = RTThreadCreate(NULL, SessionTaskCopyTo::taskThread, this,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync 0, RTTHREADTYPE_MAIN_HEAVY_WORKER, 0,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync "gctlCpyTo");
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync LogFlowFuncLeaveRC(rc);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return rc;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync/* static */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncint SessionTaskCopyTo::taskThread(RTTHREAD Thread, void *pvUser)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync std::auto_ptr<SessionTaskCopyTo> task(static_cast<SessionTaskCopyTo*>(pvUser));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync AssertReturn(task.get(), VERR_GENERAL_FAILURE);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync LogFlowFunc(("pTask=%p\n", task.get()));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return task->Run();
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsyncSessionTaskCopyFrom::SessionTaskCopyFrom(GuestSession *pSession,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync const Utf8Str &strSource, const Utf8Str &strDest, uint32_t uFlags)
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync : GuestSessionTask(pSession)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync mSource = strSource;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync mDest = strDest;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync mFlags = uFlags;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncSessionTaskCopyFrom::~SessionTaskCopyFrom(void)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncint SessionTaskCopyFrom::Run(void)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
5366e994777f9d9391cf809dc77610f57270d75dvboxsync LogFlowThisFuncEnter();
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync ComObjPtr<GuestSession> pSession = mSession;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync Assert(!pSession.isNull());
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync AutoCaller autoCaller(pSession);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync int rc;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /** @todo Make use of exceptions (+ finally block) here! */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync try
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /*
5366e994777f9d9391cf809dc77610f57270d75dvboxsync * Note: There will be races between querying file size + reading the guest file's
5366e994777f9d9391cf809dc77610f57270d75dvboxsync * content because we currently *do not* lock down the guest file when doing the
5366e994777f9d9391cf809dc77610f57270d75dvboxsync * actual operations.
5366e994777f9d9391cf809dc77610f57270d75dvboxsync ** @todo Implement guest file locking!
5366e994777f9d9391cf809dc77610f57270d75dvboxsync */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync GuestFsObjData objData;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync rc = pSession->fileQueryInfoInternal(Utf8Str(mSource), objData);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_FAILURE(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
5366e994777f9d9391cf809dc77610f57270d75dvboxsync Utf8StrFmt(GuestSession::tr("Querying guest file information for \"%s\" failed: %Rrc"),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync mSource.c_str(), rc));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync else if (objData.mType != FsObjType_File) /* Only single files are supported at the moment. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync rc = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
5366e994777f9d9391cf809dc77610f57270d75dvboxsync Utf8StrFmt(GuestSession::tr("Guest file \"%s\" is not a file"), mSource.c_str()));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_SUCCESS(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync RTFILE fileDest;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync rc = RTFileOpen(&fileDest, mDest.c_str(),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync RTFILE_O_WRITE | RTFILE_O_OPEN_CREATE | RTFILE_O_DENY_WRITE); /** @todo Use the correct open modes! */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_FAILURE(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
5366e994777f9d9391cf809dc77610f57270d75dvboxsync Utf8StrFmt(GuestSession::tr("Error opening destination file \"%s\": %Rrc"),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync mDest.c_str(), rc));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync else
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync GuestProcessStartupInfo procInfo;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync procInfo.mName = Utf8StrFmt(GuestSession::tr("Copying file \"%s\" from guest to the host to \"%s\" (%RI64 bytes)"),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync mSource.c_str(), mDest.c_str(), objData.mObjectSize);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_CAT);
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync procInfo.mFlags = ProcessCreateFlag_Hidden | ProcessCreateFlag_WaitForStdOut;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /* Set arguments.*/
5366e994777f9d9391cf809dc77610f57270d75dvboxsync procInfo.mArguments.push_back(mSource); /* Which file to output? */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /* Startup process. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync ComObjPtr<GuestProcess> pProcess;
386a7cc6c736c97bb8839df94eef779de7fbfdc1vboxsync rc = pSession->processCreateExInteral(procInfo, pProcess);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_SUCCESS(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync rc = pProcess->startProcess();
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_FAILURE(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
5366e994777f9d9391cf809dc77610f57270d75dvboxsync Utf8StrFmt(GuestSession::tr("Unable to start guest process: %Rrc"), rc));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync else
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync GuestProcessWaitResult waitRes;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync BYTE byBuf[_64K];
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync BOOL fCanceled = FALSE;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync uint64_t cbWrittenTotal = 0;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync uint64_t cbToRead = objData.mObjectSize;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync for (;;)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync rc = pProcess->waitFor(ProcessWaitForFlag_StdOut,
5366e994777f9d9391cf809dc77610f57270d75dvboxsync 30 * 1000 /* Timeout */, waitRes);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if ( RT_FAILURE(rc)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync || waitRes.mResult != ProcessWaitResult_StdOut)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync break;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync size_t cbRead;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync rc = pProcess->readData(OUTPUT_HANDLE_ID_STDOUT, sizeof(byBuf),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync 30 * 1000 /* Timeout */, byBuf, sizeof(byBuf),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync &cbRead);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_FAILURE(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
5366e994777f9d9391cf809dc77610f57270d75dvboxsync Utf8StrFmt(GuestSession::tr("Reading from file \"%s\" (offset %RU64) failed: %Rrc"),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync mSource.c_str(), cbWrittenTotal, rc));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync break;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (cbRead)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync rc = RTFileWrite(fileDest, byBuf, cbRead, NULL /* No partial writes */);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_FAILURE(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync setProgressErrorMsg(VBOX_E_IPRT_ERROR,
5366e994777f9d9391cf809dc77610f57270d75dvboxsync Utf8StrFmt(GuestSession::tr("Error writing to file \"%s\" (%RU64 bytes left): %Rrc"),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync mDest.c_str(), cbToRead, rc));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync break;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /* Only subtract bytes reported written by the guest. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync Assert(cbToRead >= cbRead);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync cbToRead -= cbRead;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /* Update total bytes written to the guest. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync cbWrittenTotal += cbRead;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync Assert(cbWrittenTotal <= (uint64_t)objData.mObjectSize);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /* Did the user cancel the operation above? */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if ( SUCCEEDED(mProgress->COMGETTER(Canceled(&fCanceled)))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync && fCanceled)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync break;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync rc = setProgress((ULONG)(cbWrittenTotal / ((uint64_t)objData.mObjectSize / 100.0)));
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if (RT_FAILURE(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync break;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /* End of file reached? */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (cbToRead == 0)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync break;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync } /* for */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if ( !fCanceled
5366e994777f9d9391cf809dc77610f57270d75dvboxsync || RT_SUCCESS(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /*
5366e994777f9d9391cf809dc77610f57270d75dvboxsync * Even if we succeeded until here make sure to check whether we really transfered
5366e994777f9d9391cf809dc77610f57270d75dvboxsync * everything.
5366e994777f9d9391cf809dc77610f57270d75dvboxsync */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if ( objData.mObjectSize > 0
5366e994777f9d9391cf809dc77610f57270d75dvboxsync && cbWrittenTotal == 0)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /* If nothing was transfered but the file size was > 0 then "vbox_cat" wasn't able to write
5366e994777f9d9391cf809dc77610f57270d75dvboxsync * to the destination -> access denied. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync rc = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
5366e994777f9d9391cf809dc77610f57270d75dvboxsync Utf8StrFmt(GuestSession::tr("Access denied when copying file \"%s\" to \"%s\""),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync mSource.c_str(), mDest.c_str()));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync else if (cbWrittenTotal < (uint64_t)objData.mObjectSize)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /* If we did not copy all let the user know. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync rc = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
5366e994777f9d9391cf809dc77610f57270d75dvboxsync Utf8StrFmt(GuestSession::tr("Copying file \"%s\" failed (%RU64/%RU64 bytes transfered)"),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync mSource.c_str(), cbWrittenTotal, objData.mObjectSize));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync else
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync ProcessStatus_T procStatus;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync LONG exitCode;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if ( ( SUCCEEDED(pProcess->COMGETTER(Status(&procStatus)))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync && procStatus != ProcessStatus_TerminatedNormally)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync || ( SUCCEEDED(pProcess->COMGETTER(ExitCode(&exitCode)))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync && exitCode != 0)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync )
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync rc = setProgressErrorMsg(VBOX_E_IPRT_ERROR,
5366e994777f9d9391cf809dc77610f57270d75dvboxsync Utf8StrFmt(GuestSession::tr("Copying file \"%s\" failed with status %ld, exit code %d"),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync mSource.c_str(), procStatus, exitCode)); /**@todo Add stringify methods! */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync else /* Yay, success! */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync rc = setProgressSuccess();
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync pProcess->close();
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync RTFileClose(fileDest);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync catch (int rc2)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync rc = rc2;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync LogFlowFuncLeaveRC(rc);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync return rc;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsyncint SessionTaskCopyFrom::RunAsync(const Utf8Str &strDesc, ComObjPtr<Progress> &pProgress)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync LogFlowThisFunc(("strDesc=%s, strSource=%s, strDest=%s, uFlags=%x\n",
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync strDesc.c_str(), mSource.c_str(), mDest.c_str(), mFlags));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync mDesc = strDesc;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync mProgress = pProgress;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync int rc = RTThreadCreate(NULL, SessionTaskCopyFrom::taskThread, this,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync 0, RTTHREADTYPE_MAIN_HEAVY_WORKER, 0,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync "gctlCpyFrom");
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync LogFlowFuncLeaveRC(rc);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return rc;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync/* static */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncint SessionTaskCopyFrom::taskThread(RTTHREAD Thread, void *pvUser)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync std::auto_ptr<SessionTaskCopyFrom> task(static_cast<SessionTaskCopyFrom*>(pvUser));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync AssertReturn(task.get(), VERR_GENERAL_FAILURE);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync LogFlowFunc(("pTask=%p\n", task.get()));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return task->Run();
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync// public initializer/uninitializer for internal purposes only
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/////////////////////////////////////////////////////////////////////////////
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsyncint GuestSession::init(Guest *aGuest, ULONG aSessionID,
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync Utf8Str aUser, Utf8Str aPassword, Utf8Str aDomain, Utf8Str aName)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
c142e0f462e6c921a73d84ee50f41396b3a99db5vboxsync AssertPtrReturn(aGuest, VERR_INVALID_POINTER);
c142e0f462e6c921a73d84ee50f41396b3a99db5vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /* Enclose the state transition NotReady->InInit->Ready. */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoInitSpan autoInitSpan(this);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync AssertReturn(autoInitSpan.isOk(), VERR_OBJECT_DESTROYED);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync mData.mTimeout = 30 * 60 * 1000; /* Session timeout is 30 mins by default. */
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync mData.mParent = aGuest;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync mData.mId = aSessionID;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync mData.mCredentials.mUser = aUser;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync mData.mCredentials.mPassword = aPassword;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync mData.mCredentials.mDomain = aDomain;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync mData.mName = aName;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /* Confirm a successful initialization when it's the case. */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync autoInitSpan.setSucceeded();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(VINF_SUCCESS);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return VINF_SUCCESS;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/**
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * Uninitializes the instance.
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync * Called from FinalRelease().
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncvoid GuestSession::uninit(void)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync /* Enclose the state transition Ready->InUninit->NotReady. */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoUninitSpan autoUninitSpan(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (autoUninitSpan.uninitDone())
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync return;
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync#ifdef VBOX_WITH_GUEST_CONTROL
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync for (SessionDirectories::iterator itDirs = mData.mDirectories.begin();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync itDirs != mData.mDirectories.end(); ++itDirs)
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync {
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync (*itDirs)->uninit();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync (*itDirs).setNull();
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync mData.mDirectories.clear();
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync for (SessionFiles::iterator itFiles = mData.mFiles.begin();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync itFiles != mData.mFiles.end(); ++itFiles)
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync {
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync (*itFiles)->uninit();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync (*itFiles).setNull();
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync mData.mFiles.clear();
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync for (SessionProcesses::iterator itProcs = mData.mProcesses.begin();
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync itProcs != mData.mProcesses.end(); ++itProcs)
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync {
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync itProcs->second->close();
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync }
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync for (SessionProcesses::iterator itProcs = mData.mProcesses.begin();
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync itProcs != mData.mProcesses.end(); ++itProcs)
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync {
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync itProcs->second->uninit();
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync itProcs->second.setNull();
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync mData.mProcesses.clear();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync mData.mParent->sessionClose(this);
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncLeave();
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync#endif
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync// implementation of public getters/setters for attributes
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/////////////////////////////////////////////////////////////////////////////
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::COMGETTER(User)(BSTR *aUser)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync CheckComArgOutPointerValid(aUser);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync mData.mCredentials.mUser.cloneTo(aUser);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Domain)(BSTR *aDomain)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync CheckComArgOutPointerValid(aDomain);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync mData.mCredentials.mDomain.cloneTo(aDomain);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Name)(BSTR *aName)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync CheckComArgOutPointerValid(aName);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync mData.mName.cloneTo(aName);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Id)(ULONG *aId)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync CheckComArgOutPointerValid(aId);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync *aId = mData.mId;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Timeout)(ULONG *aTimeout)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync CheckComArgOutPointerValid(aTimeout);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync *aTimeout = mData.mTimeout;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
7e8ef90d3160234df0f254131b87af4243d79476vboxsyncSTDMETHODIMP GuestSession::COMSETTER(Timeout)(ULONG aTimeout)
7e8ef90d3160234df0f254131b87af4243d79476vboxsync{
7e8ef90d3160234df0f254131b87af4243d79476vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
7e8ef90d3160234df0f254131b87af4243d79476vboxsync ReturnComNotImplemented();
7e8ef90d3160234df0f254131b87af4243d79476vboxsync#else
7e8ef90d3160234df0f254131b87af4243d79476vboxsync LogFlowThisFuncEnter();
7e8ef90d3160234df0f254131b87af4243d79476vboxsync
7e8ef90d3160234df0f254131b87af4243d79476vboxsync AutoCaller autoCaller(this);
7e8ef90d3160234df0f254131b87af4243d79476vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
7e8ef90d3160234df0f254131b87af4243d79476vboxsync
7e8ef90d3160234df0f254131b87af4243d79476vboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
7e8ef90d3160234df0f254131b87af4243d79476vboxsync
7e8ef90d3160234df0f254131b87af4243d79476vboxsync mData.mTimeout = aTimeout;
7e8ef90d3160234df0f254131b87af4243d79476vboxsync
7e8ef90d3160234df0f254131b87af4243d79476vboxsync LogFlowFuncLeaveRC(S_OK);
7e8ef90d3160234df0f254131b87af4243d79476vboxsync return S_OK;
7e8ef90d3160234df0f254131b87af4243d79476vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
7e8ef90d3160234df0f254131b87af4243d79476vboxsync}
7e8ef90d3160234df0f254131b87af4243d79476vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Environment)(ComSafeArrayOut(BSTR, aEnvironment))
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync CheckComArgOutSafeArrayPointerValid(aEnvironment);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync size_t cEnvVars = mData.mEnvironment.Size();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFunc(("%s cEnvVars=%RU32\n", mData.mName.c_str(), cEnvVars));
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync com::SafeArray<BSTR> environment(cEnvVars);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync for (size_t i = 0; i < cEnvVars; i++)
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync {
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync Bstr strEnv(mData.mEnvironment.Get(i));
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync strEnv.cloneTo(&environment[i]);
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync }
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync environment.detachTo(ComSafeArrayOutArg(aEnvironment));
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsyncSTDMETHODIMP GuestSession::COMSETTER(Environment)(ComSafeArrayIn(IN_BSTR, aValues))
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync{
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync ReturnComNotImplemented();
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync#else
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync LogFlowThisFuncEnter();
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync AutoCaller autoCaller(this);
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync com::SafeArray<IN_BSTR> environment(ComSafeArrayInArg(aValues));
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync int rc = VINF_SUCCESS;
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync for (size_t i = 0; i < environment.size() && RT_SUCCESS(rc); i++)
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync {
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync Utf8Str strEnv(environment[i]);
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync if (!strEnv.isEmpty()) /* Silently skip empty entries. */
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync rc = mData.mEnvironment.Set(strEnv);
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync }
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync HRESULT hr = RT_SUCCESS(rc) ? S_OK : VBOX_E_IPRT_ERROR;
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync LogFlowFuncLeaveRC(hr);
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync return hr;
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync}
1cd59fdf671ca60c64d77e3f7046aaecf7003824vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Processes)(ComSafeArrayOut(IGuestProcess *, aProcesses))
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync CheckComArgOutSafeArrayPointerValid(aProcesses);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync SafeIfaceArray<IGuestProcess> collection(mData.mProcesses);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync collection.detachTo(ComSafeArrayOutArg(aProcesses));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Directories)(ComSafeArrayOut(IGuestDirectory *, aDirectories))
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync CheckComArgOutSafeArrayPointerValid(aDirectories);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync SafeIfaceArray<IGuestDirectory> collection(mData.mDirectories);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync collection.detachTo(ComSafeArrayOutArg(aDirectories));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncSTDMETHODIMP GuestSession::COMGETTER(Files)(ComSafeArrayOut(IGuestFile *, aFiles))
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync CheckComArgOutSafeArrayPointerValid(aFiles);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync SafeIfaceArray<IGuestFile> collection(mData.mFiles);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync collection.detachTo(ComSafeArrayOutArg(aFiles));
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync// private methods
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync/////////////////////////////////////////////////////////////////////////////
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsyncint GuestSession::directoryClose(ComObjPtr<GuestDirectory> pDirectory)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync{
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync for (SessionDirectories::iterator itDirs = mData.mDirectories.begin();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync itDirs != mData.mDirectories.end(); ++itDirs)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync {
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync if (pDirectory == (*itDirs))
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync {
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync mData.mDirectories.erase(itDirs);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return VINF_SUCCESS;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return VERR_NOT_FOUND;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync}
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsyncint GuestSession::directoryCreateInternal(const Utf8Str &strPath, uint32_t uMode, uint32_t uFlags, ComObjPtr<GuestDirectory> &pDirectory)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync{
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync LogFlowThisFunc(("strPath=%s, uMode=%x, uFlags=%x\n",
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync strPath.c_str(), uMode, uFlags));
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync GuestProcessStartupInfo procInfo;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync procInfo.mName = Utf8StrFmt(tr("Creating directory \"%s\"", strPath.c_str()));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_MKDIR);
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync procInfo.mFlags = ProcessCreateFlag_Hidden;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync int rc = VINF_SUCCESS;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync /* Construct arguments. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (uFlags & DirectoryCreateFlag_Parents)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync procInfo.mArguments.push_back(Utf8Str("--parents")); /* We also want to create the parent directories. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (uMode)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync procInfo.mArguments.push_back(Utf8Str("--mode")); /* Set the creation mode. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync char szMode[16];
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (RTStrPrintf(szMode, sizeof(szMode), "%o", uMode))
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync procInfo.mArguments.push_back(Utf8Str(szMode));
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync else
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync rc = VERR_INVALID_PARAMETER;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync procInfo.mArguments.push_back(strPath); /* The directory we want to create. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync ComObjPtr<GuestProcess> pProcess;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync rc = processCreateExInteral(procInfo, pProcess);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_SUCCESS(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync rc = pProcess->startProcess();
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (RT_SUCCESS(rc))
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync GuestProcessWaitResult waitRes;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync rc = pProcess->waitFor(ProcessWaitForFlag_Terminate, 30 * 1000 /* Timeout */, waitRes);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (RT_SUCCESS(rc))
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync ProcessStatus_T procStatus;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync HRESULT hr = pProcess->COMGETTER(Status)(&procStatus);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync ComAssertComRC(hr);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (procStatus == ProcessStatus_TerminatedNormally)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync LONG lExitCode;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync pProcess->COMGETTER(ExitCode)(&lExitCode);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (lExitCode != 0)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync return VERR_CANT_CREATE;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync else
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync rc = VERR_BROKEN_PIPE; /** @todo Find a better rc. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (RT_FAILURE(rc))
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync return rc;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync try
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync /* Create the directory object. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync HRESULT hr = pDirectory.createObject();
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (FAILED(hr)) throw VERR_COM_UNEXPECTED;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync /* Note: There will be a race between creating and getting/initing the directory
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync object here. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync rc = pDirectory->init(this /* Parent */, strPath);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (RT_FAILURE(rc)) throw rc;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync /* Add the created directory to our vector. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync mData.mDirectories.push_back(pDirectory);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync LogFlowFunc(("Added new directory \"%s\" (Session: %RU32)\n",
5366e994777f9d9391cf809dc77610f57270d75dvboxsync strPath.c_str(), mData.mId));
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync catch (int rc2)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync rc = rc2;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync LogFlowFuncLeaveRC(rc);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync return rc;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync}
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsyncint GuestSession::directoryOpenInternal(const Utf8Str &strPath, const Utf8Str &strFilter,
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync uint32_t uFlags, ComObjPtr<GuestDirectory> &pDirectory)
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync{
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync LogFlowThisFunc(("strPath=%s, strPath=%s, uFlags=%x\n",
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync strPath.c_str(), strFilter.c_str(), uFlags));
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync int rc;
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync try
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync {
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync /* Create the directory object. */
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync HRESULT hr = pDirectory.createObject();
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync if (FAILED(hr)) throw VERR_COM_UNEXPECTED;
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync rc = pDirectory->init(this /* Parent */,
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync strPath, strFilter, uFlags);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync if (RT_FAILURE(rc)) throw rc;
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync /* Add the created directory to our vector. */
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync mData.mDirectories.push_back(pDirectory);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync LogFlowFunc(("Added new directory \"%s\" (Session: %RU32)\n",
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync strPath.c_str(), mData.mId));
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync }
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync catch (int rc2)
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync {
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync rc = rc2;
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync }
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync LogFlowFuncLeaveRC(rc);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync return rc;
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync}
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsyncint GuestSession::dispatchToProcess(uint32_t uContextID, uint32_t uFunction, void *pvData, size_t cbData)
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync{
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync LogFlowFuncEnter();
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync uint32_t uProcessID = VBOX_GUESTCTRL_CONTEXTID_GET_PROCESS(uContextID);
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync#ifdef DEBUG
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync LogFlowFunc(("uProcessID=%RU32 (%RU32 total)\n",
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync uProcessID, mData.mProcesses.size()));
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync#endif
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync int rc;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync SessionProcesses::const_iterator itProc
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync = mData.mProcesses.find(uProcessID);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync if (itProc != mData.mProcesses.end())
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync {
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync ComObjPtr<GuestProcess> pProcess(itProc->second);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync Assert(!pProcess.isNull());
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync alock.release();
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync rc = pProcess->callbackDispatcher(uContextID, uFunction, pvData, cbData);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync }
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync else
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync rc = VERR_NOT_FOUND;
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync LogFlowFuncLeaveRC(rc);
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync return rc;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync}
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsyncint GuestSession::fileClose(ComObjPtr<GuestFile> pFile)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync{
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync for (SessionFiles::iterator itFiles = mData.mFiles.begin();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync itFiles != mData.mFiles.end(); ++itFiles)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync {
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync if (pFile == (*itFiles))
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync {
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync mData.mFiles.erase(itFiles);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return VINF_SUCCESS;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return VERR_NOT_FOUND;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync}
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsyncint GuestSession::fileOpenInternal(const Utf8Str &strPath, const Utf8Str &strOpenMode, const Utf8Str &strDisposition,
5366e994777f9d9391cf809dc77610f57270d75dvboxsync uint32_t uCreationMode, int64_t iOffset, ComObjPtr<GuestFile> &pFile)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync{
5366e994777f9d9391cf809dc77610f57270d75dvboxsync LogFlowThisFunc(("strPath=%s, strOpenMode=%s, strDisposition=%s, uCreationMode=%x, iOffset=%RI64\n",
5366e994777f9d9391cf809dc77610f57270d75dvboxsync strPath.c_str(), strOpenMode.c_str(), strDisposition.c_str(), uCreationMode, iOffset));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync int rc;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync try
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /* Create the directory object. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync HRESULT hr = pFile.createObject();
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (FAILED(hr)) throw VERR_COM_UNEXPECTED;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /* Note: There will be a race between creating and getting/initing the directory
5366e994777f9d9391cf809dc77610f57270d75dvboxsync object here. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync rc = pFile->init(this /* Parent */,
5366e994777f9d9391cf809dc77610f57270d75dvboxsync strPath, strOpenMode, strDisposition, uCreationMode, iOffset);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_FAILURE(rc)) throw rc;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /* Add the created directory to our vector. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync mData.mFiles.push_back(pFile);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync LogFlowFunc(("Added new file \"%s\" (Session: %RU32\n",
5366e994777f9d9391cf809dc77610f57270d75dvboxsync strPath.c_str(), mData.mId));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync catch (int rc2)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync rc = rc2;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync LogFlowFuncLeaveRC(rc);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync return rc;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync}
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync/* Note: Will work on directories and others, too. */
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsyncint GuestSession::fileQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData)
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync{
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync LogFlowThisFunc(("strPath=%s\n", strPath.c_str()));
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync GuestProcessStartupInfo procInfo;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync procInfo.mName = Utf8StrFmt(tr("Querying info for \"%s\""), strPath.c_str());
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_STAT);
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync procInfo.mFlags = ProcessCreateFlag_Hidden | ProcessCreateFlag_WaitForStdOut;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync /* Construct arguments. */
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync procInfo.mArguments.push_back(Utf8Str("--machinereadable"));
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync procInfo.mArguments.push_back(strPath);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync GuestProcessStream streamOut;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync ComObjPtr<GuestProcess> pProcess;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync int rc = processCreateExInteral(procInfo, pProcess);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_SUCCESS(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync rc = pProcess->startProcess();
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync if (RT_SUCCESS(rc))
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync {
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync GuestProcessWaitResult waitRes;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync BYTE byBuf[_64K];
5366e994777f9d9391cf809dc77610f57270d75dvboxsync size_t cbRead = 0;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync /** @todo Merge with GuestDirectory::read. */
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync for (;;)
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync {
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync rc = pProcess->waitFor(ProcessWaitForFlag_StdOut,
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync 30 * 1000 /* Timeout */, waitRes);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync if ( RT_FAILURE(rc)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync || waitRes.mResult == ProcessWaitResult_Terminate
5366e994777f9d9391cf809dc77610f57270d75dvboxsync || waitRes.mResult == ProcessWaitResult_Error
5366e994777f9d9391cf809dc77610f57270d75dvboxsync || waitRes.mResult == ProcessWaitResult_Timeout)
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync {
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync break;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync }
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync rc = pProcess->readData(OUTPUT_HANDLE_ID_STDOUT, sizeof(byBuf),
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync 30 * 1000 /* Timeout */, byBuf, sizeof(byBuf),
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync &cbRead);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync if (RT_FAILURE(rc))
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync break;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (cbRead)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync rc = streamOut.AddData(byBuf, cbRead);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_FAILURE(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync break;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync }
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync LogFlowThisFunc(("rc=%Rrc, cbRead=%RU64, cbStreamOut=%RU32\n",
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync rc, cbRead, streamOut.GetSize()));
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync }
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync if (RT_SUCCESS(rc))
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync {
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync GuestProcessStreamBlock streamBlock;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync rc = streamOut.ParseBlock(streamBlock);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync if (RT_SUCCESS(rc))
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync {
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync rc = objData.FromStat(streamBlock);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync }
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync else
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync AssertMsgFailed(("Parsing stream block failed: %Rrc\n", rc));
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync }
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync LogFlowFuncLeaveRC(rc);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync return rc;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync}
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsyncint GuestSession::fileQuerySizeInternal(const Utf8Str &strPath, int64_t *pllSize)
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync{
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync AssertPtrReturn(pllSize, VERR_INVALID_POINTER);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync GuestFsObjData objData;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync int rc = fileQueryInfoInternal(strPath, objData);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync if (RT_SUCCESS(rc))
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync {
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync if (objData.mType == FsObjType_File)
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync *pllSize = objData.mObjectSize;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync else
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync rc = VERR_NOT_A_FILE;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync }
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync return rc;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync}
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsyncconst GuestCredentials& GuestSession::getCredentials(void)
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync{
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync return mData.mCredentials;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync}
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsyncconst GuestEnvironment& GuestSession::getEnvironment(void)
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync{
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync return mData.mEnvironment;
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync}
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync
40c1a23e86c79b24a917a43c186b2e54504d12c1vboxsyncUtf8Str GuestSession::getName(void)
40c1a23e86c79b24a917a43c186b2e54504d12c1vboxsync{
40c1a23e86c79b24a917a43c186b2e54504d12c1vboxsync return mData.mName;
40c1a23e86c79b24a917a43c186b2e54504d12c1vboxsync}
40c1a23e86c79b24a917a43c186b2e54504d12c1vboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsyncint GuestSession::processClose(ComObjPtr<GuestProcess> pProcess)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync{
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync for (SessionProcesses::iterator itProcs = mData.mProcesses.begin();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync itProcs != mData.mProcesses.end(); ++itProcs)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync {
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync if (pProcess == itProcs->second)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync {
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync LogFlowFunc(("Removing process (Session: %RU32) with process ID=%RU32, guest PID=%RU32 (now total %ld processes)\n",
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync mData.mId, itProcs->second->getProcessID(), itProcs->second->getPID(), mData.mProcesses.size() - 1));
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync mData.mProcesses.erase(itProcs);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return VINF_SUCCESS;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return VERR_NOT_FOUND;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync}
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync/**
5366e994777f9d9391cf809dc77610f57270d75dvboxsync * Creates but does *not* start the process yet. See GuestProcess::startProcess() or
5366e994777f9d9391cf809dc77610f57270d75dvboxsync * GuestProcess::startProcessAsync() for that.
5366e994777f9d9391cf809dc77610f57270d75dvboxsync *
5366e994777f9d9391cf809dc77610f57270d75dvboxsync * @return IPRT status code.
5366e994777f9d9391cf809dc77610f57270d75dvboxsync * @param procInfo
5366e994777f9d9391cf809dc77610f57270d75dvboxsync * @param pProcess
5366e994777f9d9391cf809dc77610f57270d75dvboxsync */
5366e994777f9d9391cf809dc77610f57270d75dvboxsyncint GuestSession::processCreateExInteral(GuestProcessStartupInfo &procInfo, ComObjPtr<GuestProcess> &pProcess)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync{
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync LogFlowFunc(("mCmd=%s, mFlags=%x, mTimeoutMS=%RU32\n",
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync procInfo.mCommand.c_str(), procInfo.mFlags, procInfo.mTimeoutMS));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync#ifdef DEBUG
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (procInfo.mArguments.size())
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync LogFlowFunc(("Arguments:"));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync ProcessArguments::const_iterator it = procInfo.mArguments.begin();
5366e994777f9d9391cf809dc77610f57270d75dvboxsync while (it != procInfo.mArguments.end())
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync LogFlow((" %s", (*it).c_str()));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync it++;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync LogFlow(("\n"));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync#endif
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync /* Validate flags. */
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync if (procInfo.mFlags)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync {
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync if ( !(procInfo.mFlags & ProcessCreateFlag_IgnoreOrphanedProcesses)
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync && !(procInfo.mFlags & ProcessCreateFlag_WaitForProcessStartOnly)
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync && !(procInfo.mFlags & ProcessCreateFlag_Hidden)
7e8ef90d3160234df0f254131b87af4243d79476vboxsync && !(procInfo.mFlags & ProcessCreateFlag_NoProfile)
7e8ef90d3160234df0f254131b87af4243d79476vboxsync && !(procInfo.mFlags & ProcessCreateFlag_WaitForStdOut)
7e8ef90d3160234df0f254131b87af4243d79476vboxsync && !(procInfo.mFlags & ProcessCreateFlag_WaitForStdErr))
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync {
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return VERR_INVALID_PARAMETER;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync /* Adjust timeout. If set to 0, we define
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync * an infinite timeout. */
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync if (procInfo.mTimeoutMS == 0)
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync procInfo.mTimeoutMS = UINT32_MAX;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync /** @tood Implement process priority + affinity. */
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync int rc = VERR_MAX_PROCS_REACHED;
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync if (mData.mProcesses.size() >= VBOX_GUESTCTRL_MAX_PROCESSES)
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync return rc;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync /* Create a new (host-based) process ID and assign it. */
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync uint32_t uNewProcessID = 0;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync ULONG uTries = 0;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync for (;;)
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync {
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync /* Is the context ID already used? */
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if (!processExists(uNewProcessID, NULL /* pProgress */))
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync {
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync /* Callback with context ID was not found. This means
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync * we can use this context ID for our new callback we want
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync * to add below. */
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync rc = VINF_SUCCESS;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync break;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync }
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync uNewProcessID++;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync if (uNewProcessID == VBOX_GUESTCTRL_MAX_PROCESSES)
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync uNewProcessID = 0;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync if (++uTries == UINT32_MAX)
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync break; /* Don't try too hard. */
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (RT_FAILURE(rc)) return rc;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync try
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync {
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync /* Create the process object. */
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync HRESULT hr = pProcess.createObject();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync if (FAILED(hr)) throw VERR_COM_UNEXPECTED;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync rc = pProcess->init(mData.mParent->getConsole() /* Console */, this /* Session */,
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync uNewProcessID, procInfo);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync if (RT_FAILURE(rc)) throw rc;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync /* Add the created process to our map. */
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync mData.mProcesses[uNewProcessID] = pProcess;
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync LogFlowFunc(("Added new process (Session: %RU32) with process ID=%RU32 (now total %ld processes)\n",
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync mData.mId, uNewProcessID, mData.mProcesses.size()));
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync catch (int rc2)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync {
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync rc = rc2;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return rc;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync}
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
ccbdc11833996cb9f3be7868f1ebaefcacafb94dvboxsyncinline bool GuestSession::processExists(uint32_t uProcessID, ComObjPtr<GuestProcess> *pProcess)
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync{
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync SessionProcesses::const_iterator it = mData.mProcesses.find(uProcessID);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync if (it != mData.mProcesses.end())
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync {
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync if (pProcess)
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync *pProcess = it->second;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync return true;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync }
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync return false;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync}
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsyncinline int GuestSession::processGetByPID(ULONG uPID, ComObjPtr<GuestProcess> *pProcess)
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync{
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync AssertReturn(uPID, false);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync /* pProcess is optional. */
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync SessionProcesses::iterator it = mData.mProcesses.begin();
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync for (; it != mData.mProcesses.end(); it++)
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync {
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync ComObjPtr<GuestProcess> pCurProc = it->second;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync AutoCaller procCaller(pCurProc);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync if (procCaller.rc())
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync return VERR_COM_INVALID_OBJECT_STATE;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync if (it->second->getPID() == uPID)
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync {
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync if (pProcess)
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync *pProcess = pCurProc;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync return VINF_SUCCESS;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync }
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync }
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync return VERR_NOT_FOUND;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync}
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncint GuestSession::startTaskAsync(const Utf8Str &strTaskDesc,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync GuestSessionTask *pTask, ComObjPtr<Progress> &pProgress)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync{
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync LogFlowThisFunc(("strTaskDesc=%s, pTask=%p\n", strTaskDesc.c_str(), pTask));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync AssertPtrReturn(pTask, VERR_INVALID_POINTER);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync int rc;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync try
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync {
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync /* Create the progress object. */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync HRESULT hr = pProgress.createObject();
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (FAILED(hr)) throw VERR_COM_UNEXPECTED;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync hr = pProgress->init(static_cast<IGuestSession*>(this),
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync Bstr(strTaskDesc).raw(),
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync TRUE /* aCancelable */);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (FAILED(hr)) throw VERR_COM_UNEXPECTED;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync /* Initialize our worker task. */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync std::auto_ptr<GuestSessionTask> task(pTask);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync rc = task->RunAsync(strTaskDesc, pProgress);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (FAILED(rc)) throw rc;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync /* Don't destruct on success. */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync task.release();
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync }
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync catch (int rc2)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync {
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync rc = rc2;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync }
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync LogFlowFuncLeaveRC(rc);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return rc;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync}
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync/**
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync * Queries/collects information prior to establishing a guest session.
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync * This is necessary to know which guest control protocol version to use,
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync * among other things (later).
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync *
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync * @return IPRT status code.
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync */
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsyncint GuestSession::queryInfo(void)
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync{
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync#if 1
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync /* Since the new functions were not implemented yet, force Main to use protocol ver 1. */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync mData.mProtocolVersion = 1;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync#else
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync /*
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync * Try querying the guest control protocol version running on the guest.
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync * This is done using the Guest Additions version
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync */
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync ComObjPtr<Guest> pGuest = mData.mParent;
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync Assert(!pGuest.isNull());
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync uint32_t uVerAdditions = pGuest->getAdditionsVersion();
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync mData.mProtocolVersion = ( VBOX_FULL_VERSION_GET_MAJOR(uVerAdditions) >= 4
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync && VBOX_FULL_VERSION_GET_MINOR(uVerAdditions) >= 2) /** @todo What's about v5.0 ? */
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync ? 2 /* Guest control 2.0. */
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync : 1; /* Legacy guest control (VBox < 4.2). */
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync /* Build revision is ignored. */
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync /* Tell the user but don't bitch too often. */
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync static short s_gctrlLegacyWarning = 0;
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync if (s_gctrlLegacyWarning++ < 3) /** @todo Find a bit nicer text. */
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync LogRel((tr("Warning: Guest Additions are older (%ld.%ld) than host capabilities for guest control, please upgrade them. Using protocol version %ld now\n"),
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync VBOX_FULL_VERSION_GET_MAJOR(uVerAdditions), VBOX_FULL_VERSION_GET_MINOR(uVerAdditions), mData.mProtocolVersion));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync#endif
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync return VINF_SUCCESS;
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync}
f9ce005e61f0fbb51a2cabc53d58c3485151faa9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync// implementation of public methods
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync/////////////////////////////////////////////////////////////////////////////
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncSTDMETHODIMP GuestSession::Close(void)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync uninit();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncSTDMETHODIMP GuestSession::CopyFrom(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(CopyFileFlag_T, aFlags), IProgress **aProgress)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync CheckComArgStrNotEmptyOrNull(aSource);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync CheckComArgStrNotEmptyOrNull(aDest);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync CheckComArgOutPointerValid(aProgress);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (RT_UNLIKELY((aSource) == NULL || *(aSource) == '\0'))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return setError(E_INVALIDARG, tr("No source specified"));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (RT_UNLIKELY((aDest) == NULL || *(aDest) == '\0'))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return setError(E_INVALIDARG, tr("No destination specified"));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync uint32_t fFlags = CopyFileFlag_None;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (aFlags)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync {
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync com::SafeArray<CopyFileFlag_T> flags(ComSafeArrayInArg(aFlags));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync for (size_t i = 0; i < flags.size(); i++)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync fFlags |= flags[i];
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync }
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync HRESULT hr = S_OK;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync ComObjPtr<Progress> pProgress;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync SessionTaskCopyFrom *pTask = new SessionTaskCopyFrom(this /* GuestSession */,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync Utf8Str(aSource), Utf8Str(aDest), fFlags);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync AssertPtrReturn(pTask, VERR_NO_MEMORY);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync int rc = startTaskAsync(Utf8StrFmt(tr("Copying \"%ls\" from guest to \"%ls\" on the host"), aSource, aDest),
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync pTask, pProgress);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (RT_SUCCESS(rc))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync {
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync /* Return progress to the caller. */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync hr = pProgress.queryInterfaceTo(aProgress);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync }
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync else
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync hr = setError(VBOX_E_IPRT_ERROR,
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync tr("Starting task for copying file \"%ls\" from guest to \"%ls\" on the host failed: %Rrc"), rc);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsyncSTDMETHODIMP GuestSession::CopyTo(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(CopyFileFlag_T, aFlags), IProgress **aProgress)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync CheckComArgStrNotEmptyOrNull(aSource);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync CheckComArgStrNotEmptyOrNull(aDest);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync CheckComArgOutPointerValid(aProgress);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (RT_UNLIKELY((aSource) == NULL || *(aSource) == '\0'))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return setError(E_INVALIDARG, tr("No source specified"));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (RT_UNLIKELY((aDest) == NULL || *(aDest) == '\0'))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync return setError(E_INVALIDARG, tr("No destination specified"));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync uint32_t fFlags = CopyFileFlag_None;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (aFlags)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync {
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync com::SafeArray<CopyFileFlag_T> flags(ComSafeArrayInArg(aFlags));
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync for (size_t i = 0; i < flags.size(); i++)
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync fFlags |= flags[i];
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync }
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync HRESULT hr = S_OK;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync ComObjPtr<Progress> pProgress;
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync SessionTaskCopyTo *pTask = new SessionTaskCopyTo(this /* GuestSession */,
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync Utf8Str(aSource), Utf8Str(aDest), fFlags);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync AssertPtrReturn(pTask, VERR_NO_MEMORY);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync int rc = startTaskAsync(Utf8StrFmt(tr("Copying \"%ls\" from host to \"%ls\" on the guest"), aSource, aDest),
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync pTask, pProgress);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync if (RT_SUCCESS(rc))
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync {
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync /* Return progress to the caller. */
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync hr = pProgress.queryInterfaceTo(aProgress);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync }
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync else
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync hr = setError(VBOX_E_IPRT_ERROR,
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync tr("Starting task for copying file \"%ls\" from host to \"%ls\" on the guest failed: %Rrc"), rc);
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsyncSTDMETHODIMP GuestSession::DirectoryCreate(IN_BSTR aPath, ULONG aMode,
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync ComSafeArrayIn(DirectoryCreateFlag_T, aFlags), IGuestDirectory **aDirectory)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync return setError(E_INVALIDARG, tr("No directory to create specified"));
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync /* aDirectory is optional. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync uint32_t fFlags = DirectoryCreateFlag_None;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (aFlags)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync com::SafeArray<DirectoryCreateFlag_T> flags(ComSafeArrayInArg(aFlags));
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync for (size_t i = 0; i < flags.size(); i++)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync fFlags |= flags[i];
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (fFlags)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (!(fFlags & DirectoryCreateFlag_Parents))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync return setError(E_INVALIDARG, tr("Unknown flags (%#x)"), fFlags);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync HRESULT hr = S_OK;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync ComObjPtr <GuestDirectory> pDirectory;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync int rc = directoryCreateInternal(Utf8Str(aPath), (uint32_t)aMode, fFlags, pDirectory);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (RT_SUCCESS(rc))
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (aDirectory)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync /* Return directory object to the caller. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync hr = pDirectory.queryInterfaceTo(aDirectory);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync else
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync rc = directoryClose(pDirectory);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync if (RT_FAILURE(rc))
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Unable to close directory object, rc=%Rrc"), rc);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync else
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync switch (rc)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync case VERR_INVALID_PARAMETER:
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Directory creation failed: Invalid parameters given"));
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync break;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync case VERR_BROKEN_PIPE:
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Directory creation failed: Unexpectedly aborted"));
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync break;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync case VERR_CANT_CREATE:
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Directory creation failed: Could not create directory"));
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync break;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync default:
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Directory creation failed: %Rrc"), rc);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync break;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::DirectoryCreateTemp(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aName, IGuestDirectory **aDirectory)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync if (RT_UNLIKELY((aTemplate) == NULL || *(aTemplate) == '\0'))
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync return setError(E_INVALIDARG, tr("No file to remove specified"));
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync GuestProcessStartupInfo procInfo;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync GuestProcessStream streamOut;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync int rc = VINF_SUCCESS;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync try /* Can this be done without exceptions? */
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync {
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync Utf8Str strTemplate(aTemplate);
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync procInfo.mName = Utf8StrFmt(tr("Creating temporary directory from template \"%s\"",
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync strTemplate.c_str()));
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_MKTEMP);
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync procInfo.mFlags = ProcessCreateFlag_Hidden
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync | ProcessCreateFlag_WaitForStdOut;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync /* Construct arguments. */
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync procInfo.mArguments.push_back(Utf8Str("--machinereadable"));
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync procInfo.mArguments.push_back(Bstr(aTemplate)); /* The template we want to use. */
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync }
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync catch (...)
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync {
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync return E_OUTOFMEMORY;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync }
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync ComObjPtr<GuestProcess> pProcess;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync rc = processCreateExInteral(procInfo, pProcess);
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync if (RT_SUCCESS(rc))
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync {
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync GuestProcessWaitResult waitRes;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync BYTE byBuf[_64K];
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync size_t cbRead;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync for (;;)
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync {
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync rc = pProcess->waitFor(ProcessWaitForFlag_StdOut,
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync 30 * 1000 /* Timeout */, waitRes);
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync if ( RT_FAILURE(rc)
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync || waitRes.mResult == ProcessWaitResult_Terminate
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync || waitRes.mResult == ProcessWaitResult_Error
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync || waitRes.mResult == ProcessWaitResult_Timeout)
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync {
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync break;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync }
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync rc = pProcess->readData(OUTPUT_HANDLE_ID_STDOUT, sizeof(byBuf),
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync 30 * 1000 /* Timeout */, byBuf, sizeof(byBuf),
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync &cbRead);
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync if (RT_FAILURE(rc))
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync break;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync if (cbRead)
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync {
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync rc = streamOut.AddData(byBuf, cbRead);
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync if (RT_FAILURE(rc))
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync break;
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync }
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync }
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync LogFlowThisFunc(("rc=%Rrc, cbRead=%RU32, cbStreamOut=%RU32\n",
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync rc, cbRead, streamOut.GetSize()));
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync }
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync else
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync return setError(E_FAIL, tr("Error while starting temporary directory creation tool on guest: %Rrc"), rc);
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync if (RT_FAILURE(rc))
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync return setError(E_FAIL, tr("Error while running temporary directory creation tool: %Rrc"), rc);
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync if (!streamOut.GetSize())
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync return setError(E_FAIL, tr("No return code after creating temporary directory"));
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync GuestProcessStreamBlock streamBlock;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync rc = streamOut.ParseBlock(streamBlock);
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync if (RT_SUCCESS(rc))
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync {
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync streamBlock.GetString("name");
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync int64_t i64rc;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync if (RT_FAILURE(streamBlock.GetInt64Ex("rc", &i64rc)))
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync return setError(E_FAIL, tr("No return code after creating temporary directory"));
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync if (RT_FAILURE((int)i64rc))
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync return setError(VBOX_E_IPRT_ERROR, tr("File deletion failed: %Rrc"), rc);
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync }
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync else
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync return setError(E_FAIL, tr("Error while getting return code from creating temporary directory: %Rrc"), rc);
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::DirectoryExists(IN_BSTR aPath, BOOL *aExists)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync return setError(E_INVALIDARG, tr("No directory to check existence for specified"));
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync CheckComArgOutPointerValid(aExists);
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync HRESULT hr = S_OK;
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync GuestFsObjData objData;
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync int rc = fileQueryInfoInternal(Utf8Str(aPath), objData);
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync if (RT_SUCCESS(rc))
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync {
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync *aExists = objData.mType == FsObjType_Directory;
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync }
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync else
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync {
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync switch (rc)
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync {
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync /** @todo Add more errors here! */
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync default:
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Querying directory existence failed: %Rrc"), rc);
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync break;
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync }
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync }
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsyncSTDMETHODIMP GuestSession::DirectoryOpen(IN_BSTR aPath, IN_BSTR aFilter, ComSafeArrayIn(DirectoryOpenFlag_T, aFlags), IGuestDirectory **aDirectory)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync return setError(E_INVALIDARG, tr("No directory to open specified"));
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync if (RT_UNLIKELY((aFilter) != NULL && *(aFilter) != '\0'))
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync return setError(E_INVALIDARG, tr("Directory filters not implemented yet"));
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync CheckComArgOutPointerValid(aDirectory);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync uint32_t fFlags = DirectoryOpenFlag_None;
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync if (aFlags)
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync {
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync com::SafeArray<DirectoryOpenFlag_T> flags(ComSafeArrayInArg(aFlags));
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync for (size_t i = 0; i < flags.size(); i++)
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync fFlags |= flags[i];
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync if (fFlags)
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync return setError(E_INVALIDARG, tr("Open flags (%#x) not implemented yet"), fFlags);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync }
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync HRESULT hr = S_OK;
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync ComObjPtr <GuestDirectory> pDirectory;
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync int rc = directoryOpenInternal(Utf8Str(aPath), Utf8Str(aFilter), fFlags, pDirectory);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync if (RT_SUCCESS(rc))
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync {
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync if (aDirectory)
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync {
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync /* Return directory object to the caller. */
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync hr = pDirectory.queryInterfaceTo(aDirectory);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync }
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync else
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync {
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync rc = directoryClose(pDirectory);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync if (RT_FAILURE(rc))
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Unable to close directory object, rc=%Rrc"), rc);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync }
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync }
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync else
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync {
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync switch (rc)
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync {
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync case VERR_INVALID_PARAMETER:
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Opening directory failed: Invalid parameters given"));
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync break;
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync case VERR_BROKEN_PIPE:
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Opening directory failed: Unexpectedly aborted"));
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync break;
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync default:
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Opening directory failed: %Rrc"), rc);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync break;
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync }
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync }
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::DirectoryQueryInfo(IN_BSTR aPath, IGuestFsObjInfo **aInfo)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::DirectoryRemove(IN_BSTR aPath)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::DirectoryRemoveRecursive(IN_BSTR aPath, ComSafeArrayIn(DirectoryRemoveRecFlag_T, aFlags), IProgress **aProgress)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::DirectoryRename(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(PathRenameFlag_T, aFlags))
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::DirectorySetACL(IN_BSTR aPath, IN_BSTR aACL)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsyncSTDMETHODIMP GuestSession::EnvironmentClear(void)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync mData.mEnvironment.Clear();
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync return S_OK;
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync}
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsyncSTDMETHODIMP GuestSession::EnvironmentGet(IN_BSTR aName, BSTR *aValue)
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync{
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync#ifndef VBOX_WITH_GUEST_CONTROL
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync ReturnComNotImplemented();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync if (RT_UNLIKELY((aName) == NULL || *(aName) == '\0'))
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync return setError(E_INVALIDARG, tr("No value name specified"));
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync CheckComArgOutPointerValid(aValue);
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync AutoCaller autoCaller(this);
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync Bstr strValue(mData.mEnvironment.Get(Utf8Str(aName)));
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync strValue.cloneTo(aValue);
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::EnvironmentSet(IN_BSTR aName, IN_BSTR aValue)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync if (RT_UNLIKELY((aName) == NULL || *(aName) == '\0'))
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync return setError(E_INVALIDARG, tr("No value name specified"));
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync int rc = mData.mEnvironment.Set(Utf8Str(aName), Utf8Str(aValue));
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync HRESULT hr = RT_SUCCESS(rc) ? S_OK : VBOX_E_IPRT_ERROR;
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(hr);
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::EnvironmentUnset(IN_BSTR aName)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync mData.mEnvironment.Unset(Utf8Str(aName));
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowFuncLeaveRC(S_OK);
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync return S_OK;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::FileCreateTemp(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aName, IGuestFile **aFile)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::FileExists(IN_BSTR aPath, BOOL *aExists)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync return setError(E_INVALIDARG, tr("No file to check existence for specified"));
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync CheckComArgOutPointerValid(aExists);
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync HRESULT hr = S_OK;
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync GuestFsObjData objData;
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync int rc = fileQueryInfoInternal(Utf8Str(aPath), objData);
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync if (RT_SUCCESS(rc))
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync {
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync *aExists = objData.mType == FsObjType_File;
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync }
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync else
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync {
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync switch (rc)
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync {
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync /** @todo Add more errors here! */
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync default:
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Querying file existence failed: %Rrc"), rc);
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync break;
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync }
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync }
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsyncSTDMETHODIMP GuestSession::FileRemove(IN_BSTR aPath)
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync{
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync ReturnComNotImplemented();
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync#else
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync LogFlowThisFuncEnter();
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync return setError(E_INVALIDARG, tr("No file to remove specified"));
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync AutoCaller autoCaller(this);
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync GuestProcessStartupInfo procInfo;
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync GuestProcessStream streamOut;
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync int rc = VINF_SUCCESS;
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync try /* Can this be done without exceptions? */
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync {
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync Utf8Str strPath(aPath);
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync procInfo.mName = Utf8StrFmt(tr("Removing file \"%s\"",
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync strPath.c_str()));
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_RM);
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync procInfo.mFlags = ProcessCreateFlag_Hidden
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync | ProcessCreateFlag_WaitForStdOut;
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync /* Construct arguments. */
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync procInfo.mArguments.push_back(Utf8Str("--machinereadable"));
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync procInfo.mArguments.push_back(Bstr(aPath)); /* The directory we want to create. */
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync }
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync catch (...)
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync {
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync return E_OUTOFMEMORY;
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync }
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync ComObjPtr<GuestProcess> pProcess;
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync rc = processCreateExInteral(procInfo, pProcess);
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync if (RT_SUCCESS(rc))
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync rc = pProcess->startProcess();
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync if (RT_SUCCESS(rc))
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync {
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync GuestProcessWaitResult waitRes;
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync BYTE byBuf[_64K];
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync size_t cbRead;
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync for (;;)
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync {
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync rc = pProcess->waitFor(ProcessWaitForFlag_StdOut,
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync 30 * 1000 /* Timeout */, waitRes);
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync if ( RT_FAILURE(rc)
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync || waitRes.mResult == ProcessWaitResult_Terminate
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync || waitRes.mResult == ProcessWaitResult_Error
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync || waitRes.mResult == ProcessWaitResult_Timeout)
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync {
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync break;
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync }
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync rc = pProcess->readData(OUTPUT_HANDLE_ID_STDOUT, sizeof(byBuf),
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync 30 * 1000 /* Timeout */, byBuf, sizeof(byBuf),
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync &cbRead);
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync if (RT_FAILURE(rc))
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync break;
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync if (cbRead)
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync {
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync rc = streamOut.AddData(byBuf, cbRead);
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync if (RT_FAILURE(rc))
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync break;
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync }
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync }
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync LogFlowThisFunc(("rc=%Rrc, cbRead=%RU32, cbStreamOut=%RU32\n",
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync rc, cbRead, streamOut.GetSize()));
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync }
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync else
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync return setError(E_FAIL, tr("Error while starting delete tool on guest: %Rrc"), rc);
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync if (RT_FAILURE(rc))
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync return setError(E_FAIL, tr("Error while running delete tool on guest: %Rrc"), rc);
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync if (!streamOut.GetSize())
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync return setError(E_FAIL, tr("No return code after deleting file"));
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync GuestProcessStreamBlock streamBlock;
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync rc = streamOut.ParseBlock(streamBlock);
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync if (RT_SUCCESS(rc))
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync {
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync streamBlock.GetString("fname");
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync int64_t i64rc;
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync if (RT_FAILURE(streamBlock.GetInt64Ex("rc", &i64rc)))
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync return setError(E_FAIL, tr("No return code after deleting file"));
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync if (RT_FAILURE((int)i64rc))
df3d97ef4590e6a4ca98e649e2a78bea3a9d28bbvboxsync return setError(VBOX_E_IPRT_ERROR, tr("File deletion failed: %Rrc"), rc);
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync }
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync else
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync return setError(E_FAIL, tr("Error while getting return code from deleting file: %Rrc"), rc);
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync return S_OK;
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync}
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::FileOpen(IN_BSTR aPath, IN_BSTR aOpenMode, IN_BSTR aDisposition, ULONG aCreationMode, LONG64 aOffset, IGuestFile **aFile)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync return setError(E_INVALIDARG, tr("No file to open specified"));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_UNLIKELY((aOpenMode) == NULL || *(aOpenMode) == '\0'))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync return setError(E_INVALIDARG, tr("No open mode specified"));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_UNLIKELY((aDisposition) == NULL || *(aDisposition) == '\0'))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync return setError(E_INVALIDARG, tr("No disposition mode specified"));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync CheckComArgOutPointerValid(aFile);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /** @todo Validate open mode. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /** @todo Validate disposition mode. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /** @todo Validate creation mode. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync uint32_t uCreationMode = 0;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync HRESULT hr = S_OK;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync ComObjPtr <GuestFile> pFile;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync int rc = fileOpenInternal(Utf8Str(aPath), Utf8Str(aOpenMode), Utf8Str(aDisposition),
5366e994777f9d9391cf809dc77610f57270d75dvboxsync aCreationMode, aOffset, pFile);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync if (RT_SUCCESS(rc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /* Return directory object to the caller. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync hr = pFile.queryInterfaceTo(aFile);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync else
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync switch (rc)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /** @todo Add more error info! */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync default:
5366e994777f9d9391cf809dc77610f57270d75dvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Directory creation failed: %Rrc"), rc);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync break;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::FileQueryInfo(IN_BSTR aPath, IGuestFsObjInfo **aInfo)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::FileQuerySize(IN_BSTR aPath, LONG64 *aSize)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync return setError(E_INVALIDARG, tr("No file to query size for specified"));
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync CheckComArgOutPointerValid(aSize);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync HRESULT hr = S_OK;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync int64_t llSize;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync int rc = fileQuerySizeInternal(Utf8Str(aPath), &llSize);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync if (RT_SUCCESS(rc))
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync {
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync *aSize = llSize;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync }
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync else
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync {
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync switch (rc)
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync {
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync /** @todo Add more errors here! */
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync default:
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Querying file size failed: %Rrc"), rc);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync break;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync }
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync }
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::FileRename(IN_BSTR aSource, IN_BSTR aDest, ComSafeArrayIn(PathRenameFlag_T, aFlags))
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::FileSetACL(IN_BSTR aPath, IN_BSTR aACL)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::ProcessCreate(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS, IGuestProcess **aProcess)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync com::SafeArray<LONG> affinity;
45655563f818c5d5bbf4b3d14aa48cbd92a871f1vboxsync
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync HRESULT hr = ProcessCreateEx(aCommand, ComSafeArrayInArg(aArguments), ComSafeArrayInArg(aEnvironment),
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync ComSafeArrayInArg(aFlags), aTimeoutMS, ProcessPriority_Default, ComSafeArrayAsInParam(affinity), aProcess);
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::ProcessCreateEx(IN_BSTR aCommand, ComSafeArrayIn(IN_BSTR, aArguments), ComSafeArrayIn(IN_BSTR, aEnvironment),
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsync ComSafeArrayIn(ProcessCreateFlag_T, aFlags), ULONG aTimeoutMS,
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsync ProcessPriority_T aPriority, ComSafeArrayIn(LONG, aAffinity),
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync IGuestProcess **aProcess)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync if (RT_UNLIKELY((aCommand) == NULL || *(aCommand) == '\0'))
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync return setError(E_INVALIDARG, tr("No command to execute specified"));
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync CheckComArgOutPointerValid(aProcess);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync GuestProcessStartupInfo procInfo;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync procInfo.mCommand = Utf8Str(aCommand);
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync if (aArguments)
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync {
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync com::SafeArray<IN_BSTR> arguments(ComSafeArrayInArg(aArguments));
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync for (size_t i = 0; i < arguments.size(); i++)
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync procInfo.mArguments.push_back(Utf8Str(arguments[i]));
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync }
45655563f818c5d5bbf4b3d14aa48cbd92a871f1vboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync int rc = VINF_SUCCESS;
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync /*
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync * Create the process environment:
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync * - Apply the session environment in a first step, and
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync * - Apply environment variables specified by this call to
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync * have the chance of overwriting/deleting session entries.
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync */
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync procInfo.mEnvironment = mData.mEnvironment; /* Apply original session environment. */
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync if (aEnvironment)
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync {
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync com::SafeArray<IN_BSTR> environment(ComSafeArrayInArg(aEnvironment));
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync for (size_t i = 0; i < environment.size() && RT_SUCCESS(rc); i++)
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync rc = procInfo.mEnvironment.Set(Utf8Str(environment[i]));
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync }
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync HRESULT hr = S_OK;
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync if (RT_SUCCESS(rc))
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync {
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync if (aFlags)
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync {
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync com::SafeArray<ProcessCreateFlag_T> flags(ComSafeArrayInArg(aFlags));
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync for (size_t i = 0; i < flags.size(); i++)
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync procInfo.mFlags |= flags[i];
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync }
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync procInfo.mTimeoutMS = aTimeoutMS;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync if (aAffinity)
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync {
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync com::SafeArray<LONG> affinity(ComSafeArrayInArg(aAffinity));
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync for (size_t i = 0; i < affinity.size(); i++)
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync procInfo.mAffinity[i] = affinity[i]; /** @todo Really necessary? Later. */
907b6adfa052386a0666d5557bee9bdbc100c2e5vboxsync }
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync procInfo.mPriority = aPriority;
45655563f818c5d5bbf4b3d14aa48cbd92a871f1vboxsync
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync ComObjPtr<GuestProcess> pProcess;
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync rc = processCreateExInteral(procInfo, pProcess);
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync if (RT_SUCCESS(rc))
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync {
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync /* Return guest session to the caller. */
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync HRESULT hr2 = pProcess.queryInterfaceTo(aProcess);
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync if (FAILED(hr2))
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync rc = VERR_COM_OBJECT_NOT_FOUND;
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync if (RT_SUCCESS(rc))
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync rc = pProcess->startProcessAsync();
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync }
7862f4bd000f1eb6c86289f5ac2849e9cf943ca9vboxsync }
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync if (RT_FAILURE(rc))
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync {
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync switch (rc)
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync {
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync case VERR_MAX_PROCS_REACHED:
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Maximum number of guest processes per session (%ld) reached"),
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync VBOX_GUESTCTRL_MAX_PROCESSES);
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync break;
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync /** @todo Add more errors here. */
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync default:
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Could not create guest process, rc=%Rrc"), rc);
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync break;
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync }
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync }
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync LogFlowFuncLeaveRC(rc);
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsyncSTDMETHODIMP GuestSession::ProcessGet(ULONG aPID, IGuestProcess **aProcess)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync LogFlowThisFunc(("aPID=%RU32\n", aPID));
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync CheckComArgOutPointerValid(aProcess);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync if (aPID == 0)
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync return setError(E_INVALIDARG, tr("No valid process ID (PID) specified"));
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync AutoReadLock alock(this COMMA_LOCKVAL_SRC_POS);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync HRESULT hr = S_OK;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync ComObjPtr<GuestProcess> pProcess;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync int rc = processGetByPID(aPID, &pProcess);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync if (RT_FAILURE(rc))
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync hr = setError(E_INVALIDARG, tr("No process with PID %RU32 found"), aPID);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync /* This will set (*aProcess) to NULL if pProgress is NULL. */
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync HRESULT hr2 = pProcess.queryInterfaceTo(aProcess);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync if (SUCCEEDED(hr))
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync hr = hr2;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync LogFlowThisFunc(("aProcess=%p, hr=%Rhrc\n", *aProcess, hr));
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::SymlinkCreate(IN_BSTR aSource, IN_BSTR aTarget, SymlinkType_T aType)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::SymlinkExists(IN_BSTR aSymlink, BOOL *aExists)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
06ea6bcf23874b662d499b3f130024c98b2dd7a6vboxsyncSTDMETHODIMP GuestSession::SymlinkRead(IN_BSTR aSymlink, ComSafeArrayIn(SymlinkReadFlag_T, aFlags), BSTR *aTarget)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::SymlinkRemoveDirectory(IN_BSTR aPath)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsyncSTDMETHODIMP GuestSession::SymlinkRemoveFile(IN_BSTR aFile)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync