]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
cgroups: rename cgroupfs mount fd
authorChristian Brauner <christian.brauner@ubuntu.com>
Sun, 21 Feb 2021 09:54:23 +0000 (10:54 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sun, 21 Feb 2021 10:25:38 +0000 (11:25 +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 4c2eb48f3656090391ff8db0ce5ab08ab39fe978..cb36abc5b1199a8a306972c399799333b929d8fe 100644 (file)
@@ -3084,11 +3084,11 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative,
                        if (IS_ERR(current_cgroup))
                                return PTR_ERR(current_cgroup);
 
-                       if (unified_cgroup_fd(ops->dfd_mnt_cgroupfs_host)) {
-                               dfd_mnt = dup_cloexec(ops->dfd_mnt_cgroupfs_host);
+                       if (unified_cgroup_fd(ops->dfd_mnt)) {
+                               dfd_mnt = dup_cloexec(ops->dfd_mnt);
                                unified_mnt = "";
                        } else {
-                               dfd_mnt = open_at(ops->dfd_mnt_cgroupfs_host,
+                               dfd_mnt = open_at(ops->dfd_mnt,
                                                  "unified",
                                                  PROTECT_OPATH_DIRECTORY,
                                                  PROTECT_LOOKUP_ABSOLUTE_XDEV, 0);
@@ -3096,7 +3096,7 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative,
                        }
                        if (dfd_mnt < 0) {
                                if (errno != ENOENT)
-                                       return syserrno(-errno, "Failed to open %d/unified", ops->dfd_mnt_cgroupfs_host);
+                                       return syserrno(-errno, "Failed to open %d/unified", ops->dfd_mnt);
 
                                SYSTRACE("Unified cgroup not mounted");
                                continue;
@@ -3146,13 +3146,13 @@ static int __initialize_cgroups(struct cgroup_ops *ops, bool relative,
                        if (!controllers)
                                return ret_errno(ENOMEM);
 
-                       dfd_mnt = open_at(ops->dfd_mnt_cgroupfs_host,
+                       dfd_mnt = open_at(ops->dfd_mnt,
                                          controllers, PROTECT_OPATH_DIRECTORY,
                                          PROTECT_LOOKUP_ABSOLUTE_XDEV, 0);
                        if (dfd_mnt < 0) {
                                if (errno != ENOENT)
                                        return syserrno(-errno, "Failed to open %d/%s",
-                                                       ops->dfd_mnt_cgroupfs_host, controllers);
+                                                       ops->dfd_mnt, controllers);
 
                                SYSTRACE("%s not mounted", controllers);
                                continue;
@@ -3236,7 +3236,7 @@ static int initialize_cgroups(struct cgroup_ops *ops, struct lxc_conf *conf)
        int ret;
        const char *controllers_use;
 
-       if (ops->dfd_mnt_cgroupfs_host >= 0)
+       if (ops->dfd_mnt >= 0)
                return ret_errno(EBUSY);
 
        /*
@@ -3270,7 +3270,7 @@ static int initialize_cgroups(struct cgroup_ops *ops, struct lxc_conf *conf)
         * once we know the initialization succeeded. So if we fail we clean up
         * the dfd.
         */
-       ops->dfd_mnt_cgroupfs_host = dfd;
+       ops->dfd_mnt = dfd;
 
        ret = __initialize_cgroups(ops, conf->cgroup_meta.relative, !lxc_list_empty(&conf->id_map));
        if (ret < 0)
@@ -3308,7 +3308,7 @@ struct cgroup_ops *cgroup_ops_init(struct lxc_conf *conf)
                return ret_set_errno(NULL, ENOMEM);
 
        cgfsng_ops->cgroup_layout = CGROUP_LAYOUT_UNKNOWN;
-       cgfsng_ops->dfd_mnt_cgroupfs_host = -EBADF;
+       cgfsng_ops->dfd_mnt = -EBADF;
 
        if (initialize_cgroups(cgfsng_ops, conf))
                return NULL;
index 4696606550183a5df0542729825a2ed43da7a6eb..fa40fc8e6ac78326758df4cc1ba52c14bd6614e6 100644 (file)
@@ -73,8 +73,8 @@ void cgroup_exit(struct cgroup_ops *ops)
 
        bpf_device_program_free(ops);
 
-       if (ops->dfd_mnt_cgroupfs_host >= 0)
-               close(ops->dfd_mnt_cgroupfs_host);
+       if (ops->dfd_mnt >= 0)
+               close(ops->dfd_mnt);
 
        for (struct hierarchy **it = ops->hierarchies; it && *it; it++) {
                for (char **p = (*it)->controllers; p && *p; p++)
index daca3f60ff4c3672d3b7230548cc0653c50344e7..47945781e33ef2c3af22f8a4e71822565a4261e8 100644 (file)
@@ -130,7 +130,7 @@ struct cgroup_ops {
         * So for CGROUP_LAYOUT_LEGACY or CGROUP_LAYOUT_HYBRID we allow
         * mountpoint crossing iff we cross from a tmpfs into a cgroupfs mount.
         * */
-       int dfd_mnt_cgroupfs_host;
+       int dfd_mnt;
 
        /* What controllers is the container supposed to use. */
        char **cgroup_use;