From: Christian Brauner Date: Tue, 25 Feb 2020 12:36:51 +0000 (+0100) Subject: cgroups: remove unused method and cleanup cgroup_exit() X-Git-Tag: lxc-4.0.0~51^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F3268%2Fhead;p=thirdparty%2Flxc.git cgroups: remove unused method and cleanup cgroup_exit() Signed-off-by: Christian Brauner --- diff --git a/src/lxc/cgroups/cgfsng.c b/src/lxc/cgroups/cgfsng.c index 3e5345b62..aa054a63d 100644 --- a/src/lxc/cgroups/cgfsng.c +++ b/src/lxc/cgroups/cgfsng.c @@ -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); diff --git a/src/lxc/cgroups/cgroup.c b/src/lxc/cgroups/cgroup.c index 2e9670e3b..37fd0e377 100644 --- a/src/lxc/cgroups/cgroup.c +++ b/src/lxc/cgroups/cgroup.c @@ -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); diff --git a/src/lxc/cgroups/cgroup.h b/src/lxc/cgroups/cgroup.h index 46644c844..32692fd71 100644 --- a/src/lxc/cgroups/cgroup.h +++ b/src/lxc/cgroups/cgroup.h @@ -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);