mirror of
git://github.com/lxc/lxc
synced 2025-08-30 20:09:33 +00:00
cgroups: remove unused method and cleanup cgroup_exit()
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
@@ -1833,57 +1833,6 @@ on_error:
|
||||
return retval;
|
||||
}
|
||||
|
||||
static int recursive_count_nrtasks(char *dirname)
|
||||
{
|
||||
__do_free char *path = NULL;
|
||||
__do_closedir DIR *dir = NULL;
|
||||
struct dirent *direntp;
|
||||
int count = 0, ret;
|
||||
|
||||
dir = opendir(dirname);
|
||||
if (!dir)
|
||||
return 0;
|
||||
|
||||
while ((direntp = readdir(dir))) {
|
||||
struct stat mystat;
|
||||
|
||||
if (!strcmp(direntp->d_name, ".") ||
|
||||
!strcmp(direntp->d_name, ".."))
|
||||
continue;
|
||||
|
||||
path = must_make_path(dirname, direntp->d_name, NULL);
|
||||
|
||||
if (lstat(path, &mystat))
|
||||
continue;
|
||||
|
||||
if (!S_ISDIR(mystat.st_mode))
|
||||
continue;
|
||||
|
||||
count += recursive_count_nrtasks(path);
|
||||
}
|
||||
|
||||
path = must_make_path(dirname, "cgroup.procs", NULL);
|
||||
ret = lxc_count_file_lines(path);
|
||||
if (ret != -1)
|
||||
count += ret;
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
__cgfsng_ops static int cgfsng_nrtasks(struct cgroup_ops *ops)
|
||||
{
|
||||
__do_free char *path = NULL;
|
||||
|
||||
if (!ops)
|
||||
return ret_set_errno(-1, ENOENT);
|
||||
|
||||
if (!ops->container_cgroup || !ops->hierarchies)
|
||||
return ret_set_errno(-1, EINVAL);
|
||||
|
||||
path = must_make_path(ops->hierarchies[0]->container_full_path, NULL);
|
||||
return recursive_count_nrtasks(path);
|
||||
}
|
||||
|
||||
/* Only root needs to escape to the cgroup of its init. */
|
||||
__cgfsng_ops static bool cgfsng_escape(const struct cgroup_ops *ops,
|
||||
struct lxc_conf *conf)
|
||||
@@ -3279,7 +3228,6 @@ struct cgroup_ops *cgfsng_ops_init(struct lxc_conf *conf)
|
||||
cgfsng_ops->attach = cgfsng_attach;
|
||||
cgfsng_ops->chown = cgfsng_chown;
|
||||
cgfsng_ops->mount = cgfsng_mount;
|
||||
cgfsng_ops->nrtasks = cgfsng_nrtasks;
|
||||
cgfsng_ops->devices_activate = cgfsng_devices_activate;
|
||||
|
||||
return move_ptr(cgfsng_ops);
|
||||
|
@@ -53,13 +53,10 @@ struct cgroup_ops *cgroup_init(struct lxc_conf *conf)
|
||||
|
||||
void cgroup_exit(struct cgroup_ops *ops)
|
||||
{
|
||||
char **cur;
|
||||
struct hierarchy **it;
|
||||
|
||||
if (!ops)
|
||||
return;
|
||||
|
||||
for (cur = ops->cgroup_use; cur && *cur; cur++)
|
||||
for (char **cur = ops->cgroup_use; cur && *cur; cur++)
|
||||
free(*cur);
|
||||
|
||||
free(ops->cgroup_pattern);
|
||||
@@ -69,14 +66,12 @@ void cgroup_exit(struct cgroup_ops *ops)
|
||||
if (ops->cgroup2_devices)
|
||||
bpf_program_free(ops->cgroup2_devices);
|
||||
|
||||
for (it = ops->hierarchies; it && *it; it++) {
|
||||
char **p;
|
||||
|
||||
for (p = (*it)->controllers; p && *p; p++)
|
||||
for (struct hierarchy **it = ops->hierarchies; it && *it; it++) {
|
||||
for (char **p = (*it)->controllers; p && *p; p++)
|
||||
free(*p);
|
||||
free((*it)->controllers);
|
||||
|
||||
for (p = (*it)->cgroup2_chown; p && *p; p++)
|
||||
for (char **p = (*it)->cgroup2_chown; p && *p; p++)
|
||||
free(*p);
|
||||
free((*it)->cgroup2_chown);
|
||||
|
||||
|
@@ -161,7 +161,6 @@ struct cgroup_ops {
|
||||
const char *lxcpath, pid_t pid);
|
||||
bool (*mount)(struct cgroup_ops *ops, struct lxc_handler *handler,
|
||||
const char *root, int type);
|
||||
int (*nrtasks)(struct cgroup_ops *ops);
|
||||
bool (*devices_activate)(struct cgroup_ops *ops,
|
||||
struct lxc_handler *handler);
|
||||
bool (*monitor_delegate_controllers)(struct cgroup_ops *ops);
|
||||
|
Reference in New Issue
Block a user