Commit 758437c5 by Michel Normand Committed by Daniel Lezcano

place nscgroup path in lxc_handler

this also avoid to call two times get_cgroup_mount Signed-off-by: 's avatarMichel Normand <normand@fr.ibm.com> Signed-off-by: 's avatarDaniel Lezcano <dlezcano@fr.ibm.com>
parent 52e35957
......@@ -81,10 +81,10 @@ out:
return err;
}
int lxc_rename_nsgroup(const char *name, pid_t pid)
int lxc_rename_nsgroup(const char *name, struct lxc_handler *handler)
{
char oldname[MAXPATHLEN];
char newname[MAXPATHLEN];
char *newname = handler->nsgroup;
char cgroup[MAXPATHLEN];
int ret;
......@@ -93,7 +93,7 @@ int lxc_rename_nsgroup(const char *name, pid_t pid)
return -1;
}
snprintf(oldname, MAXPATHLEN, "%s/%d", cgroup, pid);
snprintf(oldname, MAXPATHLEN, "%s/%d", cgroup, handler->pid);
snprintf(newname, MAXPATHLEN, "%s/%s", cgroup, name);
/* there is a previous cgroup, assume it is empty, otherwise
......@@ -113,23 +113,16 @@ int lxc_rename_nsgroup(const char *name, pid_t pid)
else
DEBUG("'%s' renamed to '%s'", oldname, newname);
return ret;
}
int lxc_link_nsgroup(const char *name)
int lxc_link_nsgroup(const char *name, const char *nsgroup)
{
char lxc[MAXPATHLEN];
char nsgroup[MAXPATHLEN];
char cgroup[MAXPATHLEN];
int ret;
if (get_cgroup_mount(MTAB, cgroup)) {
ERROR("cgroup is not mounted");
return -1;
}
snprintf(lxc, MAXPATHLEN, LXCPATH "/%s/nsgroup", name);
snprintf(nsgroup, MAXPATHLEN, "%s/%s", cgroup, name);
unlink(lxc);
ret = symlink(nsgroup, lxc);
......
......@@ -25,9 +25,10 @@
#define MAXPRIOLEN 24
struct lxc_handler;
int lxc_get_cgroup_mount(const char *mtab, char *mnt);
int lxc_rename_nsgroup(const char *name, pid_t pid);
int lxc_link_nsgroup(const char *name);
int lxc_rename_nsgroup(const char *name, struct lxc_handler *handler);
int lxc_link_nsgroup(const char *name, const char *nsgroup);
int lxc_unlink_nsgroup(const char *name);
#endif
......@@ -424,7 +424,8 @@ int lxc_spawn(const char *name, struct lxc_handler *handler, char *const argv[])
goto out_abort;
}
if (lxc_rename_nsgroup(name, handler->pid) || lxc_link_nsgroup(name))
if (lxc_rename_nsgroup(name, handler) ||
lxc_link_nsgroup(name, handler->nsgroup))
goto out_abort;
/* Create the network configuration */
......
......@@ -29,6 +29,7 @@ struct lxc_handler {
int sigfd;
int lock;
char tty[MAXPATHLEN];
char nsgroup[MAXPATHLEN];
sigset_t oldmask;
struct lxc_tty_info tty_info;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment