GuestSessionImpl.cpp revision c99b597540585068d22dde4c9f74730305f24097
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
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync#ifdef LOG_GROUP
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync #undef LOG_GROUP
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync#endif
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync#define LOG_GROUP LOG_GROUP_GUEST_CONTROL
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync#include <VBox/log.h>
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
c4b821bf03ae7641a0791e3fd161247e66433b68vboxsync
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
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;
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync mData.mNumObjects = 0;
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
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync int rc = VINF_SUCCESS;
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync LogFlowThisFunc(("Closing directories (%RU64 total)\n",
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync mData.mDirectories.size()));
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync for (SessionDirectories::iterator itDirs = mData.mDirectories.begin();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync itDirs != mData.mDirectories.end(); ++itDirs)
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync {
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync#ifdef DEBUG
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync ULONG cRefs = (*itDirs)->AddRef();
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync LogFlowThisFunc(("pFile=%p, cRefs=%RU32\n", (*itDirs), cRefs));
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync (*itDirs)->Release();
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync#endif
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync (*itDirs)->uninit();
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync mData.mDirectories.clear();
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync LogFlowThisFunc(("Closing files (%RU64 total)\n",
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync mData.mFiles.size()));
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync for (SessionFiles::iterator itFiles = mData.mFiles.begin();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync itFiles != mData.mFiles.end(); ++itFiles)
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync {
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync#ifdef DEBUG
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync ULONG cRefs = (*itFiles)->AddRef();
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync LogFlowThisFunc(("pFile=%p, cRefs=%RU32\n", (*itFiles), cRefs));
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync (*itFiles)->Release();
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync#endif
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync (*itFiles)->uninit();
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync mData.mFiles.clear();
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync LogFlowThisFunc(("Closing processes (%RU64 total)\n",
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync mData.mProcesses.size()));
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync for (SessionProcesses::iterator itProcs = mData.mProcesses.begin();
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync itProcs != mData.mProcesses.end(); ++itProcs)
ed9d3db07648c7e3a979105c15ad752ee9ea18devboxsync {
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync#ifdef DEBUG
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync ULONG cRefs = itProcs->second->AddRef();
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync LogFlowThisFunc(("pProcess=%p, cRefs=%RU32\n", itProcs->second, cRefs));
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync itProcs->second->Release();
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync#endif
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync itProcs->second->uninit();
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync mData.mProcesses.clear();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync LogFlowThisFunc(("mNumObjects=%RU32\n", mData.mNumObjects));
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync#endif
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync LogFlowFuncLeaveRC(rc);
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
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsyncint GuestSession::directoryRemoveFromList(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 {
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync Bstr strName;
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync HRESULT hr = (*itDirs)->COMGETTER(DirectoryName)(strName.asOutParam());
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync ComAssertComRC(hr);
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync Assert(mData.mDirectories.size());
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync LogFlowFunc(("Removing directory \"%s\" (Session: %RU32) (now total %ld directories)\n",
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync Utf8Str(strName).c_str(), mData.mId, mData.mDirectories.size() - 1));
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync mData.mDirectories.erase(itDirs);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return VINF_SUCCESS;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return VERR_NOT_FOUND;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync}
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsyncint GuestSession::directoryCreateInternal(const Utf8Str &strPath, uint32_t uMode, uint32_t uFlags, int *pGuestRc)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync{
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync LogFlowThisFunc(("strPath=%s, uMode=%x, uFlags=%x\n",
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync strPath.c_str(), uMode, uFlags));
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync GuestProcessStartupInfo procInfo;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_MKDIR);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync procInfo.mFlags = ProcessCreateFlag_Hidden;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync int vrc = 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
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync vrc = VERR_BUFFER_OVERFLOW;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync procInfo.mArguments.push_back(strPath); /* The directory we want to create. */
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync int guestRc;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(vrc))
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync GuestProcessTool procTool;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync vrc = procTool.Init(this, procInfo, false /* Async */, &guestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(vrc))
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(guestRc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync vrc = procTool.Wait(GUESTPROCESSTOOL_FLAG_NONE, &guestRc);
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(vrc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(guestRc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync guestRc = procTool.TerminatedOk(NULL /* Exit code */);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync }
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (pGuestRc)
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync *pGuestRc = guestRc;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync LogFlowFuncLeaveRC(vrc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_FAILURE(vrc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return vrc;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return RT_SUCCESS(guestRc) ? VINF_SUCCESS : VERR_GENERAL_FAILURE; /** @todo Special guest control rc needed! */
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync}
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsyncint GuestSession::directoryQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc)
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync{
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync LogFlowThisFunc(("strPath=%s\n", strPath.c_str()));
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync int vrc = fsQueryInfoInternal(strPath, objData, pGuestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(vrc))
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync vrc = objData.mType == FsObjType_Directory
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync ? VINF_SUCCESS : VERR_NOT_A_DIRECTORY;
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync }
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync LogFlowFuncLeaveRC(vrc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return vrc;
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync}
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsyncint GuestSession::objectCreateTempInternal(const Utf8Str &strTemplate, const Utf8Str &strPath,
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync bool fDirectory, const Utf8Str &strName, int *pGuestRc)
ca3db470494a8b6eaec69ea37468a5cda65e2da8vboxsync{
ca3db470494a8b6eaec69ea37468a5cda65e2da8vboxsync GuestProcessStartupInfo procInfo;
ca3db470494a8b6eaec69ea37468a5cda65e2da8vboxsync procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_MKTEMP);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync procInfo.mFlags = ProcessCreateFlag_WaitForStdOut;
ca3db470494a8b6eaec69ea37468a5cda65e2da8vboxsync procInfo.mArguments.push_back(Utf8Str("--machinereadable"));
ca3db470494a8b6eaec69ea37468a5cda65e2da8vboxsync if (fDirectory)
ca3db470494a8b6eaec69ea37468a5cda65e2da8vboxsync procInfo.mArguments.push_back(Utf8Str("-d"));
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (strPath.length()) /* Otherwise use /tmp or equivalent. */
ca3db470494a8b6eaec69ea37468a5cda65e2da8vboxsync {
ca3db470494a8b6eaec69ea37468a5cda65e2da8vboxsync procInfo.mArguments.push_back(Utf8Str("-t"));
ca3db470494a8b6eaec69ea37468a5cda65e2da8vboxsync procInfo.mArguments.push_back(strPath);
ca3db470494a8b6eaec69ea37468a5cda65e2da8vboxsync }
ca3db470494a8b6eaec69ea37468a5cda65e2da8vboxsync procInfo.mArguments.push_back(strTemplate);
ca3db470494a8b6eaec69ea37468a5cda65e2da8vboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync GuestProcessTool procTool; int guestRc;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync int vrc = procTool.Init(this, procInfo, false /* Async */, &guestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(vrc))
ca3db470494a8b6eaec69ea37468a5cda65e2da8vboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(guestRc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync vrc = procTool.Wait(GUESTPROCESSTOOL_FLAG_NONE, &guestRc);
ca3db470494a8b6eaec69ea37468a5cda65e2da8vboxsync }
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(vrc))
ca3db470494a8b6eaec69ea37468a5cda65e2da8vboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(guestRc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync guestRc = procTool.TerminatedOk(NULL /* Exit code */);
ca3db470494a8b6eaec69ea37468a5cda65e2da8vboxsync }
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (pGuestRc)
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync *pGuestRc = guestRc;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_FAILURE(vrc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return vrc;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return RT_SUCCESS(guestRc) ? VINF_SUCCESS : VERR_GENERAL_FAILURE; /** @todo Special guest control rc needed! */
ca3db470494a8b6eaec69ea37468a5cda65e2da8vboxsync}
ca3db470494a8b6eaec69ea37468a5cda65e2da8vboxsync
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
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Create the directory object. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync HRESULT hr = pDirectory.createObject();
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (FAILED(hr))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return VERR_COM_UNEXPECTED;
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync int vrc = pDirectory->init(this /* Parent */,
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync strPath, strFilter, uFlags);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_FAILURE(vrc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return vrc;
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Add the created directory to our vector. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mData.mDirectories.push_back(pDirectory);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync LogFlowFunc(("Added new directory \"%s\" (Session: %RU32)\n",
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync strPath.c_str(), mData.mId));
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync LogFlowFuncLeaveRC(vrc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return vrc;
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
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync uint32_t uProcessID = VBOX_GUESTCTRL_CONTEXTID_GET_OBJECT(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
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsyncint GuestSession::fileRemoveFromList(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 {
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync Bstr strName;
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync HRESULT hr = (*itFiles)->COMGETTER(FileName)(strName.asOutParam());
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync ComAssertComRC(hr);
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync Assert(mData.mNumObjects);
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync LogFlowThisFunc(("Removing file \"%s\" (Session: %RU32) (now total %ld files, %ld objects)\n",
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync Utf8Str(strName).c_str(), mData.mId, mData.mFiles.size() - 1, mData.mNumObjects - 1));
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync#ifdef DEBUG
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync ULONG cRefs = pFile->AddRef();
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync LogFlowThisFunc(("pObject=%p, cRefs=%RU32\n", pFile, cRefs));
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync pFile->Release();
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync#endif
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync mData.mFiles.erase(itFiles);
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync mData.mNumObjects--;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return VINF_SUCCESS;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync return VERR_NOT_FOUND;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync}
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsyncint GuestSession::fileRemoveInternal(const Utf8Str &strPath, int *pGuestRc)
004d74842597dacc4009803171296dfcf9398c69vboxsync{
004d74842597dacc4009803171296dfcf9398c69vboxsync GuestProcessStartupInfo procInfo;
004d74842597dacc4009803171296dfcf9398c69vboxsync GuestProcessStream streamOut;
004d74842597dacc4009803171296dfcf9398c69vboxsync
004d74842597dacc4009803171296dfcf9398c69vboxsync procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_RM);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync procInfo.mFlags = ProcessCreateFlag_WaitForStdOut;
004d74842597dacc4009803171296dfcf9398c69vboxsync procInfo.mArguments.push_back(Utf8Str("--machinereadable"));
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync procInfo.mArguments.push_back(strPath); /* The file we want to remove. */
004d74842597dacc4009803171296dfcf9398c69vboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync GuestProcessTool procTool; int guestRc;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync int vrc = procTool.Init(this, procInfo, false /* Async */, &guestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(vrc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync vrc = procTool.Wait(GUESTPROCESSTOOL_FLAG_NONE, &guestRc);
004d74842597dacc4009803171296dfcf9398c69vboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(vrc))
004d74842597dacc4009803171296dfcf9398c69vboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(guestRc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync guestRc = procTool.TerminatedOk(NULL /* Exit code */);
004d74842597dacc4009803171296dfcf9398c69vboxsync }
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (pGuestRc)
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync *pGuestRc = guestRc;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_FAILURE(vrc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return vrc;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return RT_SUCCESS(guestRc) ? VINF_SUCCESS : VERR_GENERAL_FAILURE; /** @todo Special guest control rc needed! */
004d74842597dacc4009803171296dfcf9398c69vboxsync}
004d74842597dacc4009803171296dfcf9398c69vboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsyncint GuestSession::fileOpenInternal(const Utf8Str &strPath, const Utf8Str &strOpenMode, const Utf8Str &strDisposition,
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync uint32_t uCreationMode, int64_t iOffset, ComObjPtr<GuestFile> &pFile, int *pGuestRc)
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
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Create the directory object. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync HRESULT hr = pFile.createObject();
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (FAILED(hr))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return VERR_COM_UNEXPECTED;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync int vrc = pFile->init(this /* Parent */,
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync strPath, strOpenMode, strDisposition, uCreationMode, iOffset, pGuestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_FAILURE(vrc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return vrc;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync /** @todo Handle guestRc. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Add the created directory to our vector. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mData.mFiles.push_back(pFile);
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync mData.mNumObjects++;
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync Assert(mData.mNumObjects <= VBOX_GUESTCTRL_MAX_OBJECTS);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync LogFlowFunc(("Added new file \"%s\" (Session: %RU32) (now total %ld files, %ld objects)\n",
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync strPath.c_str(), mData.mId, mData.mProcesses.size(), mData.mNumObjects));
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync LogFlowFuncLeaveRC(vrc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return vrc;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync}
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsyncint GuestSession::fileQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc)
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync{
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync LogFlowThisFunc(("strPath=%s\n", strPath.c_str()));
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync int vrc = fsQueryInfoInternal(strPath, objData, pGuestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(vrc))
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync vrc = objData.mType == FsObjType_File
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync ? VINF_SUCCESS : VERR_NOT_A_FILE;
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync }
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync LogFlowFuncLeaveRC(vrc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return vrc;
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync}
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsyncint GuestSession::fileQuerySizeInternal(const Utf8Str &strPath, int64_t *pllSize, int *pGuestRc)
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync{
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync AssertPtrReturn(pllSize, VERR_INVALID_POINTER);
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync GuestFsObjData objData;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync int vrc = fileQueryInfoInternal(strPath, objData, pGuestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(vrc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync *pllSize = objData.mObjectSize;
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return vrc;
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync}
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsyncint GuestSession::fsQueryInfoInternal(const Utf8Str &strPath, GuestFsObjData &objData, int *pGuestRc)
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync{
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync LogFlowThisFunc(("strPath=%s\n", strPath.c_str()));
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync
3ff8aa7d3c74cfbe8da5f77b8ea6c748cc79213avboxsync /** @todo Merge this with IGuestFile::queryInfo(). */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync GuestProcessStartupInfo procInfo;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync procInfo.mCommand = Utf8Str(VBOXSERVICE_TOOL_STAT);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync procInfo.mFlags = ProcessCreateFlag_WaitForStdOut;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync /* Construct arguments. */
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync procInfo.mArguments.push_back(Utf8Str("--machinereadable"));
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync procInfo.mArguments.push_back(strPath);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync GuestProcessTool procTool; int guestRc;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync int vrc = procTool.Init(this, procInfo, false /* Async */, &guestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(vrc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync vrc = procTool.Wait(GUESTPROCESSTOOL_FLAG_NONE, &guestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(vrc))
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync guestRc = procTool.TerminatedOk(NULL /* Exit code */);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(guestRc))
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync GuestProcessStreamBlock curBlock;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync vrc = procTool.GetCurrentBlock(OUTPUT_HANDLE_ID_STDOUT, curBlock);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync /** @todo Check for more / validate blocks! */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(vrc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync vrc = objData.FromStat(curBlock);
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync }
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync }
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (pGuestRc)
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync *pGuestRc = guestRc;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync LogFlowFuncLeaveRC(vrc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_FAILURE(vrc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return vrc;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return RT_SUCCESS(guestRc) ? VINF_SUCCESS : VERR_GENERAL_FAILURE; /** @todo Special guest control rc needed! */
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
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsyncint GuestSession::processRemoveFromList(GuestProcess *pProcess)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync{
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync LogFlowThisFuncEnter();
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync AutoWriteLock alock(this COMMA_LOCKVAL_SRC_POS);
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync int rc = VERR_NOT_FOUND;
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync ULONG uPID;
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync HRESULT hr = pProcess->COMGETTER(PID)(&uPID);
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync LogFlowFunc(("Closing process (PID=%RU32) ...\n", uPID));
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync for (SessionProcesses::iterator itProcs = mData.mProcesses.begin();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync itProcs != mData.mProcesses.end(); ++itProcs)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync {
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync if (pProcess == itProcs->second)
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync {
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync GuestProcess *pCurProc = itProcs->second;
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync AssertPtr(pCurProc);
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync hr = pCurProc->COMGETTER(PID)(&uPID);
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync ComAssertComRC(hr);
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync Assert(mData.mNumObjects);
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync LogFlowFunc(("Removing process (Session: %RU32) with process ID=%RU32, guest PID=%RU32 (now total %ld processes, %ld objects)\n",
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync mData.mId, pCurProc->getProcessID(), uPID, mData.mProcesses.size() - 1, mData.mNumObjects - 1));
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync mData.mProcesses.erase(itProcs);
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync mData.mNumObjects--;
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync rc = VINF_SUCCESS;
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync break;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync }
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync LogFlowFuncLeaveRC(rc);
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync return rc;
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;
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync if (mData.mNumObjects >= VBOX_GUESTCTRL_MAX_OBJECTS)
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++;
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync if (uNewProcessID == VBOX_GUESTCTRL_MAX_OBJECTS)
6b9d50a0f466bd5a61458ed53925480ab28a3c17vboxsync uNewProcessID = 0;
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync if (++uTries == UINT32_MAX)
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync break; /* Don't try too hard. */
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync }
5f2b03bf7695dabd71222dba123532a3f76828c1vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_FAILURE(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return rc;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Create the process object. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync HRESULT hr = pProcess.createObject();
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (FAILED(hr))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return VERR_COM_UNEXPECTED;
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync rc = pProcess->init(mData.mParent->getConsole() /* Console */, this /* Session */,
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync uNewProcessID, procInfo);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_FAILURE(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return rc;
cc1ef2ef9bbc6a0ff964928d61b7298e5bfcce5fvboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Add the created process to our map. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync mData.mProcesses[uNewProcessID] = pProcess;
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync mData.mNumObjects++;
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync Assert(mData.mNumObjects <= VBOX_GUESTCTRL_MAX_OBJECTS);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync LogFlowFunc(("Added new process (Session: %RU32) with process ID=%RU32 (now total %ld processes, %ld objects)\n",
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync mData.mId, uNewProcessID, mData.mProcesses.size(), mData.mNumObjects));
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
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync SessionProcesses::iterator itProcs = mData.mProcesses.begin();
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync for (; itProcs != mData.mProcesses.end(); itProcs++)
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync {
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync ComObjPtr<GuestProcess> pCurProc = itProcs->second;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync AutoCaller procCaller(pCurProc);
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync if (procCaller.rc())
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync return VERR_COM_INVALID_OBJECT_STATE;
687794577e2e35c3cae67e692a7f2130d1262a82vboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync ULONG uCurPID;
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync HRESULT hr = pCurProc->COMGETTER(PID)(&uCurPID);
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync ComAssertComRC(hr);
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync if (uCurPID == 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
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Create the progress object. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync HRESULT hr = pProgress.createObject();
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (FAILED(hr))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return VERR_COM_UNEXPECTED;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync hr = pProgress->init(static_cast<IGuestSession*>(this),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync Bstr(strTaskDesc).raw(),
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync TRUE /* aCancelable */);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (FAILED(hr))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return VERR_COM_UNEXPECTED;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Initialize our worker task. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync std::auto_ptr<GuestSessionTask> task(pTask);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync int rc = task->RunAsync(strTaskDesc, pProgress);
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync if (RT_FAILURE(rc))
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync return rc;
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync /* Don't destruct on success. */
88cc9bf61296bc5526344415167bb2625ae1dd99vboxsync task.release();
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
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync AutoCaller autoCaller(this);
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync /* Remove ourselves from the session list. */
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync mData.mParent->sessionRemove(this);
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync /*
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync * Release autocaller before calling uninit.
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync */
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync autoCaller.release();
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync
9523921c89c66f4bececdbd5ac95aed0039eda1bvboxsync uninit();
d4a9d525e6f2111d462d2d96462dced6b9ec00efvboxsync
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync LogFlowFuncLeave();
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
c99b597540585068d22dde4c9f74730305f24097vboxsync try
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync {
c99b597540585068d22dde4c9f74730305f24097vboxsync ComObjPtr<Progress> pProgress;
c99b597540585068d22dde4c9f74730305f24097vboxsync SessionTaskCopyFrom *pTask = new SessionTaskCopyFrom(this /* GuestSession */,
c99b597540585068d22dde4c9f74730305f24097vboxsync Utf8Str(aSource), Utf8Str(aDest), fFlags);
c99b597540585068d22dde4c9f74730305f24097vboxsync int rc = startTaskAsync(Utf8StrFmt(tr("Copying \"%ls\" from guest to \"%ls\" on the host"), aSource, aDest),
c99b597540585068d22dde4c9f74730305f24097vboxsync pTask, pProgress);
c99b597540585068d22dde4c9f74730305f24097vboxsync if (RT_SUCCESS(rc))
c99b597540585068d22dde4c9f74730305f24097vboxsync {
c99b597540585068d22dde4c9f74730305f24097vboxsync /* Return progress to the caller. */
c99b597540585068d22dde4c9f74730305f24097vboxsync hr = pProgress.queryInterfaceTo(aProgress);
c99b597540585068d22dde4c9f74730305f24097vboxsync }
c99b597540585068d22dde4c9f74730305f24097vboxsync else
c99b597540585068d22dde4c9f74730305f24097vboxsync hr = setError(VBOX_E_IPRT_ERROR,
c99b597540585068d22dde4c9f74730305f24097vboxsync tr("Starting task for copying file \"%ls\" from guest to \"%ls\" on the host failed: %Rrc"), rc);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync }
c99b597540585068d22dde4c9f74730305f24097vboxsync catch(std::bad_alloc &)
c99b597540585068d22dde4c9f74730305f24097vboxsync {
c99b597540585068d22dde4c9f74730305f24097vboxsync hr = E_OUTOFMEMORY;
c99b597540585068d22dde4c9f74730305f24097vboxsync }
c99b597540585068d22dde4c9f74730305f24097vboxsync
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
c99b597540585068d22dde4c9f74730305f24097vboxsync try
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync {
c99b597540585068d22dde4c9f74730305f24097vboxsync ComObjPtr<Progress> pProgress;
c99b597540585068d22dde4c9f74730305f24097vboxsync SessionTaskCopyTo *pTask = new SessionTaskCopyTo(this /* GuestSession */,
c99b597540585068d22dde4c9f74730305f24097vboxsync Utf8Str(aSource), Utf8Str(aDest), fFlags);
c99b597540585068d22dde4c9f74730305f24097vboxsync AssertPtrReturn(pTask, VERR_NO_MEMORY);
c99b597540585068d22dde4c9f74730305f24097vboxsync int rc = startTaskAsync(Utf8StrFmt(tr("Copying \"%ls\" from host to \"%ls\" on the guest"), aSource, aDest),
c99b597540585068d22dde4c9f74730305f24097vboxsync pTask, pProgress);
c99b597540585068d22dde4c9f74730305f24097vboxsync if (RT_SUCCESS(rc))
c99b597540585068d22dde4c9f74730305f24097vboxsync {
c99b597540585068d22dde4c9f74730305f24097vboxsync /* Return progress to the caller. */
c99b597540585068d22dde4c9f74730305f24097vboxsync hr = pProgress.queryInterfaceTo(aProgress);
c99b597540585068d22dde4c9f74730305f24097vboxsync }
c99b597540585068d22dde4c9f74730305f24097vboxsync else
c99b597540585068d22dde4c9f74730305f24097vboxsync hr = setError(VBOX_E_IPRT_ERROR,
c99b597540585068d22dde4c9f74730305f24097vboxsync tr("Starting task for copying file \"%ls\" from host to \"%ls\" on the guest failed: %Rrc"), rc);
0fd108a555ae02f2fb557d5f2c40281999b60d15vboxsync }
c99b597540585068d22dde4c9f74730305f24097vboxsync catch(std::bad_alloc &)
c99b597540585068d22dde4c9f74730305f24097vboxsync {
c99b597540585068d22dde4c9f74730305f24097vboxsync hr = E_OUTOFMEMORY;
c99b597540585068d22dde4c9f74730305f24097vboxsync }
c99b597540585068d22dde4c9f74730305f24097vboxsync
c99b597540585068d22dde4c9f74730305f24097vboxsync return hr;
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#endif /* VBOX_WITH_GUEST_CONTROL */
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync}
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsyncSTDMETHODIMP GuestSession::DirectoryCreate(IN_BSTR aPath, ULONG aMode,
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync ComSafeArrayIn(DirectoryCreateFlag_T, aFlags))
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
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
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync ComObjPtr <GuestDirectory> pDirectory; int guestRc;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync int rc = directoryCreateInternal(Utf8Str(aPath), (uint32_t)aMode, fFlags, &guestRc);
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync if (RT_FAILURE(rc))
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync switch (rc)
35e6d303696e46d969aaf9a59cc381333a483b0bvboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync case VERR_GENERAL_FAILURE: /** @todo Special guest control rc needed! */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync hr = GuestProcess::setErrorExternal(this, guestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync break;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
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
3641904508e6a0671c21a083a2ed03ebad8d976cvboxsyncSTDMETHODIMP GuestSession::DirectoryCreateTemp(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aPath, BOOL aSecure, BSTR *aDirectory)
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync{
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#ifndef VBOX_WITH_GUEST_CONTROL
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync ReturnComNotImplemented();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync#else
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync LogFlowThisFuncEnter();
702a8ee2dc1de96f2f77e97135015d3e243186fdvboxsync
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync if (RT_UNLIKELY((aTemplate) == NULL || *(aTemplate) == '\0'))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return setError(E_INVALIDARG, tr("No template specified"));
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return setError(E_INVALIDARG, tr("No directory name specified"));
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync CheckComArgOutPointerValid(aDirectory);
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync HRESULT hr = S_OK;
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync Utf8Str strName; int guestRc;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync int rc = objectCreateTempInternal(Utf8Str(aTemplate),
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync Utf8Str(aPath),
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync true /* Directory */, strName, &guestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(rc))
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync {
ca3db470494a8b6eaec69ea37468a5cda65e2da8vboxsync strName.cloneTo(aDirectory);
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync }
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync else
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync switch (rc)
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync case VERR_GENERAL_FAILURE: /** @todo Special guest control rc needed! */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync hr = GuestProcess::setErrorExternal(this, guestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync break;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync default:
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Temporary directory creation \"%s\" with template \"%s\" failed: %Rrc"),
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync Utf8Str(aPath).c_str(), Utf8Str(aTemplate).c_str(), rc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync break;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync }
36f3c24e4ad9c6b813767db1faeabbe7e2ecc057vboxsync }
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return hr;
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
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync GuestFsObjData objData; int guestRc;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync int rc = directoryQueryInfoInternal(Utf8Str(aPath), objData, &guestRc);
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync if (RT_SUCCESS(rc))
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync {
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync *aExists = objData.mType == FsObjType_Directory;
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync }
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync else
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync {
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync switch (rc)
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync case VERR_GENERAL_FAILURE: /** @todo Special guest control rc needed! */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync hr = GuestProcess::setErrorExternal(this, guestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync break;
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync default:
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Querying directory existence \"%s\" failed: %Rrc"),
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync Utf8Str(aPath).c_str(), 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'))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return setError(E_INVALIDARG, tr("Directory filters are not implemented yet"));
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 {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync /* Return directory object to the caller. */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync hr = pDirectory.queryInterfaceTo(aDirectory);
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync }
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync else
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync {
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync switch (rc)
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync {
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync case VERR_INVALID_PARAMETER:
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Opening directory \"%s\" failed; invalid parameters given",
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync Utf8Str(aPath).c_str()));
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync break;
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync
8bc8d66f188d5357155b8340e2d489573be2b607vboxsync default:
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Opening directory \"%s\" failed: %Rrc"),
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync Utf8Str(aPath).c_str(),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
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync return setError(E_INVALIDARG, tr("No directory to query information for specified"));
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync CheckComArgOutPointerValid(aInfo);
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync HRESULT hr = S_OK;
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync GuestFsObjData objData; int guestRc;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync int vrc = directoryQueryInfoInternal(Utf8Str(aPath), objData, &guestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(vrc))
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync {
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync if (objData.mType == FsObjType_Directory)
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync {
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync ComObjPtr<GuestFsObjInfo> pFsObjInfo;
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync hr = pFsObjInfo.createObject();
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (FAILED(hr)) return hr;
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync vrc = pFsObjInfo->init(objData);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(vrc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync {
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync hr = pFsObjInfo.queryInterfaceTo(aInfo);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (FAILED(hr)) return hr;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync }
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync }
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync }
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_FAILURE(vrc))
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync switch (vrc)
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync case VERR_GENERAL_FAILURE: /** @todo Special guest control rc needed! */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync hr = GuestProcess::setErrorExternal(this, guestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync break;
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync case VERR_NOT_A_DIRECTORY:
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Element \"%s\" exists but is not a directory",
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync Utf8Str(aPath).c_str()));
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync break;
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync default:
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Querying directory information for \"%s\" failed: %Rrc"),
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync Utf8Str(aPath).c_str(), vrc);
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync break;
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync }
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync }
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync return hr;
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
92e624e40b06b4dc6d0a8222e1de33bd3e879a63vboxsyncSTDMETHODIMP GuestSession::FileCreateTemp(IN_BSTR aTemplate, ULONG aMode, IN_BSTR aPath, BOOL aSecure, 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
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync GuestFsObjData objData; int guestRc;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync int vrc = fileQueryInfoInternal(Utf8Str(aPath), objData, &guestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(vrc))
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync *aExists = TRUE;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return S_OK;
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync }
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync HRESULT hr = S_OK;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync switch (vrc)
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync case VERR_GENERAL_FAILURE: /** @todo Special guest control rc needed! */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync hr = GuestProcess::setErrorExternal(this, guestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync break;
58c0567dee3cc3ebe62dec1e27f8e35bac4ddeb0vboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync case VERR_NOT_A_FILE:
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync *aExists = FALSE;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync break;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync default:
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Querying file information for \"%s\" failed: %Rrc"),
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync Utf8Str(aPath).c_str(), vrc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync break;
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
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync HRESULT hr = S_OK;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync int guestRc;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync int vrc = fileRemoveInternal(Utf8Str(aPath), &guestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_FAILURE(vrc))
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync switch (vrc)
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync case VERR_GENERAL_FAILURE: /** @todo Special guest control rc needed! */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync hr = GuestProcess::setErrorExternal(this, guestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync break;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync default:
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Removing file \"%s\" failed: %Rrc"),
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync Utf8Str(aPath).c_str(), vrc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync break;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync }
9e17ca2e9d797e845e3284141dd4086a4b817ae5vboxsync }
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return hr;
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
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync ComObjPtr <GuestFile> pFile; int guestRc;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync int vrc = fileOpenInternal(Utf8Str(aPath), Utf8Str(aOpenMode), Utf8Str(aDisposition),
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync aCreationMode, aOffset, pFile, &guestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(vrc))
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5366e994777f9d9391cf809dc77610f57270d75dvboxsync /* Return directory object to the caller. */
5366e994777f9d9391cf809dc77610f57270d75dvboxsync hr = pFile.queryInterfaceTo(aFile);
5366e994777f9d9391cf809dc77610f57270d75dvboxsync }
5366e994777f9d9391cf809dc77610f57270d75dvboxsync else
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync switch (vrc)
5366e994777f9d9391cf809dc77610f57270d75dvboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync case VERR_GENERAL_FAILURE: /** @todo Special guest control rc needed! */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync hr = GuestProcess::setErrorExternal(this, guestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync break;
5366e994777f9d9391cf809dc77610f57270d75dvboxsync
5366e994777f9d9391cf809dc77610f57270d75dvboxsync default:
c4d2656b949ac8efc3c83eb540ec25a9c889b9d6vboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Opening file \"%s\" failed: %Rrc"),
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync Utf8Str(aPath).c_str(), vrc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync 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
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync if (RT_UNLIKELY((aPath) == NULL || *(aPath) == '\0'))
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync return setError(E_INVALIDARG, tr("No file to query information for specified"));
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync CheckComArgOutPointerValid(aInfo);
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync AutoCaller autoCaller(this);
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync if (FAILED(autoCaller.rc())) return autoCaller.rc();
2f3883b126a405f92b19e829472f614c7352b4f9vboxsync
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync HRESULT hr = S_OK;
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync GuestFsObjData objData; int guestRc;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync int vrc = fileQueryInfoInternal(Utf8Str(aPath), objData, &guestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(vrc))
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync {
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync ComObjPtr<GuestFsObjInfo> pFsObjInfo;
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync hr = pFsObjInfo.createObject();
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (FAILED(hr)) return hr;
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync vrc = pFsObjInfo->init(objData);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(vrc))
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync {
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync hr = pFsObjInfo.queryInterfaceTo(aInfo);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (FAILED(hr)) return hr;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync }
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync }
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_FAILURE(vrc))
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync switch (vrc)
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync case VERR_GENERAL_FAILURE: /** @todo Special guest control rc needed! */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync hr = GuestProcess::setErrorExternal(this, guestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync break;
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync case VERR_NOT_A_FILE:
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Element exists but is not a file"));
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync break;
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync default:
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Querying file information failed: %Rrc"), vrc);
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync break;
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync }
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync }
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync
4121d226ac899f17e13aff3aff42b603c8b5c1fevboxsync return hr;
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
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync int64_t llSize; int guestRc;
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync int vrc = fileQuerySizeInternal(Utf8Str(aPath), &llSize, &guestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync if (RT_SUCCESS(vrc))
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync {
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync *aSize = llSize;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync }
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync else
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync switch (vrc)
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync {
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync case VERR_GENERAL_FAILURE: /** @todo Special guest control rc needed! */
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync hr = GuestProcess::setErrorExternal(this, guestRc);
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync break;
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync
e378dfdadd62aadc0a012c9953322d979d7606e6vboxsync default:
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Querying file size failed: %Rrc"), vrc);
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
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync return ProcessCreateEx(aCommand, ComSafeArrayInArg(aArguments), ComSafeArrayInArg(aEnvironment),
5050fc8de0b121eab1b738d7c1007cde4903284dvboxsync ComSafeArrayInArg(aFlags), aTimeoutMS, ProcessPriority_Default, ComSafeArrayAsInParam(affinity), aProcess);
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:
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync hr = setError(VBOX_E_IPRT_ERROR, tr("Maximum number of guest objects per session (%ld) reached"),
c10a6f0c7041e4d1ee50ad38425aab9d43c55522vboxsync VBOX_GUESTCTRL_MAX_OBJECTS);
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