]> git.proxmox.com Git - mirror_lxc.git/commitdiff
cgroups: remove unused method and cleanup cgroup_exit()
authorChristian Brauner <christian.brauner@ubuntu.com>
Tue, 25 Feb 2020 12:36:51 +0000 (13:36 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Tue, 25 Feb 2020 12:38:32 +0000 (13:38 +0100)
Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/cgroups/cgfsng.c
src/lxc/cgroups/cgroup.c
src/lxc/cgroups/cgroup.h

index 3e5345b62dd2dc82cf90e326d4e5a13b51f29950..aa054a63d3e17eef041f5ef0fb62a0604ca262cf 100644 (file)
@@ -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);
index 2e9670e3b190b015a6b33c727f38a3fc7acf61ff..37fd0e377d7e2e6135b3496333af58e1617e8a8c 100644 (file)
@@ -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);
 
index 46644c8445f4b618565615b7dad0acd5a2a8b1a4..32692fd71119f4f4f67cad2435d2b185743efe70 100644 (file)
@@ -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);