GuestCtrlImplDir.cpp revision bf2e596de1ba94c3502e0cce7d81e35bf213a876
/* $Id: */
/** @file
* VirtualBox Guest Control - Guest directory handling.
*/
/*
* Copyright (C) 2011 Oracle Corporation
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*/
#include "GuestImpl.h"
#include "GuestCtrlImplPrivate.h"
#include "Global.h"
#include "ConsoleImpl.h"
#include "ProgressImpl.h"
#include "VMMDev.h"
#include "AutoCaller.h"
#include "Logging.h"
#ifdef VBOX_WITH_GUEST_CONTROL
#endif
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else /* VBOX_WITH_GUEST_CONTROL */
using namespace guestControl;
if (directoryHandleExists(aHandle))
{
return S_OK;
}
return setError(VBOX_E_IPRT_ERROR,
#endif
}
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else /* VBOX_WITH_GUEST_CONTROL */
using namespace guestControl;
/* Do not allow anonymous executions (with system rights). */
LogRel(("Creating guest directory \"%s\" as user \"%s\" ...\n",
return directoryCreateInternal(aDirectory,
#endif
}
#ifdef VBOX_WITH_GUEST_CONTROL
{
using namespace guestControl;
AutoCaller autoCaller(this);
/* Validate flags. */
if (aFlags != DirectoryCreateFlag_None)
{
if (!(aFlags & DirectoryCreateFlag_Parents))
{
}
}
try
{
/*
* Prepare tool command line.
*/
if (aMode > 0)
{
char szMode[16];
}
}
{
rc = E_OUTOFMEMORY;
}
return rc;
}
/**
* Creates a new directory handle ID and returns it. Returns VERR_TOO_MUCH_DATA
* if no free handles left, otherwise VINF_SUCCESS (or some other IPRT error).
*
* @return IPRT status code.
* @param puHandle Pointer where the handle gets stored to.
* @param uPID PID of guest process running the associated "vbox_ls".
* @param pszDirectory Directory the handle is assigned to.
* @param pszFilter Directory filter. Optional.
* @param uFlags Directory open flags.
*
*/
{
/* pszFilter is optional. */
int rc = VERR_TOO_MUCH_DATA;
{
/* Create a new context ID ... */
{
rc = VINF_SUCCESS;
rc = VERR_NO_MEMORY;
else
{
/* Filter is optional. */
if (pszFilter)
{
rc = VERR_NO_MEMORY;
}
if (RT_SUCCESS(rc))
{
*puHandle = uHandleTry;
break;
}
}
if (RT_FAILURE(rc))
break;
}
}
return rc;
}
/**
* Destroys a previously created directory handle and its
* associated data.
*
* @return IPRT status code.
* @param uHandle Handle to destroy.
*/
{
{
/* Remove callback context (not used anymore). */
}
}
/**
* Gets the associated PID from a directory handle.
*
* @param uHandle Directory handle to get PID for.
*/
{
return 0;
}
/**
* Checks whether a specified directory handle exists (is valid)
* or not.
*
* @return bool True if handle exists, false if not.
* @param uHandle Directory handle to check.
*/
{
return true;
return false;
}
#endif /* VBOX_WITH_GUEST_CONTROL */
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else /* VBOX_WITH_GUEST_CONTROL */
using namespace guestControl;
/* Do not allow anonymous executions (with system rights). */
#endif
}
#ifdef VBOX_WITH_GUEST_CONTROL
{
using namespace guestControl;
AutoCaller autoCaller(this);
/* Validate flags. No flags supported yet. */
if (aFlags != DirectoryOpenFlag_None)
try
{
/*
* Prepare tool command line.
*/
/* We need to get output which is machine-readable in form
* of "key=value\0..key=value\0\0". */
/* We want the long output format. Handy for getting a lot of
* details we could (should?) use (later). */
/* As we want to keep this stuff simple we don't do recursive (-R)
* or dereferencing (--dereference) lookups here. This has to be done by
* the user. */
/* Construct and hand in actual directory name + filter we want to open. */
char *pszDirectoryFinal;
int cbRet;
if (Utf8Filter.isEmpty())
else
if (!cbRet)
{
/* Assign new directory handle ID. */
aFlags);
if (RT_FAILURE(vrc))
}
}
{
rc = E_OUTOFMEMORY;
}
return rc;
}
#endif /* VBOX_WITH_GUEST_CONTROL */
{
#ifndef VBOX_WITH_GUEST_CONTROL
#else /* VBOX_WITH_GUEST_CONTROL */
using namespace guestControl;
if (uPID)
{
ULONG cbOutputData = 0;
30 * 1000 /* Timeout in ms */,
{
}
return rc;
}
return setError(VBOX_E_IPRT_ERROR,
#endif
}