commands: portlxc_cmd_get_cgroup_path_do() to new helpers

parent 19ed9e74
...@@ -781,23 +781,16 @@ static int lxc_cmd_get_clone_flags_callback(int fd, struct lxc_cmd_req *req, ...@@ -781,23 +781,16 @@ static int lxc_cmd_get_clone_flags_callback(int fd, struct lxc_cmd_req *req,
} }
static char *lxc_cmd_get_cgroup_path_do(const char *name, const char *lxcpath, static char *lxc_cmd_get_cgroup_path_do(const char *name, const char *lxcpath,
const char *subsystem, const char *controller,
lxc_cmd_t command) lxc_cmd_t command)
{ {
bool stopped = false; bool stopped = false;
struct lxc_cmd_rr cmd = {
.req = {
.cmd = command,
.data = subsystem,
.datalen = 0,
},
};
int ret; int ret;
struct lxc_cmd_rr cmd;
cmd.req.data = subsystem; lxc_cmd_init(&cmd, command);
cmd.req.datalen = 0; if (controller)
if (subsystem) lxc_cmd_data(&cmd, strlen(controller) + 1, controller);
cmd.req.datalen = strlen(subsystem) + 1;
ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL); ret = lxc_cmd(name, &cmd, &stopped, lxcpath, NULL);
if (ret < 0) if (ret < 0)
...@@ -813,7 +806,7 @@ static char *lxc_cmd_get_cgroup_path_do(const char *name, const char *lxcpath, ...@@ -813,7 +806,7 @@ static char *lxc_cmd_get_cgroup_path_do(const char *name, const char *lxcpath,
* socket, sending us an EOF. * socket, sending us an EOF.
*/ */
return lxc_cmd_get_cgroup_path_do(name, lxcpath, return lxc_cmd_get_cgroup_path_do(name, lxcpath,
subsystem, controller,
LXC_CMD_GET_CGROUP); LXC_CMD_GET_CGROUP);
} }
return NULL; return NULL;
...@@ -827,41 +820,41 @@ static char *lxc_cmd_get_cgroup_path_do(const char *name, const char *lxcpath, ...@@ -827,41 +820,41 @@ static char *lxc_cmd_get_cgroup_path_do(const char *name, const char *lxcpath,
/* /*
* lxc_cmd_get_cgroup_path: Calculate a container's cgroup path for a * lxc_cmd_get_cgroup_path: Calculate a container's cgroup path for a
* particular subsystem. This is the cgroup path relative to the root * particular controller. This is the cgroup path relative to the root
* of the cgroup filesystem. * of the cgroup filesystem.
* *
* @name : name of container to connect to * @name : name of container to connect to
* @lxcpath : the lxcpath in which the container is running * @lxcpath : the lxcpath in which the container is running
* @subsystem : the subsystem being asked about * @controller : the controller being asked about
* *
* Returns the path on success, NULL on failure. The caller must free() the * Returns the path on success, NULL on failure. The caller must free() the
* returned path. * returned path.
*/ */
char *lxc_cmd_get_cgroup_path(const char *name, const char *lxcpath, char *lxc_cmd_get_cgroup_path(const char *name, const char *lxcpath,
const char *subsystem) const char *controller)
{ {
return lxc_cmd_get_cgroup_path_do(name, lxcpath, subsystem, return lxc_cmd_get_cgroup_path_do(name, lxcpath, controller,
LXC_CMD_GET_CGROUP); LXC_CMD_GET_CGROUP);
} }
/* /*
* lxc_cmd_get_limit_cgroup_path: Calculate a container's limit cgroup * lxc_cmd_get_limit_cgroup_path: Calculate a container's limit cgroup
* path for a particular subsystem. This is the cgroup path relative to the * path for a particular controller. This is the cgroup path relative to the
* root of the cgroup filesystem. This may be the same as the path returned by * root of the cgroup filesystem. This may be the same as the path returned by
* lxc_cmd_get_cgroup_path if the container doesn't have a limit path prefix * lxc_cmd_get_cgroup_path if the container doesn't have a limit path prefix
* set. * set.
* *
* @name : name of container to connect to * @name : name of container to connect to
* @lxcpath : the lxcpath in which the container is running * @lxcpath : the lxcpath in which the container is running
* @subsystem : the subsystem being asked about * @controller : the controller being asked about
* *
* Returns the path on success, NULL on failure. The caller must free() the * Returns the path on success, NULL on failure. The caller must free() the
* returned path. * returned path.
*/ */
char *lxc_cmd_get_limit_cgroup_path(const char *name, const char *lxcpath, char *lxc_cmd_get_limit_cgroup_path(const char *name, const char *lxcpath,
const char *subsystem) const char *controller)
{ {
return lxc_cmd_get_cgroup_path_do(name, lxcpath, subsystem, return lxc_cmd_get_cgroup_path_do(name, lxcpath, controller,
LXC_CMD_GET_LIMIT_CGROUP); LXC_CMD_GET_LIMIT_CGROUP);
} }
......
...@@ -102,10 +102,10 @@ __hidden extern int lxc_cmd_get_tty_fd(const char *name, int *ttynum, int *fd, ...@@ -102,10 +102,10 @@ __hidden extern int lxc_cmd_get_tty_fd(const char *name, int *ttynum, int *fd,
const char *lxcpath); const char *lxcpath);
/* /*
* Get the 'real' cgroup path (as seen in /proc/self/cgroup) for a container * Get the 'real' cgroup path (as seen in /proc/self/cgroup) for a container
* for a particular subsystem * for a particular controller
*/ */
__hidden extern char *lxc_cmd_get_cgroup_path(const char *name, const char *lxcpath, __hidden extern char *lxc_cmd_get_cgroup_path(const char *name, const char *lxcpath,
const char *subsystem); const char *controller);
__hidden extern int lxc_cmd_get_clone_flags(const char *name, const char *lxcpath); __hidden extern int lxc_cmd_get_clone_flags(const char *name, const char *lxcpath);
__hidden extern char *lxc_cmd_get_config_item(const char *name, const char *item, __hidden extern char *lxc_cmd_get_config_item(const char *name, const char *item,
const char *lxcpath); const char *lxcpath);
...@@ -164,7 +164,7 @@ __hidden extern int lxc_cmd_get_cgroup_fd(const char *name, const char *lxcpath, ...@@ -164,7 +164,7 @@ __hidden extern int lxc_cmd_get_cgroup_fd(const char *name, const char *lxcpath,
struct cgroup_fd *ret_fd); struct cgroup_fd *ret_fd);
__hidden extern char *lxc_cmd_get_limit_cgroup_path(const char *name, __hidden extern char *lxc_cmd_get_limit_cgroup_path(const char *name,
const char *lxcpath, const char *lxcpath,
const char *subsystem); const char *controller);
__hidden extern int lxc_cmd_get_limit_cgroup2_fd(const char *name, __hidden extern int lxc_cmd_get_limit_cgroup2_fd(const char *name,
const char *lxcpath); const char *lxcpath);
__hidden extern int lxc_cmd_get_limit_cgroup_fd(const char *name, __hidden extern int lxc_cmd_get_limit_cgroup_fd(const char *name,
......
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