create.c revision c2cc9f0a9b052563d803d3d1e685e307d1d1412b
/*
* lxc: linux Container library
*
* (C) Copyright IBM Corp. 2007, 2008
*
* Authors:
* Daniel Lezcano <dlezcano at fr.ibm.com>
*
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include <stdio.h>
#include <string.h>
#include <dirent.h>
#include <unistd.h>
#include <errno.h>
#include <lxc.h>
{
return 0;
return 1;
}
static int is_empty_directory(const char *dirname)
{
int n;
if (n < 0)
return n == 0;
}
static int create_lxc_directory(const char *dirname)
{
char path[MAXPATHLEN];
return -1;
}
return -1;
}
return 0;
}
static int remove_lxc_directory(const char *dirname)
{
char path[MAXPATHLEN];
return -1;
}
if (is_empty_directory(LXCPATH)) {
return -1;
}
}
return 0;
}
{
if (create_lxc_directory(name)) {
return -1;
}
if (!lock) {
goto err;
}
if (lock < 0) {
lxc_log_error("failed to acquire lock on '%s':%s",
goto err;
}
if (lxc_mkstate(name)) {
goto err;
}
goto err_state;
}
goto err_state;
}
err = 0;
out:
return err;
if (lxc_rmstate(name))
err:
if (remove_lxc_directory(name))
goto out;
}