AutostartDb-generic.cpp revision 395d92a7732aad3c0b9baecedfabba5113b84485
/* $Id$ */
/** @file
* VirtualBox Main - Autostart implementation.
*/
/*
* Copyright (C) 2009-2010 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 "AutostartDb.h"
#if defined(RT_OS_LINUX)
/**
* Modifies the autostart database.
*
* @returns VBox status code.
* @param fAutostart Flag whether the autostart or autostop database is modified.
* @param fAddVM Flag whether a VM is added or removed from the database.
*/
{
int rc = VINF_SUCCESS;
/* Check if the path is set. */
if (!m_pszAutostartDbPath)
return VERR_PATH_NOT_FOUND;
if (RT_SUCCESS(rc))
{
char *pszFile;
if (fAddVM)
else
fOpen |= RTFILE_O_OPEN;
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
/*
* Files with more than 16 bytes are rejected because they just contain
* a number of the amount of VMs with autostart configured, so they
* should be really really small. Anything else is bogus.
*/
if ( RT_SUCCESS(rc)
&& cbFile <= 16)
{
uint32_t cAutostartVms = 0;
/* Check if the file was just created. */
if (cbFile)
{
if (RT_SUCCESS(rc))
{
if ( rc == VWRN_TRAILING_CHARS
|| rc == VWRN_TRAILING_SPACES)
rc = VINF_SUCCESS;
}
}
if (RT_SUCCESS(rc))
{
/* Modify VM counter and write back. */
if (fAddVM)
else
if (cAutostartVms > 0)
{
if (RT_SUCCESS(rc))
}
else
{
/* Just delete the file if there are no VMs left. */
}
}
}
else if (RT_SUCCESS(rc))
if (hAutostartFile != NIL_RTFILE)
}
}
}
return rc;
}
#endif
{
#ifdef RT_OS_LINUX
#endif
}
{
#ifdef RT_OS_LINUX
RTCritSectDelete(&this->CritSect);
if (m_pszAutostartDbPath)
#endif
}
{
#if defined(RT_OS_LINUX)
char *pszAutostartDbPathTmp = NULL;
{
if (!pszAutostartDbPathTmp)
return VERR_NO_MEMORY;
}
RTCritSectEnter(&this->CritSect);
if (m_pszAutostartDbPath)
RTCritSectLeave(&this->CritSect);
return VINF_SUCCESS;
#else
return VERR_NOT_SUPPORTED;
#endif
}
{
int rc = VERR_NOT_SUPPORTED;
#if defined(RT_OS_LINUX)
RTCritSectEnter(&this->CritSect);
RTCritSectLeave(&this->CritSect);
rc = VINF_SUCCESS;
#else
#endif
return rc;
}
{
int rc = VINF_SUCCESS;
#if defined(RT_OS_LINUX)
RTCritSectEnter(&this->CritSect);
RTCritSectLeave(&this->CritSect);
rc = VINF_SUCCESS;
#else
#endif
return rc;
}
{
int rc = VINF_SUCCESS;
#if defined(RT_OS_LINUX)
RTCritSectEnter(&this->CritSect);
RTCritSectLeave(&this->CritSect);
#elif defined(RT_OS_DARWIN)
rc = VINF_SUCCESS;
#else
#endif
return rc;
}
{
int rc = VINF_SUCCESS;
#if defined(RT_OS_LINUX)
RTCritSectEnter(&this->CritSect);
RTCritSectLeave(&this->CritSect);
#elif defined(RT_OS_DARWIN)
rc = VINF_SUCCESS;
#else
#endif
return rc;
}