mirror of
git://github.com/lxc/lxc
synced 2025-09-03 02:39:33 +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:
committed by
Daniel Lezcano
parent
e3b4c4c44a
commit
751d9dcd39
@@ -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 );
|
waitpid(pid, &status, 0);
|
||||||
if (status != 0) {
|
if (status != 0) {
|
||||||
/* something weird happened */
|
/* something weird happened */
|
||||||
SYSERROR("Script '%s' terminated with non-zero exitcode %d", name, status);
|
SYSERROR("Script '%s' terminated with non-zero exitcode %d",
|
||||||
|
name, status);
|
||||||
return -1;
|
return -1;
|
||||||
} else {
|
|
||||||
return 0; /* all is well */
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return -1;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int find_fstype_cb(char* buffer, void *data)
|
static int find_fstype_cb(char* buffer, void *data)
|
||||||
@@ -1317,14 +1327,11 @@ 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'",
|
||||||
veth1, veth2, netdev->ifindex);
|
veth1, veth2, netdev->ifindex);
|
||||||
@@ -1370,14 +1377,11 @@ 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'",
|
||||||
peer, netdev->ifindex, netdev->priv.macvlan_attr.mode);
|
peer, netdev->ifindex, netdev->priv.macvlan_attr.mode);
|
||||||
@@ -1433,14 +1437,11 @@ 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,12 +1451,11 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user