confile.c revision d685aa8049978e27f9b4d914e3c927c55fff99d0
/*
* 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 <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include "parse.h"
static int config_pts(const char *, char *, struct lxc_conf *);
static int config_tty(const char *, char *, struct lxc_conf *);
static int config_cgroup(const char *, char *, struct lxc_conf *);
static int config_mount(const char *, char *, struct lxc_conf *);
static int config_rootfs(const char *, char *, struct lxc_conf *);
static int config_utsname(const char *, char *, struct lxc_conf *);
static int config_network_type(const char *, char *, struct lxc_conf *);
static int config_network_flags(const char *, char *, struct lxc_conf *);
static int config_network_link(const char *, char *, struct lxc_conf *);
static int config_network_name(const char *, char *, struct lxc_conf *);
static int config_network_hwaddr(const char *, char *, struct lxc_conf *);
static int config_network_mtu(const char *, char *, struct lxc_conf *);
static int config_network_ipv4(const char *, char *, struct lxc_conf *);
static int config_network_ipv6(const char *, char *, struct lxc_conf *);
struct config {
char *name;
};
{ "lxc.pts", config_pts },
{ "lxc.tty", config_tty },
{ "lxc.cgroup", config_cgroup },
{ "lxc.mount", config_mount },
{ "lxc.rootfs", config_rootfs },
{ "lxc.utsname", config_utsname },
{ "lxc.network.type", config_network_type },
{ "lxc.network.flags", config_network_flags },
{ "lxc.network.link", config_network_link },
{ "lxc.network.name", config_network_name },
{ "lxc.network.hwaddr", config_network_hwaddr },
{ "lxc.network.mtu", config_network_mtu },
{ "lxc.network.ipv4", config_network_ipv4 },
{ "lxc.network.ipv6", config_network_ipv6 },
};
{
int i;
for (i = 0; i < config_size; i++)
return &config[i];
return NULL;
}
{
struct lxc_netdev *netdev;
if (!netdev) {
SYSERROR("failed to allocate memory");
return -1;
}
if (!list) {
SYSERROR("failed to allocate memory");
return -1;
}
else {
return -1;
}
return 0;
}
{
return 32 - IN_CLASSA_NSHIFT;
return 32 - IN_CLASSB_NSHIFT;
return 32 - IN_CLASSC_NSHIFT;
return 0;
}
{
struct lxc_netdev *netdev;
if (lxc_list_empty(network)) {
return -1;
}
if (!netdev) {
return -1;
}
return 0;
}
{
struct lxc_netdev *netdev;
if (lxc_list_empty(network)) {
return -1;
}
if (!netdev) {
return -1;
}
return -1;
}
return 0;
}
{
struct lxc_netdev *netdev;
if (lxc_list_empty(network)) {
return -1;
}
if (!netdev) {
return -1;
}
return -1;
}
return 0;
}
{
struct lxc_netdev *netdev;
if (lxc_list_empty(network)) {
return -1;
}
if (!netdev) {
return -1;
}
return 0;
}
{
struct lxc_netdev *netdev;
if (lxc_list_empty(network)) {
return -1;
}
if (!netdev) {
return -1;
}
return 0;
}
{
struct lxc_inetdev *inetdev;
struct lxc_netdev *netdev;
if (lxc_list_empty(network)) {
return -1;
}
if (!netdev) {
}
if (!inetdev) {
SYSERROR("failed to allocate ipv4 address");
return -1;
}
if (!list) {
SYSERROR("failed to allocate memory");
return -1;
}
if (cursor) {
*cursor = '\0';
}
if (slash) {
*slash = '\0';
}
if (!addr) {
ERROR("no address specified");
return -1;
}
return -1;
}
if (bcast)
return -1;
}
/* no prefix specified, determine it from the network class */
return 0;
}
{
struct lxc_netdev *netdev;
struct lxc_inet6dev *inet6dev;
char *slash;
char *netmask;
if (lxc_list_empty(network)) {
return -1;
}
if (!netdev) {
return -1;
}
if (!inet6dev) {
SYSERROR("failed to allocate ipv6 address");
return -1;
}
if (!list) {
SYSERROR("failed to allocate memory");
return -1;
}
if (slash) {
*slash = '\0';
}
return -1;
}
return 0;
}
{
return 0;
}
{
return 0;
}
{
char *subkey;
struct lxc_cgroup *cgelem;
if (!subkey)
return -1;
return -1;
return -1;
if (!cglist)
return -1;
if (!cgelem) {
return -1;
}
return 0;
}
{
return -1;
}
return -1;
}
return 0;
}
{
return -1;
}
return -1;
}
return 0;
}
{
if (!utsname) {
SYSERROR("failed to allocate memory");
return -1;
}
ERROR("node name '%s' is too long",
return -1;
}
return 0;
}
{
char *dot;
char *key;
char *value;
if (lxc_is_line_empty(line))
return 0;
if (line[0] == '#')
return 0;
if (!dot) {
return -1;
}
*dot = '\0';
if (!config) {
return -1;
}
}
{
char buffer[MAXPATHLEN];
}