2
0
mirror of git://github.com/lxc/lxc synced 2025-09-03 11:09:32 +00:00

fix Coding Style

Fix the coding style, 80 chars lines, etc ...
Fix indentation blocks if ... then ... else ... fi

Signed-off-by: Daniel Lezcano <dlezcano@fr.ibm.com>
This commit is contained in:
Daniel Lezcano
2010-10-12 10:52:47 +02:00
committed by Daniel Lezcano
parent e3b4c4c44a
commit 751d9dcd39

View File

@@ -186,51 +186,61 @@ static struct caps_opt caps_opt[] = {
{ "mac_admin", CAP_MAC_ADMIN }, { "mac_admin", CAP_MAC_ADMIN },
}; };
static int run_script(const char *name, const char *section, const char *script, ...) static int run_script(const char *name, const char *section,
const char *script, ...)
{ {
va_list argp; va_list argp;
int vargc = 4; int vargc = 4;
int status = 0;
/* count variable arguments and add 4 for script, container /* count variable arguments and add 4 for script, container
* and section name as well as the terminating NULL * and section name as well as the terminating NULL
*/ */
va_start(argp, script); va_start(argp, script);
while (va_arg(argp, char*)) vargc++; while (va_arg(argp, char*)) vargc++;
va_end(argp); va_end(argp);
INFO("Executing script '%s' for container '%s', config section '%s'", script, name, section);
INFO("Executing script '%s' for container '%s', config section '%s'",
script, name, section);
int pid = fork(); int pid = fork();
if (pid < 0) { if (pid < 0) {
ERROR("Error forking"); ERROR("Error forking");
} else if (pid == 0) { return -1;
}
if (pid == 0) {
/* prepare command line arguments */ /* prepare command line arguments */
char *args[vargc]; char *args[vargc];
int i; int i;
args[0] = strdup(script); args[0] = strdup(script);
args[1] = strdup(name); args[1] = strdup(name);
args[2] = strdup(section); args[2] = strdup(section);
va_start(argp, script); va_start(argp, script);
for (i=3; i<vargc; i++) { for (i = 3; i < vargc; i++)
args[i] = va_arg(argp, char*); args[i] = va_arg(argp, char*);
}
va_end(argp); va_end(argp);
args[vargc-1] = (char*) NULL; args[vargc-1] = (char*) NULL;
execv(script, args); execv(script, args);
/* if we cannot exec, we exit this fork */ /* if we cannot exec, we exit this fork */
SYSERROR("Failed to execute script '%s' for container '%s': %s", script, name, strerror(errno)); SYSERROR("Failed to execute script '%s' for container '%s': %s",
script, name);
exit(1); exit(1);
} else {
int status = 0;
waitpid( pid, &status, 0 );
if (status != 0) {
/* something weird happened */
SYSERROR("Script '%s' terminated with non-zero exitcode %d", name, status);
return -1;
} else {
return 0; /* all is well */
}
} }
return -1;
waitpid(pid, &status, 0);
if (status != 0) {
/* something weird happened */
SYSERROR("Script '%s' terminated with non-zero exitcode %d",
name, status);
return -1;
}
return 0;
} }
static int find_fstype_cb(char* buffer, void *data) static int find_fstype_cb(char* buffer, void *data)
@@ -1317,13 +1327,10 @@ static int instanciate_veth(struct lxc_handler *handler, struct lxc_netdev *netd
} }
if (netdev->upscript) { if (netdev->upscript) {
err = run_script(handler->name, "net", netdev->upscript, "up", "veth", err = run_script(handler->name, "net", netdev->upscript, "up",
veth1, (char*) NULL); "veth", veth1, (char*) NULL);
if (err) { if (err)
ERROR("Failed to run script '%s' for container '%s' and interface '%s'",
netdev->upscript, handler->name, veth1);
goto out_delete; goto out_delete;
}
} }
DEBUG("instanciated veth '%s/%s', index is '%d'", DEBUG("instanciated veth '%s/%s', index is '%d'",
@@ -1370,13 +1377,10 @@ static int instanciate_macvlan(struct lxc_handler *handler, struct lxc_netdev *n
} }
if (netdev->upscript) { if (netdev->upscript) {
err = run_script(handler->name, "net", netdev->upscript, "up", "macvlan", err = run_script(handler->name, "net", netdev->upscript, "up",
netdev->link, (char*) NULL); "macvlan", netdev->link, (char*) NULL);
if (err) { if (err)
ERROR("Failed to run script '%s' for container '%s' and interface '%s'",
netdev->upscript, handler->name, netdev->link);
return -1; return -1;
}
} }
DEBUG("instanciated macvlan '%s', index is '%d' and mode '%d'", DEBUG("instanciated macvlan '%s', index is '%d' and mode '%d'",
@@ -1433,13 +1437,10 @@ static int instanciate_phys(struct lxc_handler *handler, struct lxc_netdev *netd
if (netdev->upscript) { if (netdev->upscript) {
int err; int err;
err = run_script(handler->name, "net", netdev->upscript, "up", "phys", err = run_script(handler->name, "net", netdev->upscript,
netdev->link, (char*) NULL); "up", "phys", netdev->link, (char*) NULL);
if (err) { if (err)
ERROR("Failed to run script '%s' for container '%s' and interface '%s'",
netdev->upscript, handler->name, netdev->link);
return -1; return -1;
}
} }
return 0; return 0;
@@ -1450,11 +1451,10 @@ static int instanciate_empty(struct lxc_handler *handler, struct lxc_netdev *net
netdev->ifindex = 0; netdev->ifindex = 0;
if (netdev->upscript) { if (netdev->upscript) {
int err; int err;
err = run_script(handler->name, "net", netdev->upscript, "up", "empty", (char*) NULL); err = run_script(handler->name, "net", netdev->upscript,
if (err) { "up", "empty", (char*) NULL);
ERROR("Failed to run script '%s' for container '%s'", netdev->upscript, handler->name); if (err)
return -1; return -1;
}
} }
return 0; return 0;
} }